#ifndef GAME_H #define GAME_H #include "animation.h" #include "events.h" #include #include /* 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; typedef enum { I_NONE, I_ARMOR, I_GLOVE, I_BEER, I_MILK, I_TALISMAN, I_AMOUNT } Item; typedef struct { Item i; unsigned char durability; } Slot; typedef struct { Slot slots[SLOT_NUM]; } Inventory; typedef struct { uint32_t x1, y1; uint32_t x2, y2; } Collider; /* Struct that define player parameters */ typedef struct { int16_t x, y; /* The position of the player in the current map */ uint16_t px, py; /* The position of the player on screen */ 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; /* the player is interacting with a NPC */ bool isInteractingWithNPC; bool is_male; Animation animation; } Player; typedef struct { uint32_t ID; /* data to be shown in the dialog*/ char *dialog; /* is it a question or a simple dialog ? */ uint32_t isQuestion; /* if it is a question, then the choices for answering */ char *choices; /* the conclusion of the dialog for answer 1 and 2 respectively */ /* Note : it may contain a set of event with a dedicated syntax */ char *conclusion1; int32_t next1; char *conclusion2; int32_t next2; int32_t nextOther; } Dialog; typedef struct { /* position of the item */ uint32_t x; uint32_t y; /*id of it's icon*/ uint32_t icon; char *name; /* the ID of the first element of the dialog */ /* (to be aligned with "dialogs.json" IDs)*/ uint32_t dialogID; /*if the dialog is interactive or not*/ uint32_t needAction; } Sign; typedef struct { /* current coordinates of the NPC * In 24:8 fixed point */ uint32_t curx; uint32_t cury; /* initial coordinates of the NPC (needed to get absolute coordinates of * path) */ uint32_t x; uint32_t y; /* id of it's face */ uint16_t face; uint8_t paused; uint8_t has_dialog; /* the ID of the first element of the dialog */ /* (to be aligned with "dialogs.json" IDs)*/ uint32_t dialogID; /*if the dialog is interactive or not*/ uint32_t needAction; char *name; /* data for NPC's trajectories */ uint32_t hasPath; uint32_t path_length; uint32_t currentPoint; int16_t *xpath; int16_t *ypath; int type : 32; uint8_t current_group; uint8_t hostile_to_group; uint16_t __padding; } NPC; typedef struct { Collider collider; /* The destination portal */ void *portal; /* The destination map */ void *map; } Portal; typedef struct { /* width, height and the number of layer of the map */ uint32_t x; uint32_t y; uint32_t w; uint32_t h; uint32_t nblayers; uint32_t tileset_size; /* 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 nbNPC; NPC *npcs; uint32_t nbSign; Sign *signs; uint32_t nbPortal; Portal *portals; /* structure that contains all the dialogs for that part of the map */ uint32_t nbdialogsdata; Dialog *dialogs; uint32_t indoor; /* 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. */ EventHandler handler; /* The event handler (see events.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; Animation npc_animation; int mana; /* Only for testing events TODO: Remove this! */ } Game; /* TODO: Doc! */ void game_init(Game *game); /* (Mibi88) TODO: Describe what this function is doing. */ void game_logic(Game *game); /* game_draw() * * Draws everything on screen. * game: The game struct. */ void game_draw(Game *game); /* game_render_indicator() * * This render a small sign on the upper left corner of the screen * if the player can do an action * game: The game struct. */ void game_render_indicator(Game *game); /* game_get_inputs() * * Handle key presses. * game: The game struct. */ void game_get_inputs(Game *game); /* TODO: Doc! */ void game_update_animations(Game *game, unsigned char ms); #endif