rotagon/game.h

84 lines
1.4 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 06:01:41 +00:00
#define SCREEN_DIAGONAL (sqrt(SCREEN_HEIGHT*SCREEN_HEIGHT + SCREEN_WIDTH*SCREEN_WIDTH))
2015-01-01 03:04:34 +00:00
2015-01-01 06:37:18 +00:00
#define POLYGON_SIZE 50
2015-01-01 04:32:07 +00:00
2015-01-01 03:04:34 +00:00
#define SHAPE_SQUARE 4
#define SHAPE_PENTAGON 5
#define SHAPE_HEXAGON 6
2015-01-01 04:57:59 +00:00
#define SHAPE_THICK 15
#define CURSOR_DIST (POLYGON_SIZE + SHAPE_THICK + 10)
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;}
#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;
int thick;
int face;
int distance;
int speed;
};
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 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 05:19:10 +00:00
//ugly !
void
(*get_polygon_drawer(struct s_game *g))
(struct s_game *, int faceno, int dist, int thick, int col);
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 03:04:34 +00:00
#endif /* ndef GAME_H */