-
Notifications
You must be signed in to change notification settings - Fork 0
/
Controller.cpp
64 lines (46 loc) · 1.25 KB
/
Controller.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
#include "Controller.h"
State* Controller::currentState;
bool Controller::loading;
Timer* Controller::timer;
void Controller::Init() {
currentState = 0;
timer = new Timer();
}
void Controller::LoadInitialState(State* lev) {
lev->loading = true;
currentState = lev;
currentState->Load();
lev->loading = false;
//currentLevel->tickRate = 64.00;
}
void Controller::SwitchState(State* lev) {
loading = true;
currentState->Unload();
lev->Load();
delete currentState;
currentState = lev;
loading = false;
}
void Controller::Render() {
if (loading) return;
currentState->Render();
}
void Controller::Update() {
/*std::clock_t start;
double duration = 0;
start = std::clock();
currentLevel->Update();
duration = (std::clock() - start) / (double)CLOCKS_PER_SEC;
Sleep(((1.00 / currentLevel->tickRate) - duration) * 1000);*/
if (loading) return;
timer->Update();
currentState->Update(timer->GetTimeTotal(), timer->GetTimeDelta());
}
void Controller::Update(std::vector<IA>* inputQue) {
if (loading) return;
timer->Update();
currentState->Update(timer->GetTimeTotal(), timer->GetTimeDelta(),inputQue);
}
/*void Controller::Update(GameLevel::GameAction action, LPARAM lparam, WPARAM wparam) {
currentLevel->Update(action, lparam, wparam);
}*/