-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainLoop.h
55 lines (41 loc) · 1.34 KB
/
MainLoop.h
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
int MainLoop()
{
menuLoop();
while(done==0)
{
Collision();
GetKeys();
//Draw everything
draw();
//Movement();
Player1.Move( delta.get_ticks() );
AI(Player2,(int)Player1.xpos,(int)Player1.ypos);
Player2.Move( delta.get_ticks() );
//If we are cooling down, add to the time.
if(Player1.coolDownT < Player1.coolDown)
Player1.coolDownT += delta.get_ticks();
if(Player2.coolDownT < Player2.coolDown)
Player2.coolDownT += delta.get_ticks();
clockTimer += delta.get_ticks();
//reset the timer
delta.start();
if(Player1.HP <= 0)
{
MessageBox(NULL, "You are a Losser","Looser",MB_ICONEXCLAMATION);
SetInstances();
menuLoop();
}
if(Player2.HP <= 0)
{
MessageBox(NULL, "You are a Winner","Winner",MB_ICONEXCLAMATION);
SetInstances();
menuLoop();
}
if((int)Player1.HP < (int)Player1.originalHP)
{
Player1.HP += Player1.regen * ( delta.get_ticks() / 1000.f );
}
SDL_Flip(screen);
}
return 0;
}