-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleSceneIntro.cpp
More file actions
133 lines (112 loc) · 2.65 KB
/
ModuleSceneIntro.cpp
File metadata and controls
133 lines (112 loc) · 2.65 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include "Globals.h"
#include "Application.h"
#include "ModuleRender.h"
#include "ModuleSceneIntro.h"
#include "ModuleInput.h"
#include "ModuleTextures.h"
#include "ModuleAudio.h"
#include "ModulePhysics.h"
ModuleSceneIntro::ModuleSceneIntro(Application* app, bool start_enabled) : Module(app, start_enabled)
{
circle = box = rick = NULL;
}
ModuleSceneIntro::~ModuleSceneIntro()
{}
// Load assets
bool ModuleSceneIntro::Start()
{
LOG("Loading Intro assets");
bool ret = true;
App->renderer->camera.x = App->renderer->camera.y = 0;
circle = App->textures->Load("pinball/wheel.png");
box = App->textures->Load("pinball/crate.png");
rick = App->textures->Load("pinball/rick_head.png");
// bonus_fx = App->audio->LoadFx("pinball/bonus.wav");
// TODO: Homework - create a sensor
return ret;
}
// Load assets
bool ModuleSceneIntro::CleanUp()
{
LOG("Unloading Intro scene");
return true;
}
// Update: draw background
update_status ModuleSceneIntro::Update()
{
if(App->input->GetKey(SDL_SCANCODE_1) == KEY_DOWN)
{
circles.add(App->physics->CreateCircle(App->input->GetMouseX(), App->input->GetMouseY(), 25));
// TODO 8: Make sure to add yourself as collision callback to the circle you creates
}
if(App->input->GetKey(SDL_SCANCODE_2) == KEY_DOWN)
{
boxes.add(App->physics->CreateRectangle(App->input->GetMouseX(), App->input->GetMouseY(), 100, 50));
}
if(App->input->GetKey(SDL_SCANCODE_3) == KEY_DOWN)
{
// Pivot 0, 0
int rick_head[64] = {
14, 36,
42, 40,
40, 0,
75, 30,
88, 4,
94, 39,
111, 36,
104, 58,
107, 62,
117, 67,
109, 73,
110, 85,
106, 91,
109, 99,
103, 104,
100, 115,
106, 121,
103, 125,
98, 126,
95, 137,
83, 147,
67, 147,
53, 140,
46, 132,
34, 136,
38, 126,
23, 123,
30, 114,
10, 102,
29, 90,
0, 75,
30, 62
};
ricks.add(App->physics->CreateChain(App->input->GetMouseX(), App->input->GetMouseY(), rick_head, 64));
}
// All draw functions ------------------------------------------------------
p2List_item<PhysBody*>* c = circles.getFirst();
while (c != NULL)
{
int x, y;
c->data->GetPosition(x, y);
App->renderer->Blit(circle, x, y, NULL, 1.0f, c->data->GetRotation());
c = c->next;
}
c = boxes.getFirst();
while(c != NULL)
{
int x, y;
c->data->GetPosition(x, y);
App->renderer->Blit(box, x, y, NULL, 1.0f, c->data->GetRotation());
c = c->next;
}
c = ricks.getFirst();
while(c != NULL)
{
int x, y;
c->data->GetPosition(x, y);
App->renderer->Blit(rick, x, y, NULL, 1.0f, c->data->GetRotation());
c = c->next;
}
return UPDATE_CONTINUE;
}
// TODO 8: Now just define collision callback for the circle and play bonus_fx audio