-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathModuleGameOver.cpp
More file actions
96 lines (73 loc) · 1.84 KB
/
ModuleGameOver.cpp
File metadata and controls
96 lines (73 loc) · 1.84 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
#include "Globals.h"
#include "Application.h"
#include "ModuleTextures.h"
#include "ModuleAudio.h"
#include "ModuleInput.h"
#include "ModuleRender.h"
#include "ModuleFadeToBlack.h"
#include "ModuleGameOver.h"
#include "ModuleFonts.h"
#include "ModulePlayer.h"
#include <stdio.h>
ModuleGameOver::ModuleGameOver()
{
for (int i = 0; i < 5; i++)
{
highscores[i] = 0;
}
}
ModuleGameOver::~ModuleGameOver()
{}
// Load assets
bool ModuleGameOver::Start()
{
LOG("Loading Game Over Scene");
App->player->checkpoint = 0;
App->player->powerup[0] = 0;
App->player->powerup[1] = 0;
App->player->powerup[2] = 0;
App->player->lifes = 3;
background = App->textures->Load("gunsmoke/start.png");
App->render->camera.x = App->render->camera.y = 0;
font_score = App->fonts->Load("fonts/font.png", "0123456789abcdefghijklmnopqrstuvwxyz", 1);
if (App->player->score > highscores[4])
highscores[4] = App->player->score;
App->player->score = 0;
for (int i = 1; i < 5; i++)
{
for (int i = 1; i < 5; i++)
{
if (highscores[i] > highscores[i - 1])
{
auxiliar = highscores[i];
auxiliar2 = highscores[i - 1];
highscores[i - 1] = auxiliar;
highscores[i] = auxiliar2;
}
}
}
return true;
}
// UnLoad assets
bool ModuleGameOver::CleanUp()
{
LOG("Unloading space scene");
App->fonts->UnLoad(font_score);
App->textures->Unload(background);
return true;
}
// Update: draw background
update_status ModuleGameOver::Update()
{
App->render->Blit(background, 0, 0, NULL);
if ((App->input->keyboard[SDL_SCANCODE_SPACE] == KEY_DOWN || App->input->controller_1.space_button) && App->fade->IsFading() == false)
{
App->fade->FadeToBlack(this, (Module*)App->scene_intro);
}
for (int i = 0; i < 5; i++)
{
sprintf_s(scores, 8, "%7d", highscores[i]);
App->fonts->BlitText(81, 144 + i * 16, font_score, scores);
}
return UPDATE_CONTINUE;
}