Collab_RPG/src/game.h

111 lines
2.5 KiB
C
Raw Normal View History

#ifndef GAME_H
#define GAME_H
#include <gint/display.h>
#include <stdint.h>
/* The direction where the player is going to. */
typedef enum {
D_UP,
D_DOWN,
D_LEFT,
D_RIGHT
} Direction;
typedef enum {
P_LEFTUP = -1,
P_CENTER = 0,
P_RIGHTDOWN = 1
} Checkpos;
/* Struct that define player parameters */
typedef struct {
int x, y; /* The position of the player int the current map */
unsigned int px, py; /* The position of the player on screen */
int wx, wy; /* position of the player in the world */
unsigned short int life; /* How many lives the player still has between 0
* and 100. */
char speed; /* The speed of the movement of the player. */
} Player;
typedef struct {
uint16_t x;
uint16_t y;
char *name;
char *type;
char *dialog;
} ExtraData;
typedef struct {
/* width, height and the number of layer of the map */
uint16_t w;
uint16_t h;
uint16_t nblayers;
uint16_t tileset_size;
/* world coordinates of the upper left and bootom right*/
/* corners of the current map to be multiplied in game by PXSIZE */
uint16_t xmin;
uint16_t ymin;
uint16_t xmax;
uint16_t ymax;
/* the tileset to use */
bopti_image_t *tileset;
/* contain the properties of the tiles */
/* this is given by the layer Walkable of the map in Tiled */
uint8_t *walkable;
uint32_t nbextradata;
ExtraData *extradata;
/* list of all the tiles */
uint16_t *layers[];
} Map;
/* This struct will contain all the data of the game. It will make it possible
* to pass it to the NPCs to let them interact with the player and the rest of
* the world. */
typedef struct {
Map *map_level; /* The level that the player is currently playing */
Player player; /* The player data (see player.h). */
/* Some global variables */
/* Set to true when asked for exit */
bool exittoOS;
/* Set to true when screenshot is required */
bool screenshot;
/* Set to true when recording a video of the screen is required */
bool record;
/* How many ms the frame already took. */
long int frame_duration;
/* variables used for debuging */
bool debug_map;
bool debug_player;
bool debug_extra;
} Game;
/* (Mibi88) TODO: Describe what this function is doing. */
void game_logic(Game *game);
/* Draws everything on screen. */
void draw(Game *game);
/* Handle key presses. */
void get_inputs(Game *game);
#endif