Skip to content

Commit

Permalink
Completely replace animate system for entities
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AllyTally committed Sep 4, 2023
1 parent bbe65e7 commit 0240a46
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 245 deletions.
5 changes: 4 additions & 1 deletion desktop_version/src/Ent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ void entclass::clear(void)
colour = 0;
para = 0;
behave = 0;
animate = 0;

xp = 0;
yp = 0;
Expand Down Expand Up @@ -69,6 +68,10 @@ void entclass::clear(void)
SDL_zero(realcol);
lerpoldxp = 0;
lerpoldyp = 0;

animation_frames = 4;
animation_type = EntityAnimationType_OSCILLATE;
animation_speed = 8;
}

bool entclass::outside(void)
Expand Down
15 changes: 14 additions & 1 deletion desktop_version/src/Ent.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ enum EntityRenderTypes
EntityRenderType_SPRITE_6x
};

enum EntityAnimationTypes
{
EntityAnimationType_STILL,
EntityAnimationType_OSCILLATE,
EntityAnimationType_LOOP,
EntityAnimationType_ONESHOT,
EntityAnimationType_CONVEYOR_LEFT,
EntityAnimationType_CONVEYOR_RIGHT
};

class entclass
{
public:
Expand All @@ -77,7 +87,7 @@ class entclass
EntityRenderTypes render_type;
int tile, rule;
int state, statedelay;
int behave, animate;
int behave;
float para;
int life, colour;

Expand All @@ -98,6 +108,9 @@ class entclass
int onground, onroof;
//Animation
int framedelay, drawframe, walkingframe, dir, actionframe;
int animation_frames;
EntityAnimationTypes animation_type;
int animation_speed;
int collisionframedelay, collisiondrawframe, collisionwalkingframe;
int visualonground, visualonroof;
int yp;int xp;
Expand Down
Loading

0 comments on commit 0240a46

Please sign in to comment.