rotagon/game.h
Frank Villaro-Dixon 916c80435b screen rotation
2015-01-01 07:01:41 +01:00

82 lines
1.4 KiB
C

/*
** game.h - Game data structure
**
** 2014 - Frank Villaro-Dixon <Frank@Villaro-Dixon.eu>
*/
#ifndef GAME_H
#define GAME_H
#include "SDL/SDL.h"
#include "SDL_prims.h"
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
#define SCREEN_DIAGONAL (sqrt(SCREEN_HEIGHT*SCREEN_HEIGHT + SCREEN_WIDTH*SCREEN_WIDTH))
#define POLYGON_SIZE 30
#define SHAPE_SQUARE 4
#define SHAPE_PENTAGON 5
#define SHAPE_HEXAGON 6
#define SHAPE_THICK 15
#define CURSOR_DIST (POLYGON_SIZE + SHAPE_THICK + 10)
#define ANGLE_MAX 3600
#define OFFSET_POINT(p) {p.x += SCREEN_WIDTH/2; p.y += SCREEN_HEIGHT/2;}
#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;
int face;
int distance;
int speed;
};
struct s_game {
#define CURSOR_POS_MAX 255
int cursor_angle; //relative to the polygon center's referential
int general_rotation;
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;
};
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);
#endif /* ndef GAME_H */