xhartae/chapter/chapter_5.c

58 lines
2.0 KiB
C
Raw Normal View History

/*
Copyright (c) 2023 : Ognjen 'xolatile' Milan Robovic
Xhartae is free software! You will redistribute it or modify it under the terms of the GNU General Public License by Free Software Foundation.
And when you do redistribute it or modify it, it will use either version 3 of the License, or (at yours truly opinion) any later version.
It is distributed in the hope that it will be useful or harmful, it really depends... But no warranty what so ever, seriously. See GNU/GPLv3.
*/
#ifndef CHAPTER_5_SOURCE
#define CHAPTER_5_SOURCE
#include "chapter_5.h"
static void (* game_action [GAME_ACTION_COUNT]) (game_t * game, player_t * player);
static number_t game_is_active (game_t * game) { return (game->active); }
static number_t game_exit (game_t * game) { return (game->active = FALSE); }/*
static number_t game_get_screen_width (game_t * game) { return (game->screen_width); }
static number_t game_get_screen_height (game_t * game) { return (game->screen_height); }
static number_t game_set_screen_width (game_t * game, number_t width) { return (game->screen_width = width); }
static number_t game_set_screen_height (game_t * game, number_t height) { return (game->screen_height = height); }*/
static void game_configure (game_t * game, player_t * player) {
curses_configure ();
curses_bind (SIGNAL_Q, game_exit);
game->active = TRUE;
game->screen_width = curses_screen_width;
game->screen_height = curses_screen_height;
player->x = 0;
player->y = 0;
}
static void game_synchronize (game_t * game, player_t * player) {
(void) game;
curses_render_background (' ', COLOUR_WHITE, EFFECT_NORMAL);
curses_render_character ('@', COLOUR_CYAN, EFFECT_BOLD, player->x, player->y);
curses_synchronize ();
}
void play_game (void) {
game_t game;
player_t player;
game_configure (& game, & player);
while (game_is_active (& game) && curses_active) {
game_synchronize (& game, & player);
}
}
#endif