rotagon/game.h

101 lines
1.9 KiB
C
Raw Normal View History

2015-01-01 03:04:34 +00:00
/*
** game.h - Game data structure
**
** 2014 - Frank Villaro-Dixon <Frank@Villaro-Dixon.eu>
*/
#ifndef GAME_H
#define GAME_H
#include "SDL/SDL.h"
2015-01-01 06:01:41 +00:00
#include "SDL_prims.h"
2015-01-01 03:04:34 +00:00
2015-01-01 06:04:55 +00:00
#define SCREEN_WIDTH 1000
#define SCREEN_HEIGHT 700
2015-01-01 10:40:34 +00:00
#define SCREEN_DIAGONAL (sqrt(SCREEN_HEIGHT*SCREEN_HEIGHT + SCREEN_WIDTH*SCREEN_WIDTH)/2)
2015-01-01 03:04:34 +00:00
2015-01-01 10:40:34 +00:00
#define CLEVER_MODULO(n, mod) do { while(n < 0) { n += mod; };;;; n %= mod; } while(0);
2015-01-01 03:04:34 +00:00
2015-01-01 04:32:07 +00:00
2015-01-01 10:40:34 +00:00
#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
2015-01-01 12:12:40 +00:00
#define SHAPE_TRIANGLE 3
2015-01-01 03:04:34 +00:00
#define SHAPE_SQUARE 4
#define SHAPE_PENTAGON 5
#define SHAPE_HEXAGON 6
2015-01-01 10:40:34 +00:00
#define SHAPE_THICK 60
#define DFT_OBS_SPEED (SHAPE_THICK / 15)
#define CURSOR_DIST (POLYGON_SIZE + POLYGON_THICK + 20)
2015-01-01 12:12:40 +00:00
#define CURSOR_DEG_FRAME (24 / g->polygon_type)
2015-01-01 03:34:12 +00:00
#define ANGLE_MAX 3600
2015-01-01 03:04:34 +00:00
2015-01-01 03:34:12 +00:00
#define OFFSET_POINT(p) {p.x += SCREEN_WIDTH/2; p.y += SCREEN_HEIGHT/2;}
2015-01-01 10:40:34 +00:00
#define MAX(a, b) (a < b) ? (b) : (a)
2015-01-01 03:34:12 +00:00
#define TO_DEG(x) (x*ANGLE_MAX/360)
2015-01-01 06:01:41 +00:00
#define TO_RAD(x) (x * 2 * M_PI / ANGLE_MAX)
2015-01-01 03:04:34 +00:00
2015-01-01 04:32:07 +00:00
struct s_obstacle {
int used;
2015-01-01 12:46:13 +00:00
int thick, original_thick;
2015-01-01 04:32:07 +00:00
int face;
int distance;
int speed;
2015-01-01 10:40:34 +00:00
#define K_CLEARANCE (SHAPE_THICK * 5)
2015-01-01 04:32:07 +00:00
};
2015-01-01 03:04:34 +00:00
struct s_game {
#define CURSOR_POS_MAX 255
int cursor_angle; //relative to the polygon center's referential
2015-01-01 06:01:41 +00:00
int general_rotation;
2015-01-01 06:37:18 +00:00
float sexual_pulsation;
2015-01-01 03:04:34 +00:00
int polygon_type; //Shape
2015-01-01 03:34:12 +00:00
int color;
2015-01-01 03:45:30 +00:00
int actual_speed;
2015-01-01 04:32:07 +00:00
int counter;
2015-01-01 03:04:34 +00:00
SDL_Surface *screen;
2015-01-01 03:34:12 +00:00
Uint8 *keys;
2015-01-01 03:04:34 +00:00
2015-01-01 04:32:07 +00:00
#define NUM_OBS 100
struct s_obstacle obs[NUM_OBS];
int num_obs;
2015-01-01 12:46:13 +00:00
struct timespec start_time;
int beat_already_done;
2015-01-01 03:04:34 +00:00
};
void
init_game(struct s_game *g);
2015-01-01 04:57:59 +00:00
int
get_face_from_cursor(struct s_game *g);
2015-01-01 06:01:41 +00:00
SDL_Point
to_screen_coords(struct s_game *g, SDL_Point p);
2015-01-01 03:04:34 +00:00
void
draw_game(struct s_game *g);
2015-01-01 04:32:07 +00:00
void
get_keys(struct s_game *g);
2015-01-01 10:40:34 +00:00
void
change_game_color(struct s_game *g);
2015-01-01 03:04:34 +00:00
#endif /* ndef GAME_H */