forked from Hartmut/paradiso
fixed quickwings, added me to readme, fixed readme
This commit is contained in:
parent
b9c7ce3b48
commit
2a42731628
8 changed files with 94 additions and 66 deletions
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* paradiso - Paradigmen der Softwareentwicklung
|
||||
*
|
||||
* (c) Copyright 2023 Hartmut Seichter, Robin Rottstädt
|
||||
* (c) Copyright 2023 Hartmut Seichter, Robin Rottstädt, brxxh (Hannes Brothuhn)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -38,22 +38,22 @@ struct Background {
|
|||
paradiso::BitmapIO::get().load("background-day.png");
|
||||
backgroundLeft = paradiso::Sprite{
|
||||
.bitmap = backgroundImage,
|
||||
.pivot = paradiso::Vector2<float>::make(0.0f, 0.0f),
|
||||
.scale = paradiso::Vector2<float>::make(1.01f, 1.0f)};
|
||||
.pivot = {paradiso::Vector2<float>::make(0.0f, 0.16f)},
|
||||
.scale = {paradiso::Vector2<float>::make(1.01f, 1.3f)}};
|
||||
backgroundRight = paradiso::Sprite{
|
||||
.bitmap = backgroundImage,
|
||||
.pivot = paradiso::Vector2<float>::make(2.0f, 0.0f),
|
||||
.scale = paradiso::Vector2<float>::make(1.01f, 1.0f)};
|
||||
.pivot = {paradiso::Vector2<float>::make(2.018f, 0.16f)},
|
||||
.scale = {paradiso::Vector2<float>::make(1.01f, 1.3f)}};
|
||||
|
||||
auto grassImage = paradiso::BitmapIO::get().load("base.png");
|
||||
grassLeft = paradiso::Sprite{
|
||||
.bitmap = grassImage,
|
||||
.pivot = paradiso::Vector2<float>::make(0.0f, -1.0f),
|
||||
.scale = paradiso::Vector2<float>::make(1.0f, 0.33333f)};
|
||||
.pivot = {paradiso::Vector2<float>::make(0.0f, -1.0f)},
|
||||
.scale = {paradiso::Vector2<float>::make(1.0f, 0.33333f)}};
|
||||
grassRight = paradiso::Sprite{
|
||||
.bitmap = grassImage,
|
||||
.pivot = paradiso::Vector2<float>::make(2.0f, -1.0f),
|
||||
.scale = paradiso::Vector2<float>::make(1.0f, 0.33333f)};
|
||||
.pivot = {paradiso::Vector2<float>::make(2.0f, -1.0f)},
|
||||
.scale = {paradiso::Vector2<float>::make(1.0f, 0.33333f)}};
|
||||
}
|
||||
|
||||
void draw(const paradiso::Shader& shader) {
|
||||
|
@ -61,7 +61,7 @@ struct Background {
|
|||
if (sprite->pivot.x() <= -2.0f) {
|
||||
sprite->pivot.x() += 4.0f;
|
||||
}
|
||||
sprite->pivot.x() -= 0.001f;
|
||||
sprite->pivot.x() -= 0.002f;
|
||||
shader.set_uniform("pivot", sprite->pivot);
|
||||
shader.set_uniform("scale", sprite->scale);
|
||||
shader.set_uniform("rotation", sprite->rotation);
|
||||
|
@ -79,23 +79,23 @@ struct Grass {
|
|||
paradiso::Sprite* scrolling[2] = {&grassLeft, &grassRight};
|
||||
|
||||
Grass() {
|
||||
auto grassImage = paradiso::BitmapIO::get().load(std::string("base.png"));
|
||||
auto grassImage = paradiso::BitmapIO::get().load("base.png");
|
||||
grassLeft = paradiso::Sprite{
|
||||
.bitmap = grassImage,
|
||||
.pivot = paradiso::Vector2<float>::make(0.0f, -0.9f),
|
||||
.scale = paradiso::Vector2<float>::make(1.0f, 0.33333f)};
|
||||
.pivot = {paradiso::Vector2<float>::make(1.0f, -0.9f)},
|
||||
.scale = {paradiso::Vector2<float>::make(2.0f, 0.33333f)}};
|
||||
grassRight = paradiso::Sprite{
|
||||
.bitmap = grassImage,
|
||||
.pivot = paradiso::Vector2<float>::make(2.0f, -0.9f),
|
||||
.scale = paradiso::Vector2<float>::make(1.0f, 0.33333f)};
|
||||
.pivot = {paradiso::Vector2<float>::make(1.0f, -0.9f)},
|
||||
.scale = {paradiso::Vector2<float>::make(2.6f, 0.33333f)}};
|
||||
}
|
||||
|
||||
void draw(const paradiso::Shader& shader) {
|
||||
for (auto sprite : scrolling) {
|
||||
if (sprite->pivot.x() <= -2.0f) {
|
||||
sprite->pivot.x() += 4.0f;
|
||||
if (sprite->pivot.x() <= -1.0f) {
|
||||
sprite->pivot.x() += 2.0f;
|
||||
}
|
||||
sprite->pivot.x() -= 0.035f;
|
||||
sprite->pivot.x() -= 0.03f;
|
||||
shader.set_uniform("pivot", sprite->pivot);
|
||||
shader.set_uniform("scale", sprite->scale);
|
||||
shader.set_uniform("rotation", sprite->rotation);
|
||||
|
@ -106,6 +106,7 @@ struct Grass {
|
|||
paradiso::Renderer renderer{};
|
||||
};
|
||||
|
||||
|
||||
struct QuickWings {
|
||||
|
||||
paradiso::Renderer renderer1{};
|
||||
|
@ -118,10 +119,10 @@ struct QuickWings {
|
|||
unsigned int flapCounter = 0; // How many ticks since last flap
|
||||
|
||||
float velocity = 0.0f;
|
||||
const float max_velocity = 0.05f;
|
||||
const float max_velocity = 0.04f;
|
||||
|
||||
const float gravity = -0.004f;
|
||||
const float move_up_velocity = 0.0055f;
|
||||
const float move_up_velocity = 0.04f;
|
||||
|
||||
bool move_up = false;
|
||||
bool paused = true;
|
||||
|
@ -129,30 +130,30 @@ struct QuickWings {
|
|||
const float max_pos = 0.95f;
|
||||
const float min_pos = -0.5f;
|
||||
|
||||
float pos = 0.0f;
|
||||
float pos = 0.34f;
|
||||
|
||||
float rotation = 0.0f;
|
||||
|
||||
QuickWings() {
|
||||
float scaleh = 0.07f;
|
||||
float scalew = scaleh * 1.416666666666667f;
|
||||
float scaleh = 0.08f;
|
||||
float scalew = 0.158f;
|
||||
|
||||
birds = {
|
||||
paradiso::Sprite{
|
||||
.bitmap =
|
||||
paradiso::BitmapIO::get().load("yellowbird-downflap.png"),
|
||||
.pivot = paradiso::Vector2<float>::make(0.0f, 0.0f),
|
||||
.scale = paradiso::Vector2<float>::make(scalew, scaleh)},
|
||||
.pivot = {paradiso::Vector2<float>::make(0.0f, 0.0f)},
|
||||
.scale = {paradiso::Vector2<float>::make(scalew, scaleh)}},
|
||||
paradiso::Sprite{
|
||||
.bitmap =
|
||||
paradiso::BitmapIO::get().load("yellowbird-midflap.png"),
|
||||
.pivot = paradiso::Vector2<float>::make(0.0f, 0.0f),
|
||||
.scale = paradiso::Vector2<float>::make(scalew, scaleh)},
|
||||
.pivot = {paradiso::Vector2<float>::make(0.0f, 0.0f)},
|
||||
.scale = {paradiso::Vector2<float>::make(scalew, scaleh)}},
|
||||
paradiso::Sprite{
|
||||
.bitmap =
|
||||
paradiso::BitmapIO::get().load("yellowbird-upflap.png"),
|
||||
.pivot = paradiso::Vector2<float>::make(0.0f, 0.0f),
|
||||
.scale = paradiso::Vector2<float>::make(scalew, scaleh)}};
|
||||
.pivot = {paradiso::Vector2<float>::make(0.0f, 0.0f)},
|
||||
.scale = {paradiso::Vector2<float>::make(scalew, scaleh)}}};
|
||||
}
|
||||
|
||||
void draw(const paradiso::Shader& shader) {
|
||||
|
@ -185,6 +186,7 @@ struct QuickWings {
|
|||
}
|
||||
|
||||
void update() {
|
||||
|
||||
// Stop game
|
||||
if (paused)
|
||||
return;
|
||||
|
@ -213,7 +215,7 @@ struct QuickWings {
|
|||
}
|
||||
|
||||
// Update rotation
|
||||
rotation = velocity * 15.0f;
|
||||
rotation = velocity * 10.0f;
|
||||
}
|
||||
|
||||
// keyboard handler
|
||||
|
@ -231,6 +233,30 @@ struct QuickWings {
|
|||
}
|
||||
};
|
||||
|
||||
/*
|
||||
TODO: finish this
|
||||
|
||||
struct Message {
|
||||
paradiso::Sprite messageSprite;
|
||||
paradiso::Renderer renderer{};
|
||||
|
||||
Message() {
|
||||
auto messageImage = paradiso::BitmapIO::get().load("message.png");
|
||||
messageSprite = paradiso::Sprite{
|
||||
.bitmap = messageImage,
|
||||
.pivot = {paradiso::Vector2<float>::make(0.0f, 0.0f)},
|
||||
.scale = {paradiso::Vector2<float>::make(0.8f, 0.8f)}
|
||||
};
|
||||
};
|
||||
|
||||
void draw(const paradiso::Shader& shader) {
|
||||
shader.set_uniform("pivot", messageSprite.pivot);
|
||||
shader.set_uniform("scale", messageSprite.scale);
|
||||
renderer.draw(messageSprite, shader);
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
auto main() -> int {
|
||||
|
||||
// Ausgabefenster ... sieht aus als wäre es auf dem Stack
|
||||
|
@ -274,9 +300,9 @@ auto main() -> int {
|
|||
paradiso::BitmapIO::get().set_path("assets");
|
||||
|
||||
// Load
|
||||
//* auto message = Message{};
|
||||
auto background = Background{};
|
||||
auto grass = Grass{};
|
||||
|
||||
auto quickwingsapp = QuickWings{};
|
||||
|
||||
// timer
|
||||
|
@ -298,6 +324,7 @@ auto main() -> int {
|
|||
// Draw
|
||||
background.draw(shader);
|
||||
grass.draw(shader);
|
||||
//* message.draw(shader);
|
||||
quickwingsapp.draw(shader);
|
||||
|
||||
// wait for frame rate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue