nsnake
Classic snake game for the terminal
Loading...
Searching...
No Matches
FruitManager Class Reference

Controls how many Fruits are there and how they're spawned. More...

#include <FruitManager.hpp>

Public Member Functions

 FruitManager (int amount)
 Creates a Fruit container that has at most amount fruits at once on the screen.
 
bool eatenFruit (Player *player)
 Tells if the #player has eaten a fruit this frame.
 
void update (Player *player, Board *board)
 Updates internal fruits, adding them to the #board and making sure it doesn't touch #player.
 
int getAmount ()
 Returns the maximum size we can store within this manager.
 
void add (int x, int y)
 Creates a fruit, adding it at #x, #y.
 
void addRandomly (Board *board, Player *player)
 Creates a fruit randomly within boundaries of #board, making sure that it's not inside #player.
 
void draw (Window *win)
 

Detailed Description

Controls how many Fruits are there and how they're spawned.

Definition at line 22 of file FruitManager.hpp.

Constructor & Destructor Documentation

◆ FruitManager()

FruitManager::FruitManager ( int amount)

Creates a Fruit container that has at most amount fruits at once on the screen.

Definition at line 4 of file FruitManager.cpp.

◆ ~FruitManager()

virtual FruitManager::~FruitManager ( )
inlinevirtual

Definition at line 29 of file FruitManager.hpp.

Member Function Documentation

◆ add()

void FruitManager::add ( int x,
int y )

Creates a fruit, adding it at #x, #y.

Note
It ignores internal amount.

Definition at line 37 of file FruitManager.cpp.

◆ addRandomly()

void FruitManager::addRandomly ( Board * board,
Player * player )

Creates a fruit randomly within boundaries of #board, making sure that it's not inside #player.

Note
It ignores internal amount.

Definition at line 41 of file FruitManager.cpp.

◆ draw()

void FruitManager::draw ( Window * win)

Definition at line 58 of file FruitManager.cpp.

◆ eatenFruit()

bool FruitManager::eatenFruit ( Player * player)

Tells if the #player has eaten a fruit this frame.

Definition at line 7 of file FruitManager.cpp.

◆ getAmount()

int FruitManager::getAmount ( )

Returns the maximum size we can store within this manager.

Note
This is not the current size, as you can use add and addRandomly to forcefully add beyond it's limit.

Definition at line 33 of file FruitManager.cpp.

◆ update()

void FruitManager::update ( Player * player,
Board * board )

Updates internal fruits, adding them to the #board and making sure it doesn't touch #player.

Definition at line 24 of file FruitManager.cpp.


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