new anim state in animation struct
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
#ifndef ANIMATION_H
|
#ifndef ANIMATION_H
|
||||||
#define ANIMATION_H
|
#define ANIMATION_H
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
int state;
|
||||||
int currentFrame;
|
int currentFrame;
|
||||||
int maxFrame;
|
int maxFrame;
|
||||||
int framesCounter;
|
int framesCounter;
|
||||||
|
|||||||
+6
-2
@@ -5,6 +5,9 @@
|
|||||||
#include "../engine/physics.h"
|
#include "../engine/physics.h"
|
||||||
#include "../engine/object.h"
|
#include "../engine/object.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
FLYING
|
||||||
|
} BeeAnimationState;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Sprite sprite;
|
Sprite sprite;
|
||||||
@@ -15,7 +18,7 @@ typedef struct {
|
|||||||
int flowerCount;
|
int flowerCount;
|
||||||
} Bee;
|
} Bee;
|
||||||
|
|
||||||
Bee CreateBee(Texture2D texture, float frameWidth, int maxFrame, int framesSpeed, Vector2 position, float speed, ObjectArray* target, Object* base){
|
Bee CreateBee(BeeAnimationState animState, Texture2D texture, float frameWidth, int maxFrame, int framesSpeed, Vector2 position, float speed, ObjectArray* target, Object* base){
|
||||||
return (Bee){
|
return (Bee){
|
||||||
.sprite = {
|
.sprite = {
|
||||||
.texture = texture,
|
.texture = texture,
|
||||||
@@ -27,6 +30,7 @@ Bee CreateBee(Texture2D texture, float frameWidth, int maxFrame, int framesSpeed
|
|||||||
.color = WHITE
|
.color = WHITE
|
||||||
},
|
},
|
||||||
.animation = {
|
.animation = {
|
||||||
|
.state = animState,
|
||||||
.currentFrame = 0,
|
.currentFrame = 0,
|
||||||
.maxFrame = maxFrame,
|
.maxFrame = maxFrame,
|
||||||
.framesCounter = 0,
|
.framesCounter = 0,
|
||||||
@@ -66,7 +70,7 @@ void UpdateBee(Bee* bee, ObjectArray* flowers, Object* hive){
|
|||||||
UpdateSpriteRotation(&bee->sprite, &bee->physics.direction);
|
UpdateSpriteRotation(&bee->sprite, &bee->physics.direction);
|
||||||
UpdateSpriteDestRec(&bee->sprite, &bee->physics.position);
|
UpdateSpriteDestRec(&bee->sprite, &bee->physics.position);
|
||||||
UpdateAnimation(&bee->animation, GetFrameTime());
|
UpdateAnimation(&bee->animation, GetFrameTime());
|
||||||
UpdateSpriteSourceRec(&bee->sprite, &(Vector2){bee->sprite.frameSize.x, bee->sprite.frameSize.x * bee->animation.currentFrame});
|
UpdateSpriteSourceRec(&bee->sprite, &(Vector2){bee->sprite.frameSize.x * bee->animation.state, bee->sprite.frameSize.x * bee->animation.currentFrame});
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // BEE_H
|
#endif // BEE_H
|
||||||
|
|||||||
Reference in New Issue
Block a user