Mercurial > molko
view src/core/game.h @ 61:8d34a12484db
core: game should present the window at the very end
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 22 Jan 2020 12:12:25 +0100 |
parents | 52792b863ff7 |
children | 4991bf5f2343 |
line wrap: on
line source
/* * game.h -- main game object * * Copyright (c) 2020 David Demelier <markand@malikania.fr> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef MOLKO_GAME_H #define MOLKO_GAME_H /** * \file game.h * \brief Main game object. */ #include <stdbool.h> #include "action.h" /** * \brief Max number of actions allowed at the same time. */ #define GAME_ACTIONS_MAX 32 struct state; union event; /** * \brief Main game object. */ struct game { /* Game states. */ struct state *state; /*!< (RO) Current state */ struct state *state_next; /*!< (RO) Next state */ /** Array of actions. */ struct action actions[GAME_ACTIONS_MAX]; }; /** * Global game object. */ extern struct game game; /** * Request to change state. * * This function will only update state after the next \a game_update call. * * If quick is true, change state immediately. * * \pre state != NULL * \param state the new state * \param quick quickly change the state */ void game_switch(struct state *state, bool quick); /** * Handle input event. * * \param event the event */ void game_handle(const union event *event); /** * Update the game state. * * \param ticks the number of milliseconds between last frame */ void game_update(unsigned int ticks); /** * Draw the game using the current state. */ void game_draw(void); /** * Add an action to the game. * * If there are no room for the action, action is discarded. Make sure to not * exceed the limit GAME_ACTIONS_MAX. * * \pre action != NULL * \param action the action to copy */ void game_add_action(const struct action *action); #endif /* !MOLKO_GAME_H */