-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
83 lines (54 loc) · 1.76 KB
/
main.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <iostream>
#include <chrono>
#include <Windows.h>
#include <mmsystem.h>
#include "headers/entity.h"
#include "headers/player.h"
#include "headers/engine.h"
#include "headers/utils.h"
#define DEBUG 0
int main(int argc, char const *argv[]) {
if (DEBUG)
utils::Logger::setDebug();
else
utils::Logger::unsetDebug();
if (utils::fileExists("track.wav"))
PlaySound(TEXT("track.wav"), NULL, SND_LOOP | SND_ASYNC); // Background music
Map map;
Player player;
// Default spawn
player.pos.a = - utils::PI / 2;
player.pos.x = 14.f;
player.pos.y = 14.5f;
float fFov = utils::PI / 3.0;
// The overlays were made with these dimensions in mind, do NOT change
int nScreenW = 120;
int nScreenH = 40;
// MAIN()
Engine engine = Engine(nScreenW, nScreenH, fFov, map);
auto tp1 = std::chrono::system_clock::now();
auto tp2 = std::chrono::system_clock::now();
WaveQueue waveQueue(map);
waveQueue.pop(engine.currentWave);
while (true) {
tp2 = std::chrono::system_clock::now();
std::chrono::duration<float> elapsedTime = tp2 - tp1;
engine.fElapsedTimeMilliSeconds = std::chrono::duration_cast<std::chrono::milliseconds>(tp2 - tp1).count();
if (engine.fElapsedTimeMilliSeconds <= 1000 / GAME_TICK_RATE)
continue;
// Game-tick:
tp1 = tp2;
engine.updateMobs();
if (engine.currentWave.ended())
waveQueue.pop(engine.currentWave);
engine.checkForDamage(player);
engine.captureInputs(player);
player.score = waveQueue.getDificulty() - 1;
engine.render(player);
if (player.fHealth <= 0.f)
break;
}
engine.deathScreen(player.score);
while (1) {}
return 0;
}