2015-01-01 03:04:34 +00:00
|
|
|
/*
|
|
|
|
** main.c - Rotagon
|
|
|
|
**
|
|
|
|
** 2014 - Frank Villaro-Dixon <Frank@Villaro-Dixon.eu>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2015-01-01 03:34:12 +00:00
|
|
|
#include "SDL/SDL.h"
|
2015-01-01 03:04:34 +00:00
|
|
|
#include "game.h"
|
|
|
|
#include "sdl.h"
|
2015-01-01 04:32:07 +00:00
|
|
|
#include "obs.h"
|
2015-01-01 03:04:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
int
|
2015-01-01 04:32:07 +00:00
|
|
|
main()
|
2015-01-01 03:04:34 +00:00
|
|
|
{
|
|
|
|
struct s_game ga;
|
|
|
|
|
2015-01-01 04:32:07 +00:00
|
|
|
start:
|
2015-01-01 03:04:34 +00:00
|
|
|
init_game(&ga);
|
|
|
|
init_SDL(&ga);
|
|
|
|
|
|
|
|
|
2015-01-01 04:32:07 +00:00
|
|
|
struct s_obstacle a = create_obstacle(SHAPE_THICK, 2, 1);
|
|
|
|
add_obstacle(&ga, a);
|
2015-01-01 03:04:34 +00:00
|
|
|
|
|
|
|
while(1) {
|
2015-01-01 03:34:12 +00:00
|
|
|
SDL_FillRect(ga.screen, NULL, 0);
|
2015-01-01 04:32:07 +00:00
|
|
|
if(!(ga.counter % 50)) {
|
|
|
|
add_random_obstacle(&ga);
|
|
|
|
}
|
|
|
|
update_obstacles(&ga);
|
2015-01-01 03:04:34 +00:00
|
|
|
draw_game(&ga);
|
|
|
|
SDL_Flip(ga.screen);
|
2015-01-01 04:32:07 +00:00
|
|
|
|
2015-01-01 04:57:59 +00:00
|
|
|
if(check_collisions(&ga)) {
|
|
|
|
puts("PERDU, connard !");
|
|
|
|
SDL_Delay(2000);
|
|
|
|
goto start;
|
|
|
|
}
|
|
|
|
|
2015-01-01 04:32:07 +00:00
|
|
|
get_keys(&ga);
|
2015-01-01 04:57:59 +00:00
|
|
|
|
|
|
|
SDL_Delay(5);
|
2015-01-01 04:32:07 +00:00
|
|
|
|
|
|
|
ga.counter++;
|
2015-01-01 03:04:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|