-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
64 lines (54 loc) · 1.12 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
#include <stdlib.h>
#include <stdio.h>
#include "game_states.h"
SDL_Surface *background = NULL;
SDL_Surface *screen = NULL;
SDL_Surface* message = NULL;
SDL_Surface* player = NULL;
SDL_Surface* ball = NULL;
SDL_Event event;
TTF_Font *font = NULL;
SDL_Rect balls[MAX_BALLS];
SDL_Color textColor = { 0, 0, 0 };
int main(int argc, char* argv[])
{
bool quit = false;
if( init() == false )
{
return 1;
}
if( load_files() == false )
{
return 1;
}
message = TTF_RenderText_Solid( font, "Press space to start, any other to quit", textColor );
apply_surface( 0, 0, background, screen );
apply_surface( ( 640 - message->w ) / 2, ( 480 - message->h ) / 2, message, screen );
SDL_Flip( screen );
while (quit == false)
{
if( SDL_PollEvent( &event ) )
{
if( event.type == SDL_KEYDOWN )
{
switch( event.key.keysym.sym )
{
case SDLK_SPACE:
{
message = NULL;
main_game();
quit = true;
break;
}
default: quit = true; break;
}
}
else if( event.type == SDL_QUIT )
{
quit = true;
}
}
}
clean_up();
return 0;
}