feat: save mechanic and cactus/dino spawn logic

This commit is contained in:
theoleuthardt 2025-03-13 13:23:10 +01:00
parent d5060f7552
commit c7554cbb81
5 changed files with 63 additions and 6 deletions

View file

@ -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};
}