- update copyright

- add instructions for cross-compilation
- add utility function for Windows and Linux executable path
This commit is contained in:
Hartmut Seichter 2025-05-25 12:31:16 +02:00
parent a4f6803c35
commit 317cde6fa1
30 changed files with 243 additions and 102 deletions

View file

@ -1,7 +1,7 @@
/**
* paradiso - Paradigmen der Softwareentwicklung
*
* (c) Copyright 2023-2024 Hartmut Seichter
* (c) Copyright 2023-2025 Hartmut Seichter and Contributors
*
*/
@ -45,13 +45,10 @@ struct PongStage {
// sprite
paradiso::Sprite sprite{
.bitmap = paradiso::Bitmap::from_data(paradiso::Size{1, 1},
paradiso::RGBA::from_rgb(0x80,0xFF,0xFF))
};
.bitmap = paradiso::Bitmap::from_data(
paradiso::Size{1, 1}, paradiso::RGBA::from_rgb(0x80, 0xFF, 0xFF))};
void draw(const paradiso::Shader& shader) {
renderer.draw(sprite, shader);
}
void draw(const paradiso::Shader& shader) { renderer.draw(sprite, shader); }
paradiso::Renderer renderer{};
};
@ -166,8 +163,9 @@ struct PongBall {
constexpr void push(const auto& impulse) noexcept { velocity += impulse; }
constexpr void whoop(const auto& whoopiness) noexcept { velocity *= whoopiness; }
constexpr void whoop(const auto& whoopiness) noexcept {
velocity *= whoopiness;
}
};
auto main() -> int {
@ -233,19 +231,19 @@ auto main() -> int {
if (!w.keyboard_input().empty()) {
if (w.keyboard_input().top().key == 'R') {
ball.sprite.pivot.x() = 0.0f;
ball.sprite.pivot.y() = 0.9f;
ball.sprite.pivot.x() = 0.0f;
ball.sprite.pivot.y() = 0.9f;
}
// speed adjust
if (w.keyboard_input().top().key == 'N') {
std::cout << "Speed Up!\n";
ball.push(paradiso::Vector2<float>::make(0.f,0.01f));
ball.push(paradiso::Vector2<float>::make(0.f, 0.01f));
} else if (w.keyboard_input().top().key == 'M') {
ball.push(paradiso::Vector2<float>::make(0.f,-0.01f));
ball.push(paradiso::Vector2<float>::make(0.f, -0.01f));
std::cout << "Speed Lower!\n";
}

View file

@ -14,7 +14,10 @@ add_executable(quickwings ${quickwings_srcs} ${quickwings_assets})
target_link_libraries(quickwings paradiso_core)
#
# copy files to bin/../assets folder
#
add_custom_command(TARGET quickwings POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/assets/ $<TARGET_FILE_DIR:quickwings>/assets)
${CMAKE_CURRENT_SOURCE_DIR}/assets/
$<TARGET_FILE_DIR:quickwings>/assets)

View file

@ -1,7 +1,8 @@
/**
* paradiso - Paradigmen der Softwareentwicklung
*
* (c) Copyright 2023-2024 Hartmut Seichter, Robin Rottstädt, brxxh (Hannes Brothuhn)
* (c) Copyright 2023-2025 Hartmut Seichter and Contributors, Robin Rottstädt,
* brxxh (Hannes Brothuhn)
*
*/
@ -77,8 +78,8 @@ struct Background {
};
struct Pipe {
paradiso::Sprite pipe_top;
paradiso::Sprite pipe_bottom;
paradiso::Sprite pipe_top{};
paradiso::Sprite pipe_bottom{};
paradiso::Renderer renderer1{};
paradiso::Renderer renderer2{};
@ -95,16 +96,21 @@ struct Pipe {
pipe_top = paradiso::Sprite{
.bitmap = pipe_image,
.pivot = {paradiso::Vector2<float>::make(1.4f, pipe_spawn_rand + 1.0f)},
.scale = {paradiso::Vector2<float>::make(((500.0f - (500.0f - 52.0f)) / 500.0f) * 2.25f, ((700.0f - (700.0f - 320.0f)) / 700.0f) * 2.25f)},
.pivot = {paradiso::Vector2<float>::make(1.4f,
pipe_spawn_rand + 1.0f)},
.scale = {paradiso::Vector2<float>::make(
((500.0f - (500.0f - 52.0f)) / 500.0f) * 2.25f,
((700.0f - (700.0f - 320.0f)) / 700.0f) * 2.25f)},
.rotation = 3.1415926f};
pipe_bottom = paradiso::Sprite{
.bitmap = pipe_image,
.pivot = {paradiso::Vector2<float>::make(1.4f, pipe_spawn_rand - 1.5f)},
.scale = {paradiso::Vector2<float>::make(((500.0f - (500.0f - 52.0f)) / 500.0f) * 2.25f, ((700.0f - (700.0f - 320.0f)) / 700.0f) * 2.25f)}};
.pivot = {paradiso::Vector2<float>::make(1.4f,
pipe_spawn_rand - 1.5f)},
.scale = {paradiso::Vector2<float>::make(
((500.0f - (500.0f - 52.0f)) / 500.0f) * 2.25f,
((700.0f - (700.0f - 320.0f)) / 700.0f) * 2.25f)}};
paused = true;
}
void update() {
@ -115,8 +121,7 @@ struct Pipe {
if (paused == true) {
return;
}
else {
} else {
pipe_spawn_rand_int = rand() % 80 + 15;
pipe_spawn_rand = float(pipe_spawn_rand_int) / 100;
@ -124,7 +129,8 @@ struct Pipe {
pipe_bottom.pivot.x() -= 0.02f;
risky_pos_x = pipe_top.pivot.x();
risky_pos_max_x = pipe_top.pivot.x() + ((500.0f - (500.0f - 52.0f)) / 500.0f) * 2.25f;
risky_pos_max_x = pipe_top.pivot.x() +
((500.0f - (500.0f - 52.0f)) / 500.0f) * 2.25f;
risky_pos_top_y = pipe_top.pivot.y();
risky_pos_top_max_y = pipe_top.pivot.y() + 10.0f;
@ -173,11 +179,15 @@ struct Grass {
grassLeft = paradiso::Sprite{
.bitmap = grassImage,
.pivot = {paradiso::Vector2<float>::make(0.0f, -0.9f)},
.scale = {paradiso::Vector2<float>::make(((500.0f - (500.0f - 504.0f)) / 500.0f) * 2.25f, ((700.0f - (700.0f - 112.0f)) / 700.0f) * 2.25f)}};
.scale = {paradiso::Vector2<float>::make(
((500.0f - (500.0f - 504.0f)) / 500.0f) * 2.25f,
((700.0f - (700.0f - 112.0f)) / 700.0f) * 2.25f)}};
grassRight = paradiso::Sprite{
.bitmap = grassImage,
.pivot = {paradiso::Vector2<float>::make(1.002f, -0.9f)},
.scale = {paradiso::Vector2<float>::make(((500.0f - (500.0f - 504.0f)) / 500.0f) * 2.25f, ((700.0f - (700.0f - 112.0f)) / 700.0f) * 2.25f)}};
.scale = {paradiso::Vector2<float>::make(
((500.0f - (500.0f - 504.0f)) / 500.0f) * 2.25f,
((700.0f - (700.0f - 112.0f)) / 700.0f) * 2.25f)}};
}
void draw(const paradiso::Shader& shader) {
@ -206,7 +216,6 @@ struct Grass {
}
};
struct QuickWings {
paradiso::Renderer renderer1{};
paradiso::Renderer renderer2{};
@ -295,13 +304,12 @@ struct QuickWings {
// Stop game
if (paused) {
return;
}
else {
// Apply gravity
velocity += gravity;
} else {
// Apply gravity
velocity += gravity;
if (move_up)
velocity += move_up_velocity - gravity;
if (move_up)
velocity += move_up_velocity - gravity;
// Cap velocity
if (velocity > max_velocity)
@ -333,11 +341,11 @@ struct QuickWings {
if (pos >= final_risky_pos_top_y && pos <= risky_pos_top_max_y) {
game_over = true;
}
if (pos <= final_risky_pos_bottom_y && pos >= risky_pos_bottom_max_y) {
if (pos <= final_risky_pos_bottom_y &&
pos >= risky_pos_bottom_max_y) {
if (collision_counter == 0) {
collision_counter++;
}
else {
} else {
collision_counter = 2;
}
@ -354,15 +362,15 @@ struct QuickWings {
paused = false;
if (paused == false) {
bool pressed_up = input.top().key == ' ' || input.top().key == 'W';
bool pressed_up =
input.top().key == ' ' || input.top().key == 'W';
if (input.top().action == 1 && pressed_up) {
move_up = true;
} else if (input.top().action == 0 && pressed_up) {
move_up = false;
}
}
else {
} else {
return;
}
}
@ -377,11 +385,10 @@ struct Message {
Message() {
auto messageImage = paradiso::BitmapIO::get().load("message.png");
messageSprite = paradiso::Sprite{
messageSprite = paradiso::Sprite{
.bitmap = messageImage,
.pivot = {paradiso::Vector2<float>::make(0.0f, 0.0f)},
.scale = {paradiso::Vector2<float>::make(0.8f, 0.8f)}
};
.scale = {paradiso::Vector2<float>::make(0.8f, 0.8f)}};
};
void draw(const paradiso::Shader& shader) {
@ -409,11 +416,12 @@ struct GameOverMessage {
GameOverMessage() {
auto messageImage = paradiso::BitmapIO::get().load("gameover.png");
messageSprite = paradiso::Sprite{
messageSprite = paradiso::Sprite{
.bitmap = messageImage,
.pivot = {paradiso::Vector2<float>::make(0.0f, 0.4f)},
.scale = {paradiso::Vector2<float>::make(((500.0f - (500.0f - 192.0f)) / 500.0f) * 2.25f, ((700.0f - (700.0f - 42.0f)) / 700.0f) * 2.25f)}
};
.scale = {paradiso::Vector2<float>::make(
((500.0f - (500.0f - 192.0f)) / 500.0f) * 2.25f,
((700.0f - (700.0f - 42.0f)) / 700.0f) * 2.25f)}};
};
void draw(const paradiso::Shader& shader) {
@ -438,9 +446,10 @@ auto main() -> int {
*/
window
.set_size(size) // ... Grösse
.set_position(paradiso::Point{.x = 1920 / 2 - 500 / 2, .y = 1080 / 2 - 700 / 2}) // ... Position
.set_title("PardiSO.FlappyBird") // ... Titel
.set_size(size) // ... Grösse
.set_position(paradiso::Point{.x = 1920 / 2 - 500 / 2,
.y = 1080 / 2 - 700 / 2}) // ... Position
.set_title("PardiSO.FlappyBird") // ... Titel
.set_visible(true); // ... und jetzt anzeigen!
// der Fenster Kontext
@ -461,7 +470,6 @@ auto main() -> int {
// nothing beats a classic look
ctx.set_clearcolor(paradiso::RGBA::from_rgb(0x00, 0x00, 0x00));
// Asset loader bekommt den Pfad
paradiso::BitmapIO::get().set_path("assets");
@ -474,7 +482,6 @@ auto main() -> int {
auto message = Message{};
auto gameover = GameOverMessage{};
// timer
// das update führt den hier mitgegebnen Ausdruck innerhalb der internen
@ -522,7 +529,7 @@ auto main() -> int {
// Quit
return !(w.keyboard_input().size() &&
w.keyboard_input().top().key == 'Q');
})) {
})) {
};
return 0;

View file

@ -5,12 +5,14 @@
*
*/
#include <istream>
#include <paradiso/bitmap.hpp>
#include <paradiso/context.hpp>
#include <paradiso/geometry.hpp>
#include <paradiso/renderer.hpp>
#include <paradiso/shader.hpp>
#include <paradiso/sprite.hpp>
#include <paradiso/utils.hpp>
#include <paradiso/window.hpp>
#include <iomanip>
@ -18,6 +20,9 @@
auto main() -> int {
//
std::cout << "running: " << paradiso::get_executable_path() << '\n';
// Ausgabefenster ... sieht aus als wäre es auf dem Stack
auto window = paradiso::Window();
@ -122,4 +127,4 @@ auto main() -> int {
};
return 0;
}
}