-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.cpp
66 lines (58 loc) · 1.35 KB
/
Game.cpp
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
#include "Game.h"
#include <LevelLoader.h>
#include "PogoScene.h"
#include <InputProcessor.h>
#include "GameState.h"
#include "Time.h"
PogoScene Game::scene = PogoScene();
MenuScene Game::menu_scene = MenuScene();
GameState Game::state = GameState();
uint8_t Game::save_slot_ = 0;
screen Game::global_screen = screen::logo;
InputProcessor Game::input_processor = InputProcessor();
void Game::initialize()
{
input_processor.set_controlled_camera(&Game::scene.camera);
scene.camera.set_followed_target(&scene.hero);
gametime::framecount = 0;
}
void Game::continue_or_new_game(const int save_slot)
{
save_slot_ = save_slot;
state.load(save_slot);
LevelLoader::trigger_level_switch(state.spawn_point);
}
void Game::reload_last_save()
{
state.load(save_slot_);
LevelLoader::trigger_level_switch(state.spawn_point);
}
void do_menu()
{
Game::menu_scene.update();
Renderer::render(Game::menu_scene, true);
}
void do_game()
{
LevelLoader::load_next_level_if_needed(Game::input_processor);
Game::input_processor.update();
Game::scene.update();
Renderer::render(Game::scene, false);
}
void Game::do_loop()
{
if (global_screen != screen::game)
{
do_menu();
}
else
{
do_game();
}
}
void Game::progress_to_spawn_point(const uint8_t next_spawn_point)
{
state.store_current_area_state();
LevelLoader::trigger_level_switch(next_spawn_point);
state.save(save_slot_);
}