-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWailmer.h
88 lines (69 loc) · 1.57 KB
/
Wailmer.h
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
85
86
87
88
#pragma once
#pragma once
#include "Globals.h"
#include "Application.h"
#include "Module.h"
#include "Prop.h"
#include "ModulePhysics.h"
#include "ModuleTextures.h"
#include "ModuleAudio.h"
#include "ModuleScene.h"
class ModulePhysics;
class SDL_Texture;
class Wailmer : public Prop {
public:
Wailmer(PropType type) : Prop(type) {
spitSfx = App->audio->LoadFx("pinball/Sounds/wailmer_spit.wav");
swallowSfx = App->audio->LoadFx("pinball/Sounds/wailmer_swallow.wav");
position = iPoint(180, 195);
pBody = App->physics->CreateRectangleSensor(position.x, position.y, 5, 5);
pBody->listener = (Module*)App->pManager;
pBody->body->SetType(b2BodyType::b2_staticBody);
pBody->body->SetTransform(b2Vec2(PIXEL_TO_METERS(position.x), PIXEL_TO_METERS(position.y)), 0.0f);
pBody->prop = this;
hasSwallowed = false;
}
void PlaySFX() {
if (hasSwallowed) {
App->audio->PlayFx(spitSfx);
}
else {
App->audio->PlayFx(swallowSfx);
}
}
bool Update() {
return true;
}
void OnCollision(PhysBody* bodyB) {
PlaySFX();
hasSwallowed = true;
}
void EndColission(PhysBody* bodyB) {
PlaySFX();
hasSwallowed = false;
}
void EndCollision(PhysBody* otherBody) {
if (otherBody->prop != NULL) {
switch (otherBody->prop->type) {
case PropType::SENSOR_SPRING_IN:
LOG("Ball END collided SPRING");
release = true;
break;
}
}
}
bool CleanUp() {
delete pBody;
pBody = nullptr;
return true;
}
private:
PhysBody* pBody;
// SFX
int spitSfx;
int swallowSfx;
// Spawn position
iPoint position;
// Wailmer flags
bool hasSwallowed, release;
};