aboutsummaryrefslogtreecommitdiff
path: root/src/effect.c
blob: 030f2235d7966cdb69b694000699885d44b924a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdint.h>

#include "vga.h"
#include "entities.h"

#include "effect.h"

#define MAX_FRAME 3

static const Rect frames[2 * 4] =
{
    { 96, 16, 144, 144 },
    { 112, 16, 144, 144 },
    { 128, 16, 144, 144 },

    /* not used */
    { 0, 0, 144, 144 },
    { 0, 0, 144, 144 },
    { 0, 0, 144, 144 },
    { 0, 0, 144, 144 },
    { 0, 0, 144, 144 }
};

void effect_out_init(Entity *e)
{
    e->frames = (const Rect *)frames;
    e->frame = 1;
    e->delay = 0;
    e->update = effect_out_update;
}

void effect_out_update(Entity *e)
{
    if (e->delay++ == WALK_DELAY - 2)
    {
        e->delay = 0;
        e->frame++;
        if (e->frame == MAX_FRAME)
            e->used = 0;
    }
}