aboutsummaryrefslogtreecommitdiff
path: root/src/effect.c
blob: e30805411f1734eff8afca3afc3bdc3a6edb975a (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
42
#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->dir = DIR_RIGHT;
    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;
    }
}