-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleBackground.cpp
More file actions
68 lines (56 loc) · 1.59 KB
/
ModuleBackground.cpp
File metadata and controls
68 lines (56 loc) · 1.59 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
#include "Globals.h"
#include "Application.h"
#include "ModuleTextures.h"
#include "ModuleRender.h"
#include "ModuleBackground.h"
// Reference at https://www.youtube.com/watch?v=OEhmUuehGOA
ModuleBackground::ModuleBackground()
{
// ground
ground.x = 8;
ground.y = 391;
ground.w = 896;
ground.h = 72;
// Background / sky
background.x = 72;
background.y = 208;
background.w = 768;
background.h = 176;
// flag animation
flag.PushBack({848, 208, 40, 40});
flag.PushBack({848, 256, 40, 40});
flag.PushBack({848, 304, 40, 40});
flag.speed = 0.08f;
ship.x = 8;
ship.y = 24;
ship.w = 521;
ship.h = 181;
girl.PushBack({ 624, 16, 32, 56 });
girl.PushBack({ 624, 80, 32, 56 });
girl.PushBack({ 624, 144, 32, 56 });
girl.PushBack({ 624, 80, 32, 56 });
girl.speed = 0.05;
}
ModuleBackground::~ModuleBackground()
{}
// Load assets
bool ModuleBackground::Start()
{
LOG("Loading background assets");
bool ret = true;
graphics = App->textures->Load("ken_stage.png");
return ret;
}
// Update: draw background
update_status ModuleBackground::Update()
{
// Draw everything --------------------------------------
App->render->Blit(graphics, 0, 0, &background, 0.75f); // sea and sky
App->render->Blit(graphics, 560, 8, &(flag.GetCurrentFrame()), 0.75f); // flag animation
// TODO 2: Draw the ship from the sprite sheet with some parallax effect
App->render->Blit(graphics, 0, 0, &ship, 0.85);
// TODO 3: Animate the girl on the ship (see the sprite sheet)
App->render->Blit(graphics, 192, 104, &(girl.GetCurrentFrame()), 0.85);
App->render->Blit(graphics, 0, 170, &ground);
return UPDATE_CONTINUE;
}