Compare commits
2 Commits
937f63b0ca
...
332fe33e8e
Author | SHA1 | Date |
---|---|---|
|
332fe33e8e | |
|
542c7cf57c |
|
@ -24,7 +24,7 @@
|
|||
#define PLAYER_WIDTH 30
|
||||
#define PLAYER_HEIGHT 42
|
||||
#define PLAYER_C_WIDTH 30
|
||||
#define PLAYER_C_HEIGHT 30
|
||||
#define PLAYER_C_HEIGHT 26
|
||||
#else
|
||||
#define PLAYER_WIDTH 14
|
||||
#define PLAYER_HEIGHT 30
|
||||
|
|
|
@ -1067,17 +1067,21 @@ void sprite_animation_system(Scene_t* scene)
|
|||
{
|
||||
Entity_t* p_ent = get_entity(&scene->ent_manager, ent_idx);
|
||||
// Update animation state
|
||||
unsigned int next_idx = p_cspr->current_idx;
|
||||
if (p_cspr->transition_func != NULL)
|
||||
{
|
||||
unsigned int spr_idx = p_cspr->transition_func(p_ent);
|
||||
if (p_cspr->current_idx != spr_idx)
|
||||
{
|
||||
p_cspr->current_idx = spr_idx;
|
||||
p_cspr->sprites[spr_idx].sprite->current_frame = 0;
|
||||
}
|
||||
next_idx = p_cspr->transition_func(p_ent);
|
||||
}
|
||||
if (p_cspr->pause) return;
|
||||
|
||||
bool reset = p_cspr->current_idx != next_idx;
|
||||
p_cspr->current_idx = next_idx;
|
||||
|
||||
SpriteRenderInfo_t spr = p_cspr->sprites[p_cspr->current_idx];
|
||||
if (spr.sprite == NULL) continue;
|
||||
|
||||
if (reset) spr.sprite->current_frame = 0;
|
||||
|
||||
// Animate it (handle frame count)
|
||||
spr.sprite->elapsed++;
|
||||
if (spr.sprite->elapsed == spr.sprite->speed)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <string.h>
|
||||
#include "raymath.h"
|
||||
|
||||
#define N_PLAYER_SPRITES 7
|
||||
#define N_PLAYER_SPRITES 8
|
||||
enum PlayerSpriteEnum
|
||||
{
|
||||
SPR_PLAYER_STAND = 0,
|
||||
|
@ -13,6 +13,7 @@ enum PlayerSpriteEnum
|
|||
SPR_PLAYER_FALL,
|
||||
SPR_PLAYER_LADDER,
|
||||
SPR_PLAYER_CROUCH,
|
||||
SPR_PLAYER_CRMOVE,
|
||||
SPR_PLAYER_SWIM,
|
||||
};
|
||||
|
||||
|
@ -31,17 +32,13 @@ static unsigned int player_sprite_transition_func(Entity_t* ent)
|
|||
|
||||
if (p_move->ground_state & 1)
|
||||
{
|
||||
if (p_plr->is_crouch)
|
||||
if (Vector2LengthSqr(p_ctrans->velocity) > 1000.0f)
|
||||
{
|
||||
return SPR_PLAYER_CROUCH;
|
||||
return (p_plr->is_crouch) ? SPR_PLAYER_CRMOVE : SPR_PLAYER_RUN;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Vector2LengthSqr(p_ctrans->velocity) > 1000.0f)
|
||||
{
|
||||
return SPR_PLAYER_RUN;
|
||||
}
|
||||
return SPR_PLAYER_STAND;
|
||||
return (p_plr->is_crouch) ? SPR_PLAYER_CROUCH : SPR_PLAYER_STAND;
|
||||
}
|
||||
}
|
||||
else if (p_plr->ladder_state)
|
||||
|
|
Loading…
Reference in New Issue