mirror of
https://github.com/theoleuthardt/DinoGame.git
synced 2026-06-13 01:17:56 +00:00
fix: y position of dino and cacti now on the desert
This commit is contained in:
parent
c7554cbb81
commit
8dd09555f2
3 changed files with 7 additions and 5 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#include "Cactus.hpp"
|
||||
|
||||
Cactus::Cactus(Texture2D texture, float x, float y) : texture(texture) {
|
||||
rect = {static_cast<float>(x), static_cast<float>(300 - texture.height),
|
||||
rect = {static_cast<float>(x), static_cast<float>(320 - texture.height),
|
||||
static_cast<float>(texture.width), static_cast<float>(texture.height)};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "Dino.hpp"
|
||||
|
||||
Dino::Dino(Texture2D tex) : texture(tex), velocityY(0), isJumping(false) {
|
||||
rect = {50.0f, static_cast<float>(330 - texture.height),
|
||||
Dino::Dino(Texture2D texture) : texture(texture), velocityY(0), isJumping(false) {
|
||||
rect = {50.0f, static_cast<float>(320 - texture.height),
|
||||
static_cast<float>(texture.width), static_cast<float>(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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue