summaryrefslogtreecommitdiff
path: root/src/object/minishLight.c
blob: 382056eefb97e682d5124870a3589fdc348f84a7 (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
43
44
45
46
/**
 * @file minishLight.c
 * @ingroup Objects
 *
 * @brief Minish Light object
 */
#include "entity.h"

void MinishLight_Init(Entity*);
void MinishLight_Action1(Entity*);

void MinishLight(Entity* this) {
    static void (*const MinishLight_Actions[])(Entity*) = {
        MinishLight_Init,
        MinishLight_Action1,
    };
    MinishLight_Actions[this->action](this);
}

void MinishLight_Init(Entity* this) {
    this->action = 1;
    this->frameIndex = 0;
    this->timer = 32;
    this->subtimer = 0;

    if (this->type2 != 0) {
        this->spriteSettings.flipX = 1;
    }

    UpdateSpriteForCollisionLayer(this);
}

void MinishLight_Action1(Entity* this) {
    if (--this->timer == 0) {
        if (this->subtimer == 0) {
            if (++this->frameIndex == 3) {
                this->subtimer = 1;
            }
        } else {
            if (--this->frameIndex == 0) {
                this->subtimer = 0;
            }
        }
        this->timer = 32;
    }
}