forked from LMG/testRTS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
69 lines (61 loc) · 1.59 KB
/
main.c
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
#include <stdlib.h>
#include <stdio.h>
#include "graphics.h"
#define DELAY 25
int main(int argc, char *argv[])
{
//initialization of the SDL.
SDL_Surface *screen = NULL;
initSDL(&screen);
//main loop
SDL_Event event;
int keepPlaying = 1;
SDL_Rect origin = {0,0};
int value = 0;//stupid test
while (keepPlaying)
{
SDL_PollEvent(&event);
switch(event.type)
{
case SDL_QUIT:
keepPlaying = 0;
break;
case SDL_KEYDOWN:
switch(event.key.keysym.sym)
{
case SDLK_ESCAPE:
keepPlaying = 0;
break;
case SDLK_RIGHT:
origin.x +=5;
break;
case SDLK_LEFT:
origin.x -=5;
break;
case SDLK_UP:
origin.y -=5;
break;
case SDLK_DOWN:
origin.y +=5;
break;
//stupid test
case SDLK_a:
value++;
break;
case SDLK_z:
value--;
break;
default:
break;
}
break;
default:
break;
}
game(screen, &origin, &value);
//waiting
SDL_Delay(DELAY);
}
SDL_Quit();
return EXIT_SUCCESS;
}