forked from knela96/XMultiply-Arcade-Game
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleSceneChoosePlayer.cpp
More file actions
73 lines (64 loc) · 1.77 KB
/
ModuleSceneChoosePlayer.cpp
File metadata and controls
73 lines (64 loc) · 1.77 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
#include "Globals.h"
#include "Application.h"
#include "ModuleTextures.h"
#include "ModuleRender.h"
#include "ModuleInput.h"
#include "ModuleFadeToBlack.h"
#include "ModuleSceneChoosePlayer.h"
#include "ModuleSceneStage1.h"
#include "ModuleSceneStage4.h"
#include "ModuleSceneCongrats.h"
#include "ModuleSceneScore.h"
#include "SDL/include/SDL_timer.h"
ModuleSceneChoosePlayer::ModuleSceneChoosePlayer()
{
// Background / sky
background = {0, 0, 384, 256};
}
ModuleSceneChoosePlayer::~ModuleSceneChoosePlayer()
{}
// Load assets
bool ModuleSceneChoosePlayer::Start()
{
LOG("Loading background assets");
bool ret = true;
player1 = App->textures->Load("Assets/Sprites/UI/1Player.png");
player2 = App->textures->Load("Assets/Sprites/UI/2Players.png");
graphics = player1;
return ret;
}
// Load assets
bool ModuleSceneChoosePlayer::CleanUp()
{
// TODO 5: Remove all memory leaks
LOG("Unloading ChoosePlayer stage");
App->textures->Unload(graphics);
graphics = nullptr;
App->textures->Unload(player1);
player1 = nullptr;
App->textures->Unload(player2);
player2 = nullptr;
return true;
}
// Update: draw background
update_status ModuleSceneChoosePlayer::Update()
{
current_time = SDL_GetTicks();
if (App->fade->isBlack) {
graphics = (player1 == graphics) ? player2 : player1;
}
else {
if (current_time - start_time > 2000) {
App->fade->FadeToBlack(1);
start_time = current_time;
}
}
// Draw everything --------------------------------------
App->render->Blit(graphics, 0, 0, &background, 1.0f);
// TODO 2: make so pressing SPACE the KEN stage is loaded
if (App->input->keyboard[SDL_SCANCODE_RETURN] == 1 || App->input->controller[START] == KEY_STATE::KEY_DOWN)
{
App->fade->FadeToBlack(App->scene_choosePlayer, App->scene_stage4, 1);
}
return UPDATE_CONTINUE;
}