56 lines
1.2 KiB
C
56 lines
1.2 KiB
C
#ifndef _MYSTNB_ENGINE_H
|
|
#define _MYSTNB_ENGINE_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#define PLAYER_COUNT 1
|
|
|
|
/* Directions */
|
|
#define DIR_DOWN 0
|
|
#define DIR_RIGHT 1
|
|
#define DIR_UP 2
|
|
#define DIR_LEFT 3
|
|
|
|
/* struct player: A player on the map, triggering actions as they move */
|
|
struct player
|
|
{
|
|
/* Position in map */
|
|
int x, y;
|
|
/* Direction currently facing */
|
|
int dir;
|
|
/* Animation and frame */
|
|
struct animation const *anim;
|
|
int frame;
|
|
};
|
|
|
|
/* struct map: A map with moving doors, collectibles, and fog */
|
|
struct map
|
|
{
|
|
/* Width and height */
|
|
int w, h;
|
|
/* Whether fog is enabled */
|
|
int fog;
|
|
/* Raw data */
|
|
uint8_t *data;
|
|
};
|
|
|
|
/* struct game: A running game with a map and some players */
|
|
struct game
|
|
{
|
|
/* Current map */
|
|
struct map *map;
|
|
/* Players */
|
|
struct player *players[PLAYER_COUNT + 1];
|
|
/* Current game time (ms) */
|
|
int time;
|
|
};
|
|
|
|
/* Draw the current game frame from scratch; does not dupdate() */
|
|
void engine_draw(struct game const *game);
|
|
|
|
/* Try to move a player along a direction. Returns 1 if the move is successful,
|
|
0 otherwise (collisions or out-of-bounds moves) */
|
|
int engine_move(struct game *game, struct player *player, int direction);
|
|
|
|
#endif /* _MYSTNB_ENGINE_H */
|