-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
54 lines (42 loc) · 862 Bytes
/
main.cpp
File metadata and controls
54 lines (42 loc) · 862 Bytes
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
#include "pch.h"
#include "Block.h"
#include "GameData.h"
GameData gameData{ 20, 19 };
void update()
{
TIMER_GUARD(update, 250);
gameData.Update();
}
void on_key(S2D_Event e)
{
GameData::Key pressedKey = GameData::KeyFromString(e.key);
if (pressedKey == GameData::Key::Esc)
exit(0);
switch (e.type)
{
case S2D_KEY_HELD:
case S2D_KEY_DOWN:
{
TIMER_GUARD(keyDown, 100);
gameData.DoKeyPressed(pressedKey);
break;
}
}
}
void render()
{
gameData.Render();
}
int main(int argc, char* args[])
{
S2D_Window* window = S2D_CreateWindow(
"FUN WITH STL", 1030, 1080, update, render, S2D_RESIZABLE
);
window->on_key = on_key;
S2D_Music * mus = S2D_CreateMusic(R"(audio\background.ogg)");
S2D_PlayMusic(mus, true);
S2D_SetMusicVolume(1);
S2D_HideCursor();
S2D_Show(window);
return 0;
}