A ncurses implementation of the classic Snake game
Definition of the player functions. More...
|void||player_change_direction (int new_direction)|
|Changes the snake direction based on the input received. |
|Depending on the game mode, the player may be able to hit borders or not. |
|Free all memory associated with the player. |
|Checks collision between the snake and the walls. |
|Checks if the snake has eaten the fruit. |
|Checks if the snake have collided with itself. |
|void||player_increase_score (int add)|
|Simply increases the score by the value sent as the parameter. |
|void||player_increase_size (int size)|
|Increases the snake size. |
|Starts the player-related variables. |
|Teleports the player around the borders. |
|Updates the player position, one piece at a time. |
|Global player structure. |
Definition of the player functions.
Checks collision between the snake and the walls.
Checks if the snake has eaten the fruit.
Increases the snake size.
Here we have the core function of this file. Each time the snake increases its size, we expand the array that represents its body.
Updates the player position, one piece at a time.
Start by moving the snake pieces one at a time from the last to the first, and then moves the head according to its direction.