nSnake
A ncurses implementation of the classic Snake game
|
Declaration of the graphical engine functions, defines and globals. More...
Go to the source code of this file.
Data Structures | |
struct | screen_t |
Global definitions related to the game screen. More... | |
Functions | |
void | draw_background () |
Just erases everything to black. | |
void | draw_borders () |
Draws the window border, according to the game.mode. | |
void | draw_fruit () |
Draws the current fruit on screen. | |
void | draw_fruit_bonus () |
Draws the bonus value of the current fruit. | |
void | draw_player () |
Draws the snake - from the head to the whole body. | |
void | draw_score () |
Prints the current score. | |
void | engine_exit () |
Exits and dealocates the memory required by ncurses. | |
void | engine_init () |
Starts the game engine. | |
void | engine_show_game_over () |
Draws the Game Over screen. | |
void | engine_show_main_menu () |
Displays the main menu and gets the user input from it. | |
void | engine_show_pause () |
Prints the pause message. | |
void | engine_show_screen () |
Completely draws the screen during game. | |
int | get_main_menu_input (int *current_option) |
Gets the input for the main menu. | |
void | engine_get_game_input () |
Get the user input during game and make the right decisions. | |
void | get_game_over_input () |
Waits for an user action during the 'Game Over' screen. | |
void | get_pause_input () |
Just waits untill the user either unpauses the game or exits. | |
void | start_atrribute (int attr) |
Wrapper to the attron() function, in case the current terminal doesn't support colors. | |
Variables | |
struct screen_t | screen |
Global screen structure. |
Declaration of the graphical engine functions, defines and globals.
void engine_init | ( | ) |
Starts the game engine.
Initializes all the stuff related to ncurses.
void engine_show_game_over | ( | ) |
Draws the Game Over screen.
Besides drawing 'Game Over', it highlights where the player died.
void engine_show_main_menu | ( | ) |
Displays the main menu and gets the user input from it.
This function blocks the game execution and waits for user input, refreshing the main menu screen according to the options selected.
void engine_show_screen | ( | ) |
Completely draws the screen during game.
The usleep() function interrupts the program for 'n' microseconds. It was difficult to get a stable value for the game progression.