feat: flower growth over time
This commit is contained in:
+22
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user