Compare commits
No commits in common. "937f63b0ca13f01b48704f3b78e10a45129d37a6" and "9c2e21f4d20e6c583ef894c49973f8b2a95be682" have entirely different histories.
937f63b0ca
...
9c2e21f4d2
|
@ -132,7 +132,6 @@ typedef struct _CSprite_t {
|
|||
unsigned int current_idx;
|
||||
bool flip_x;
|
||||
bool flip_y;
|
||||
bool pause;
|
||||
} CSprite_t;
|
||||
|
||||
static inline void set_bbox(CBBox_t* p_bbox, unsigned int x, unsigned int y)
|
||||
|
|
|
@ -1076,7 +1076,6 @@ void sprite_animation_system(Scene_t* scene)
|
|||
p_cspr->sprites[spr_idx].sprite->current_frame = 0;
|
||||
}
|
||||
}
|
||||
if (p_cspr->pause) return;
|
||||
SpriteRenderInfo_t spr = p_cspr->sprites[p_cspr->current_idx];
|
||||
// Animate it (handle frame count)
|
||||
spr.sprite->elapsed++;
|
||||
|
|
|
@ -4,16 +4,13 @@
|
|||
#include <string.h>
|
||||
#include "raymath.h"
|
||||
|
||||
#define N_PLAYER_SPRITES 7
|
||||
#define N_PLAYER_SPRITES 4
|
||||
enum PlayerSpriteEnum
|
||||
{
|
||||
SPR_PLAYER_STAND = 0,
|
||||
SPR_PLAYER_RUN,
|
||||
SPR_PLAYER_JUMP,
|
||||
SPR_PLAYER_FALL,
|
||||
SPR_PLAYER_LADDER,
|
||||
SPR_PLAYER_CROUCH,
|
||||
SPR_PLAYER_SWIM,
|
||||
};
|
||||
|
||||
static SpriteRenderInfo_t player_sprite_map[N_PLAYER_SPRITES] = {0};
|
||||
|
@ -23,35 +20,16 @@ static unsigned int player_sprite_transition_func(Entity_t* ent)
|
|||
CTransform_t* p_ctrans = get_component(ent, CTRANSFORM_COMP_T);
|
||||
CMovementState_t* p_move = get_component(ent, CMOVEMENTSTATE_T);
|
||||
CSprite_t* p_spr = get_component(ent, CSPRITE_T);
|
||||
CPlayerState_t* p_plr = get_component(ent, CPLAYERSTATE_T);
|
||||
if (p_ctrans->velocity.x > 0) p_spr->flip_x = true;
|
||||
else if (p_ctrans->velocity.x < 0) p_spr->flip_x = false;
|
||||
|
||||
p_spr->pause = false;
|
||||
|
||||
if (p_move->ground_state & 1)
|
||||
{
|
||||
if (p_plr->is_crouch)
|
||||
if (Vector2LengthSqr(p_ctrans->velocity) > 1000.0f)
|
||||
{
|
||||
return SPR_PLAYER_CROUCH;
|
||||
return SPR_PLAYER_RUN;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Vector2LengthSqr(p_ctrans->velocity) > 1000.0f)
|
||||
{
|
||||
return SPR_PLAYER_RUN;
|
||||
}
|
||||
return SPR_PLAYER_STAND;
|
||||
}
|
||||
}
|
||||
else if (p_plr->ladder_state)
|
||||
{
|
||||
p_spr->pause = Vector2LengthSqr(p_ctrans->velocity) < 10.0f;
|
||||
return SPR_PLAYER_LADDER;
|
||||
}
|
||||
else if (p_move->water_state & 1)
|
||||
{
|
||||
return SPR_PLAYER_SWIM;
|
||||
return SPR_PLAYER_STAND;
|
||||
}
|
||||
return (p_ctrans->velocity.y < 0) ? SPR_PLAYER_JUMP : SPR_PLAYER_FALL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue