-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
71 lines (61 loc) · 1.22 KB
/
main.cpp
File metadata and controls
71 lines (61 loc) · 1.22 KB
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
#include<bits/stdc++.h>
#include<SDL2/SDL.h>
#include<SDL2/SDL_image.h>
#include "Game.h"
using namespace std;
#include "MainMenu.hpp"
#include "ScreenManager.hpp"
Game* game = NULL;
MainMenu* mgame = NULL;
Screens* s = NULL ;
int firsttime = 1 ;
int main(int argc, const char* argv[]){
const int FPS = 60;
const int frameDelay = 1000/FPS;
Uint32 framestart ;
int frametime ;
game = new Game();
game->displayHighScore();
mgame = new MainMenu(game->getHighScore());
mgame->init("iCarrom",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,800,600);
s = (Screens*)mgame;
while(s->rungame())
{
s->EventHandling();
s->updatescr();
s->renderscr();
frametime = SDL_GetTicks()-framestart ;
if(frameDelay > frametime){
SDL_Delay(frameDelay-frametime);
}
if(s->snum==0)
{
if(firsttime !=1)
if(game->rungame()==false)
{
cout<<"IN THIS \n";
}
s=(Screens*)mgame;
firsttime = 1;
}
else
{
if(firsttime==1)
{
if(s->snum==1)
{
game->init("iCarrom",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,800,600);
firsttime=-1;
}
else if(s->snum==2)
{
cout<<"exiting"<<endl;
break;
}
s=(Screens*)game;
}
}
}
s->cleanscr();
return 0 ;
}