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