- Actor: Velocitat de animació configurable

This commit is contained in:
2023-09-20 14:36:39 +02:00
parent 5cea9960a2
commit b10b76d59d
2 changed files with 14 additions and 9 deletions

View File

@@ -9,7 +9,6 @@ namespace actor
{0, 1, 0, 2},
{0, 1, 2, 3}
};
static uint8_t anim_frame=0;
actor_t *first = nullptr;
actor_t *dirty = nullptr;
@@ -32,6 +31,8 @@ namespace actor
act->push = act->mov_push = PUSH_NONE;
act->below = act->above = nullptr;
act->prev = act->next = nullptr;
act->anim_wait = act->anim_wait_count = 0;
act->anim_frame=0;
return act;
}
@@ -111,15 +112,9 @@ namespace actor
else if (act2->pos.z >= act1->pos.z+act1->size.z) { return false; }
else { return false; }
}
int peiv = 0;
void reorder()
{
// [TODO] QUE LA VELOCITAT DE ANIMACIÓ SIGA CONFIGURABLE
//if (peiv==2) {
anim_frame=(anim_frame+1)%4;
// peiv=0;
//} peiv++;
while (dirty)
{
if (first)
@@ -535,6 +530,13 @@ int peiv = 0;
{
actor_t *next = act->next;
if (act->anim_wait_count==act->anim_wait) {
act->anim_frame=(act->anim_frame+1)%4;
act->anim_wait_count=0;
} else {
act->anim_wait++;
}
if (act->flags & FLAG_HERO) updateUserInput(act);
if (act->flags & FLAG_MOVING) updateMoving(act);
//if (act->flags & FLAG_PUSHABLE)
@@ -579,7 +581,7 @@ int peiv = 0;
const bool flip = ( (act->flags & FLAG_ORIENTABLE) && (act->orient==PUSH_XN || act->orient==PUSH_YP) ) ? DRAW_FLIP_HORIZONTAL : DRAW_FLIP_NONE;
const int oo = ( (act->flags & FLAG_ORIENTABLE) && (act->orient==PUSH_XN || act->orient==PUSH_YN) ) ? act->bmp_rect.h : 0;
const int ao = (act->flags & FLAG_ANIMATED) ? anims[act->anim_cycle][anim_frame]*act->bmp_rect.w : 0;
const int ao = (act->flags & FLAG_ANIMATED) ? anims[act->anim_cycle][act->anim_frame]*act->bmp_rect.w : 0;
draw::pushSource();
draw::setSource(act->surface);

View File

@@ -44,6 +44,9 @@ namespace actor
uint8_t orient;
uint8_t anim_cycle;
uint8_t anim_frame;
uint8_t anim_wait;
uint8_t anim_wait_count;
uint8_t flags;
uint8_t push;