diff --git a/src/Cactus.cpp b/src/Cactus.cpp index 2ab0a8f..a164e1e 100644 --- a/src/Cactus.cpp +++ b/src/Cactus.cpp @@ -1,7 +1,7 @@ #include "Cactus.hpp" Cactus::Cactus(Texture2D texture, float x, float y) : texture(texture) { - rect = {static_cast(x), static_cast(300 - texture.height), + rect = {static_cast(x), static_cast(320 - texture.height), static_cast(texture.width), static_cast(texture.height)}; } diff --git a/src/Dino.cpp b/src/Dino.cpp index d9d4eaf..0ea0a78 100644 --- a/src/Dino.cpp +++ b/src/Dino.cpp @@ -1,7 +1,7 @@ #include "Dino.hpp" -Dino::Dino(Texture2D tex) : texture(tex), velocityY(0), isJumping(false) { - rect = {50.0f, static_cast(330 - texture.height), +Dino::Dino(Texture2D texture) : texture(texture), velocityY(0), isJumping(false) { + rect = {50.0f, static_cast(320 - texture.height), static_cast(texture.width), static_cast(texture.height)}; } @@ -16,8 +16,9 @@ void Dino::Update() { velocityY += GRAVITY; rect.y += velocityY; - if (rect.y >= 300 - rect.height) { - rect.y = 300 - rect.height; + if (rect.y >= groundLevel - rect.height) { + rect.y = groundLevel - rect.height; + velocityY = 0; isJumping = false; } } diff --git a/src/Dino.hpp b/src/Dino.hpp index 4a198ab..7c945ae 100644 --- a/src/Dino.hpp +++ b/src/Dino.hpp @@ -17,6 +17,7 @@ private: bool isJumping; static constexpr float GRAVITY = 0.4; static constexpr float JUMP_STRENGTH = -10; + int groundLevel = 320; }; #endif //DINO_HPP \ No newline at end of file