|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- /*
- 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 = curses_active); }
-
- /*
- So, what are actually getters and setters, and why you should never use them? Lets explain.
- @C
- 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 ();
-
- game->active = curses_active;
- 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)) {
- game_synchronize (& game, & player);
- }
- }
-
- #endif
|