/* ** game.h - Game data structure ** ** 2014 - Frank Villaro-Dixon */ #ifndef GAME_H #define GAME_H #include "SDL/SDL.h" #include "SDL_prims.h" #define SCREEN_WIDTH 1000 #define SCREEN_HEIGHT 700 #define SCREEN_DIAGONAL (sqrt(SCREEN_HEIGHT*SCREEN_HEIGHT + SCREEN_WIDTH*SCREEN_WIDTH)/2) #define CLEVER_MODULO(n, mod) do { while(n < 0) { n += mod; };;;; n %= mod; } while(0); #define DEC_COLOR 0x00020202 #define DIVIDE_COLOR(color, times) (((color) & 0x00ff0000 / (times)) | ((color) & 0x0000ff00 / (times)) | ((color) & 0x000000ff / (times))) ////POLYGON #define POLYGON_SIZE 50 #define POLYGON_THICK 15 //SHAPES #define SHAPE_TRIANGLE 3 #define SHAPE_SQUARE 4 #define SHAPE_PENTAGON 5 #define SHAPE_HEXAGON 6 #define SHAPE_THICK 60 #define DFT_OBS_SPEED (SHAPE_THICK / 15) #define CURSOR_DIST (POLYGON_SIZE + POLYGON_THICK + 20) #define CURSOR_DEG_FRAME (24 / g->polygon_type) #define ANGLE_MAX 3600 #define OFFSET_POINT(p) {p.x += SCREEN_WIDTH/2; p.y += SCREEN_HEIGHT/2;} #define MAX(a, b) (a < b) ? (b) : (a) #define TO_DEG(x) (x*ANGLE_MAX/360) #define TO_RAD(x) (x * 2 * M_PI / ANGLE_MAX) struct s_obstacle { int used; int thick, original_thick; int face; int distance; int speed; #define K_CLEARANCE (SHAPE_THICK * 5) }; struct s_game { #define CURSOR_POS_MAX 255 int cursor_angle; //relative to the polygon center's referential int general_rotation; float sexual_pulsation; int polygon_type; //Shape int color; int actual_speed; int counter; SDL_Surface *screen; Uint8 *keys; #define NUM_OBS 100 struct s_obstacle obs[NUM_OBS]; int num_obs; struct timespec start_time; int beat_already_done; }; void init_game(struct s_game *g); int get_face_from_cursor(struct s_game *g); //ugly ! void (*get_polygon_drawer(struct s_game *g)) (struct s_game *, int faceno, int dist, int thick, int col); SDL_Point to_screen_coords(struct s_game *g, SDL_Point p); void draw_game(struct s_game *g); void get_keys(struct s_game *g); void change_game_color(struct s_game *g); #endif /* ndef GAME_H */