-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cpp
43 lines (43 loc) · 1.27 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
// Tetris
// Author: Serban Mihai Ciprian
// Language: C++11
// Compiler: GNU G++
// Developed on: GNU/Linux Distro. Linux Mint 18.2
// Verison: 0.8
// GitHub: https://github.com/serban-mihai/Tetris
// IMPORTS =====================================================================
#include <iostream>
#include "Game.h"
// LIBS ========================================================================
using namespace std;
// OBJECTS DECLARATION =========================================================
Game *game = nullptr;
// MAIN ========================================================================
int main(int argc, const char * argv[])
{
// Frame rate control (locked to 60FPS/s)
const int FPS = 60;
const int frameDelay = 1000 / FPS;
int frameTime;
Uint32 frameStart;
// Game init and loop
game = new Game();
game->init("Tetris", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 704, false);
while(game->isRunning())
{
game->events();
while(!game->isPaused())
{
frameStart = SDL_GetTicks();
game->events();
game->update();
game->render();
frameTime = SDL_GetTicks() - frameStart;
if(frameDelay > frameTime)
{ SDL_Delay(frameDelay - frameTime); }
}
game->renderPause();
}
game->clean();
return 0;
}