mirror of
https://github.com/theoleuthardt/DinoGame.git
synced 2026-06-13 09:27:57 +00:00
feat: save mechanic and cactus/dino spawn logic
This commit is contained in:
parent
d5060f7552
commit
c7554cbb81
5 changed files with 63 additions and 6 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#include "Cactus.hpp"
|
||||
|
||||
Cactus::Cactus(Texture2D texture, float x) : texture(texture) {
|
||||
Cactus::Cactus(Texture2D texture, float x, float y) : texture(texture) {
|
||||
rect = {static_cast<float>(x), static_cast<float>(300 - texture.height),
|
||||
static_cast<float>(texture.width), static_cast<float>(texture.height)};
|
||||
}
|
||||
|
|
@ -18,5 +18,11 @@ bool Cactus::IsOffScreen() {
|
|||
}
|
||||
|
||||
Rectangle Cactus::GetRect() {
|
||||
return rect;
|
||||
float hitboxWidth = texture.width * 0.8f;
|
||||
float hitboxHeight = texture.height * 0.7f;
|
||||
|
||||
float hitboxX = rect.x + (texture.width - hitboxWidth) / 2;
|
||||
float hitboxY = rect.y + (texture.height - hitboxHeight);
|
||||
|
||||
return {hitboxX, hitboxY, hitboxWidth, hitboxHeight};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue