mirror of
https://git.planet-casio.com/Slyvtt/Collab_RPG.git
synced 2024-12-29 13:03:43 +01:00
128 lines
3.3 KiB
C
128 lines
3.3 KiB
C
#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 {
|
|
int16_t x, y; /* The position of the player int the current map */
|
|
uint16_t px, py; /* The position of the player on screen */
|
|
int16_t wx, wy; /* position of the player in the world */
|
|
int8_t life; /* How many lives the player still has between 0 and 100. */
|
|
int8_t speed; /* The speed of the movement of the player. */
|
|
|
|
|
|
/* set to true if a action can be done in the current position of the map */
|
|
bool canDoSomething;
|
|
/* indicates which data are relevant to the current action in the */
|
|
/* extradata layer of the map */
|
|
int32_t whichAction;
|
|
/* the player is doing something */
|
|
bool isDoingAction;
|
|
} Player;
|
|
|
|
|
|
typedef struct {
|
|
/* position of the item */
|
|
uint16_t x;
|
|
uint16_t y;
|
|
/* its name */
|
|
char *name;
|
|
/* its class (NPC, SGN, INFO, ... )*/
|
|
char *type;
|
|
/* data to be shown in the dialog*/
|
|
char *dialog;
|
|
/* ... this can be extended as per needs ... */
|
|
} 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;
|
|
|
|
/* structure that contains all the items on the map to interract with */
|
|
/* each portion of the map has its own list to avoid scrutinizing too much */
|
|
/* data when lloking for proximity of items */
|
|
uint32_t nbextradata;
|
|
ExtraData *extradata;
|
|
|
|
/* list of all the tiles to draw the background and the foreground layers */
|
|
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);
|
|
|
|
/* This render a small sign on the upper lecft corner of the screen */
|
|
/* if the player can do an action */
|
|
void render_indicator(Game *game);
|
|
|
|
/* Handle key presses. */
|
|
void get_inputs(Game *game);
|
|
|
|
#endif
|
|
|