rotagon/main.c
Frank Villaro-Dixon 2bb09b07f2 some stupid speed
2015-01-01 07:04:55 +01:00

66 lines
944 B
C

/*
** main.c - Rotagon
**
** 2014 - Frank Villaro-Dixon <Frank@Villaro-Dixon.eu>
*/
#include <stdio.h>
#include <stdlib.h>
#include "SDL/SDL.h"
#include "game.h"
#include "sdl.h"
#include "obs.h"
int
main()
{
struct s_game ga;
start:
init_game(&ga);
init_SDL(&ga);
struct s_obstacle a = create_obstacle(SHAPE_THICK, 2, 1);
add_obstacle(&ga, a);
int rotation = 0;
while(1) {
SDL_FillRect(ga.screen, NULL, 0);
if(!(ga.counter % 28)) {
add_random_obstacle(&ga);
}
update_obstacles(&ga);
draw_game(&ga);
SDL_Flip(ga.screen);
if(check_collisions(&ga)) {
puts("PERDU, connard !");
SDL_Delay(2000);
goto start;
}
get_keys(&ga);
SDL_Delay(5);
ga.counter++;
if(rand()%30 == 0) {
rotation += rand()%20 - 10;
if(rotation > 15)
rotation = 15;
if(rotation < -13)
rotation = -13;
}
ga.general_rotation += rotation;
ga.general_rotation %= ANGLE_MAX;
}
return EXIT_SUCCESS;
}