#include <Snake.h>
|
struct | Fruit |
| Structure to holds x and y cordinates of the fruit. More...
|
|
struct | SnakeStrct |
| Structure to holds x and y cordinates of the snake when it move across the grid. More...
|
|
|
| Snake () |
| Default Constructor. initialize variables. More...
|
|
virtual int | CalculateScore () |
| Pure virtual function inherited from GameGenerics.h Each game calculate scores differently and therefore this function need to override in each game according to the game rules. More...
|
|
| GameGenerics () |
| Default Constructor for GameGenerics. This is a abstract class and you cannot instantiate this class. More...
|
|
|
void | GameOverScreen (RenderWindow &window) |
| Display a game over screen at the end of the game alone with user's score. Currently, every game has the same game over screen. If each and every game needs a different screen, it might be a good idea to make it a pure virtual function. More...
|
|
Definition at line 6 of file Snake.h.
◆ Snake()
Default Constructor. initialize variables.
Definition at line 3 of file Snake.cpp.
◆ BoundaryControl()
void Snake::BoundaryControl |
( |
| ) |
|
|
private |
If snake cross the boundary of the window make it reappear on the opposite side of the window.
Definition at line 70 of file Snake.cpp.
◆ CalculateScore()
int Snake::CalculateScore |
( |
| ) |
|
|
virtual |
Pure virtual function inherited from GameGenerics.h Each game calculate scores differently and therefore this function need to override in each game according to the game rules.
Implements GameGenerics.
Definition at line 27 of file Snake.cpp.
◆ DrawSprites()
void Snake::DrawSprites |
( |
RenderWindow & |
window, |
|
|
Sprite & |
sprite1, |
|
|
Sprite & |
sprite2 |
|
) |
| |
|
private |
Draw sprites on the window.
Definition at line 139 of file Snake.cpp.
◆ GameOverLogic()
void Snake::GameOverLogic |
( |
| ) |
|
|
private |
Whenever snake tries to eat itself game is over.
Definition at line 48 of file Snake.cpp.
◆ GrowUponEat()
void Snake::GrowUponEat |
( |
| ) |
|
|
private |
Whenever snake eats a fruit make it grow by 1 square.
Definition at line 59 of file Snake.cpp.
◆ InitializeVars()
void Snake::InitializeVars |
( |
| ) |
|
|
private |
Create Sprites. Load the Images and set the Sprites. Call PlaySnake() function to start the game.
Definition at line 8 of file Snake.cpp.
◆ KeyControls()
void Snake::KeyControls |
( |
| ) |
|
|
private |
Allow user to control snake by using arrow keys.
Definition at line 116 of file Snake.cpp.
◆ MoveSnake()
void Snake::MoveSnake |
( |
| ) |
|
|
private |
◆ MoveToThisDirection()
void Snake::MoveToThisDirection |
( |
| ) |
|
|
private |
Set the direction to move the snake. 0 indicates down. 3 indicates up. 1 indicates left. 2 indicate right.
Definition at line 93 of file Snake.cpp.
◆ PlaySnake()
void Snake::PlaySnake |
( |
RenderWindow & |
window, |
|
|
Sprite & |
sprite1, |
|
|
Sprite & |
sprite2 |
|
) |
| |
|
private |
◆ HEIGHT
const int Snake::HEIGHT = SIZE * M |
|
private |
Define height of the window.
Definition at line 24 of file Snake.h.
Define height with 30 squares.
Definition at line 15 of file Snake.h.
◆ m_direction
Direction of the snake.
Definition at line 27 of file Snake.h.
◆ m_IsGameOver
Track when game is over or not.
Definition at line 36 of file Snake.h.
◆ m_MyFruit
Holds x and y cordinates of the snake when it move across the grid.
Definition at line 55 of file Snake.h.
◆ m_MySnake
Holds x and y cordinates of the fruit.
Definition at line 58 of file Snake.h.
◆ m_Score
Track game score.
Definition at line 33 of file Snake.h.
◆ m_SnakeLength
Length of the snake.
Definition at line 30 of file Snake.h.
Define length with 30 squares.
Definition at line 12 of file Snake.h.
◆ SIZE
const int Snake::SIZE = 16 |
|
private |
Define space between each square.
Definition at line 18 of file Snake.h.
◆ WIDTH
const int Snake::WIDTH = SIZE * N |
|
private |
Define width of the window.
Definition at line 21 of file Snake.h.
The documentation for this class was generated from the following files: