rotagon/main.c

71 lines
1 KiB
C
Raw Normal View History

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 06:37:18 +00:00
#include <math.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 10:40:34 +00:00
#include "patterns.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 10:40:34 +00:00
struct s_obstacle a = create_obstacle(SHAPE_THICK, 2, 1, -1);
2015-01-01 04:32:07 +00:00
add_obstacle(&ga, a);
2015-01-01 03:04:34 +00:00
2015-01-01 06:01:41 +00:00
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 10:40:34 +00:00
/*
2015-01-01 06:04:55 +00:00
if(!(ga.counter % 28)) {
2015-01-01 04:32:07 +00:00
add_random_obstacle(&ga);
}
2015-01-01 10:40:34 +00:00
*/
if(get_max_obs_dist(&ga) < SCREEN_DIAGONAL)
add_pattern(&ga);
2015-01-01 04:32:07 +00:00
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
2015-01-01 10:40:34 +00:00
SDL_Delay(3);
2015-01-01 04:32:07 +00:00
ga.counter++;
2015-01-01 06:01:41 +00:00
2015-01-01 06:40:25 +00:00
ga.general_rotation = ga.counter*3;
2015-01-01 06:37:18 +00:00
ga.sexual_pulsation = 0.3 * fabs(cos(ga.counter*M_PI/45)) + 1 +
0.3 * fabs(sin(ga.counter*M_PI/90));
2015-01-01 10:40:34 +00:00
if(!(ga.counter % 10))
change_game_color(&ga);
2015-01-01 03:04:34 +00:00
}
return EXIT_SUCCESS;
}