blob: 02191bd9a9850078a021b9052d4421aa370d0a4d (
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/**
* @file iceProjectile.c
* @ingroup Projectiles
*
* @brief Ice Projectile
*/
#include "enemy.h"
#include "entity.h"
#include "physics.h"
#include "script.h"
extern void (*const IceProjectile_Actions[])(Entity*);
void IceProjectile(Entity* this) {
if (GetNextFunction(this) != 0) {
DeleteThisEntity();
}
IceProjectile_Actions[this->action](this);
}
void IceProjectile_Init(Entity* this) {
if (this->type == 0) {
this->action = 1;
InitializeAnimation(this, this->direction >> 3);
} else {
this->action = 2;
InitializeAnimation(this, this->direction >> 3 | IdleSouth);
EnqueueSFX(SFX_160);
}
}
void IceProjectile_Action1(Entity* this) {
u32 direction;
Entity* parent;
parent = this->parent;
if (parent == NULL) {
DeleteEntity(this);
} else {
if (parent->next == NULL) {
DeleteEntity(this);
} else {
if (this->spriteSettings.draw == 1) {
CopyPosition(parent, this);
if (this->timer != 0) {
direction = parent->direction & DirectionWest;
this->direction = direction;
this->timer = 0;
InitializeAnimation(this, direction >> 3);
}
}
GetNextFrame(this);
}
}
}
void IceProjectile_Action2(Entity* this) {
GetNextFrame(this);
if (ProcessMovement3(this) != 0) {
if (IsProjectileOffScreen(this)) {
DeleteEntity(this);
} else {
UpdateCollisionLayer(this);
}
} else {
this->action = 3;
COLLISION_OFF(this);
this->speed = 0;
}
}
void IceProjectile_Action3(Entity* this) {
GetNextFrame(this);
if ((this->frame & ANIM_DONE) != 0) {
DeleteEntity(this);
}
}
void (*const IceProjectile_Actions[])(Entity*) = {
IceProjectile_Init,
IceProjectile_Action1,
IceProjectile_Action2,
IceProjectile_Action3,
};
|