summaryrefslogtreecommitdiff
path: root/src/projectile/mazaalEnergyBeam.c
blob: 843a03961f3fbc73dfd2725df4ab016477195060 (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
52
53
54
55
56
57
58
/**
 * @file mazaalEnergyBeam.c
 * @ingroup Projectiles
 *
 * @brief Mazaal Energy Beam Projectile
 */
#include "entity.h"
#include "physics.h"
#include "sound.h"

extern void (*const MazaalEnergyBeam_Actions[])(Entity*);

void MazaalEnergyBeam(Entity* this) {
    MazaalEnergyBeam_Actions[this->action](this);
}

void MazaalEnergyBeam_Init(Entity* this) {
    this->action = 1;
    this->timer = 10;
    this->z.HALF.HI -= 2;
    this->y.HALF.HI += 2;
    InitializeAnimation(this, 0);
    SoundReq(SFX_149);
}

void MazaalEnergyBeam_Action1(Entity* this) {
    const s16* tmp;

    if (--this->timer == 0) {
        this->action = 2;
        COLLISION_OFF(this);
        this->spritePriority.b0 = 7;
        this->y.HALF.HI += 6;
        InitializeAnimation(this, 1);
    } else {
        if (this->z.HALF.HI != 0) {
            this->z.HALF.HI++;
        }

        tmp = &gSineTable[this->direction];
        this->x.WORD += tmp[0] * this->speed;
        this->y.WORD -= tmp[0x40] * this->speed;
        GetNextFrame(this);
    }
}

void MazaalEnergyBeam_Action2(Entity* this) {
    GetNextFrame(this);
    if ((this->frame & ANIM_DONE) != 0) {
        DeleteEntity(this);
    }
}

void (*const MazaalEnergyBeam_Actions[])(Entity*) = {
    MazaalEnergyBeam_Init,
    MazaalEnergyBeam_Action1,
    MazaalEnergyBeam_Action2,
};