-
Notifications
You must be signed in to change notification settings - Fork 0
/
kidnapper.c
63 lines (44 loc) · 1.46 KB
/
kidnapper.c
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
#include "kidnapper.h"
#include <tari/animation.h>
#include <tari/file.h>
#include <tari/physicshandler.h>
#include "shadow.h"
static struct {
int physicsID;
int animationID;
int shadowID;
TextureData kidnapperTextures[10];
Animation kidnapperAnimation;
Position* pos;
int isActive;
} gData;
void loadKidnapper() {
gData.kidnapperAnimation = createEmptyAnimation();
gData.kidnapperAnimation.mFrameAmount = 6;
gData.kidnapperAnimation.mDuration = 4;
int i;
for (i = 0; i < (int)gData.kidnapperAnimation.mFrameAmount; i++) {
char path[1024];
getPathWithNumberAffixedFromAssetPath(path, "assets/sprites/KIDNAPPER.pkg", i);
gData.kidnapperTextures[i] = loadTexture(path);
}
gData.physicsID = addToPhysicsHandler(makePosition(450, 350, 5));
gData.pos = &getPhysicsFromHandler(gData.physicsID)->mPosition;
addAccelerationToHandledPhysics(gData.physicsID, makePosition(2, 0, 0));
gData.animationID = playAnimationLoop(makePosition(0,0,0), gData.kidnapperTextures, gData.kidnapperAnimation, makeRectangleFromTexture(gData.kidnapperTextures[0]));
setAnimationBasePositionReference(gData.animationID, gData.pos);
gData.shadowID = addShadow(gData.pos);
gData.isActive = 1;
}
static void removeKidnapper() {
removeShadow(gData.shadowID);
removeHandledAnimation(gData.animationID);
removeFromPhysicsHandler(gData.physicsID);
gData.isActive = 0;
}
void updateKidnapper() {
if (!gData.isActive) return;
if (gData.pos->x > 670) {
removeKidnapper();
}
}