Skip to content

Commit 45bc4d1

Browse files
AllyTallyNyakoFox
authored andcommitted
Completely replace animate system for entities
This removes the magic numbers used for `animate`, and makes the animation system far more flexible, instead giving entities the option to control what they need, instead of having a bunch of duplicated hardly-readable code.
1 parent f8c4e26 commit 45bc4d1

File tree

6 files changed

+180
-234
lines changed

6 files changed

+180
-234
lines changed

desktop_version/src/Ent.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ void entclass::clear(void)
2222
colour = 0;
2323
para = 0;
2424
behave = 0;
25-
animate = 0;
2625

2726
xp = 0;
2827
yp = 0;
@@ -69,6 +68,10 @@ void entclass::clear(void)
6968
SDL_zero(realcol);
7069
lerpoldxp = 0;
7170
lerpoldyp = 0;
71+
72+
animation_frames = 4;
73+
animation_type = EntityAnimationType_OSCILLATE;
74+
animation_speed = 8;
7275
}
7376

7477
bool entclass::outside(void)

desktop_version/src/Ent.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ enum EntityRenderType
5252
EntityRenderType_SPRITE_6x
5353
};
5454

55+
enum EntityAnimationTypes
56+
{
57+
EntityAnimationType_STILL,
58+
EntityAnimationType_OSCILLATE,
59+
EntityAnimationType_LOOP,
60+
EntityAnimationType_ONESHOT,
61+
EntityAnimationType_CONVEYOR_LEFT,
62+
EntityAnimationType_CONVEYOR_RIGHT
63+
};
64+
5565
class entclass
5666
{
5767
public:
@@ -77,7 +87,7 @@ class entclass
7787
EntityRenderType render_type;
7888
int tile, rule;
7989
int state, statedelay;
80-
int behave, animate;
90+
int behave;
8191
float para;
8292
int life, colour;
8393

@@ -98,6 +108,9 @@ class entclass
98108
int onground, onroof;
99109
//Animation
100110
int framedelay, drawframe, walkingframe, dir, actionframe;
111+
int animation_frames;
112+
EntityAnimationTypes animation_type;
113+
int animation_speed;
101114
int collisionframedelay, collisiondrawframe, collisionwalkingframe;
102115
int visualonground, visualonroof;
103116
int yp;int xp;

0 commit comments

Comments
 (0)