summaryrefslogtreecommitdiff
path: root/src/object/thoughtBubble.c
blob: 10b9de5eb3068b5a494b670fd0a1d587026cfbd1 (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
47
48
49
50
51
/**
 * @file thoughtBubble.c
 * @ingroup Objects
 *
 * @brief Thought Bubble object
 */
#include "entity.h"
#include "sound.h"

void ThoughtBubble_Init(Entity*);
void ThoughtBubble_Update(Entity*);

static const u16 ThoughtBubble_SFX[] = {
    SFX_METAL_CLINK,
    SFX_F3,
    SFX_NONE,
    SFX_NONE,
};

void ThoughtBubble(Entity* this) {
    static void (*const ThoughtBubble_Actions[])(Entity*) = {
        ThoughtBubble_Init,
        ThoughtBubble_Update,
    };
    ThoughtBubble_Actions[this->action](this);
}

void ThoughtBubble_Init(Entity* this) {
    this->action = 1;
    this->spriteSettings.draw = 1;
    if (this->timer == 0) {
        this->timer = 45;
    }
    this->spriteOrientation.flipY = 1;
    InitializeAnimation(this, this->type2);
    SoundReq(ThoughtBubble_SFX[this->type2]);
}

void ThoughtBubble_Update(Entity* this) {
    if (this->parent != NULL) {
        this->x.HALF.HI = this->parent->x.HALF.HI;
        this->y.HALF.HI = this->parent->y.HALF.HI;
        this->z.HALF.HI = this->parent->z.HALF.HI;
    }
    if (this->type2 != 2) {
        if (--this->timer == 0) {
            DeleteThisEntity();
        }
    }
    GetNextFrame(this);
}