-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleSceneSpace.cpp
More file actions
62 lines (46 loc) · 1.42 KB
/
ModuleSceneSpace.cpp
File metadata and controls
62 lines (46 loc) · 1.42 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
#include "Globals.h"
#include "Application.h"
#include "ModuleSceneSpace.h"
// Reference at https://www.youtube.com/watch?v=OEhmUuehGOA
ModuleSceneSpace::ModuleSceneSpace(Application* app, bool start_enabled) : Module(app, start_enabled)
{
background = NULL;
stars = NULL;
}
ModuleSceneSpace::~ModuleSceneSpace()
{}
// Load assets
bool ModuleSceneSpace::Start()
{
LOG("Loading space scene");
background = App->textures->Load("rtype/background.png");
App->collision->Enable(); // enable before player
App->player->Enable();
App->audio->PlayMusic("rtype/stage1.ogg", 1.0f);
App->renderer->camera.x = App->renderer->camera.y = 0;
App->collision->AddCollider({0,224,3930, 16}, COLLIDER_WALL);
App->collision->AddCollider({142, 192, 63, 48}, COLLIDER_WALL);
App->collision->AddCollider({1376, 0, 560, 15}, COLLIDER_WALL);
App->collision->AddCollider({1376, 15, 112, 79}, COLLIDER_WALL);
return true;
}
// UnLoad assets
bool ModuleSceneSpace::CleanUp()
{
LOG("Unloading space scene");
App->textures->Unload(background);
App->player->Disable();
App->collision->Disable();
return true;
}
// Update: draw background
update_status ModuleSceneSpace::Update()
{
// Move camera forward -----------------------------
int scroll_speed = 1;
App->player->position.x += 1;
App->renderer->camera.x -= 3;
// Draw everything --------------------------------------
App->renderer->Blit(background, 0, 0, NULL);
return UPDATE_CONTINUE;
}