nsnake
Classic snake game for the terminal
Public Member Functions | List of all members
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. More...
 
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. More...
 
int getAmount ()
 Returns the maximum size we can store within this manager. More...
 
void add (int x, int y)
 Creates a fruit, adding it at #x, #y. More...
 
void addRandomly (Board *board, Player *player)
 Creates a fruit randomly within boundaries of #board, making sure that it's not inside #player. More...
 
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 ( 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.

Member Function Documentation

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.

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.

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.

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: