Loading...
Searching...
No Matches
SnakeGame Class Reference

Snake. More...

`#include <game.h>`

Inheritance diagram for SnakeGame:

## Private Types

enum | GameMode { Classic , Hunt , Battle }
| Enumerates the available game modes. More...

## Private Slots

void | processGameLogic ()
| Processes the logic of the game.

## Private Member Functions

void | keyPressEvent (QKeyEvent *event) override
| Stores the valid key events in a queue. More...
void | processNextKeyEvent ()
| Processes the key events in the queue. More...
void | checkCollision (Snake &snake, Snake &adv_snake, const bool &is_adv)
| Checks if a snake will collide with another entity.
void | updateGameScore ()
| Increases/Decreases the player's score by one.

## Private Attributes

std::queue< unsigned short > | key_events
| Stores the key events.
const unsigned int | MAX_SNAKE_LENGTH = 64
| The maximum length of the snake.
Snake | snake
| The snake.
Food | food
| Instance of the egg/rat which will be eat by the snake.

## Detailed Description

Snake.

A reproduction of the timeless classic game

## Member Enumeration Documentation

## GameMode

enum SnakeGame::GameMode

private

Enumerates the available game modes.

Enumerator
Classic | Classic snake game.
Hunt | Game variant in which the food moves too.
Battle | Game variant in which you play against another snake.

## Member Function Documentation

## keyPressEvent()

void SnakeGame::keyPressEvent | ( | QKeyEvent * | event | ) |

overrideprivate

Stores the valid key events in a queue.

Valid keys are UP/DOWN/LEFT/RIGHT arrows and W/S/A/D letters

See also
  key_events, processNextKeyEvent()

## processNextKeyEvent()

void SnakeGame::processNextKeyEvent | ( |  | ) |

private

Processes the key events in the queue.

See also
  key_events, keyPressEvent()

The documentation for this class was generated from the following files:

- logdoctor/games/snake/game.h
- logdoctor/games/snake/game.cpp