feat: flower growth over time

This commit is contained in:
2025-04-12 20:19:49 +02:00
parent 77f2c38204
commit 79c6a058c7
4 changed files with 32 additions and 2 deletions
+22 -1
View File
@@ -13,6 +13,7 @@ typedef struct {
Sprite sprite;
Vector2 position;
AGE age;
float ageTimer;
} Flower;
Array* CreateFlowers(Texture2D texture, float frameWidth, float rotation, float fieldSize)
@@ -35,13 +36,32 @@ Array* CreateFlowers(Texture2D texture, float frameWidth, float rotation, float
.rotation = rotation,
.color = WHITE,
},
.age = CHILD
.age = CHILD,
.ageTimer = 0.0f
};
AddElementToArray(flowers, flower);
}
return flowers;
}
void UpdateFlower(void* element) {
Flower* f = (Flower*)element;
if (!f) return;
f->ageTimer += 1;
if (f->age == CHILD && f->ageTimer >= 3000.0f) {
f->age = TEEN;
f->sprite.sourceRec.x = f->sprite.sourceRec.width;
}
else if (f->age == TEEN && f->ageTimer >= 6000.0f) {
f->age = ADULT;
f->sprite.sourceRec.x = 2.0f * f->sprite.sourceRec.width;
}
}
void RenderFlower(void* element)
{
Flower* f = (Flower*)element;
@@ -51,4 +71,5 @@ void RenderFlower(void* element)
#endif // FLOWERS_H