nsnake
Classic snake game for the terminal
Loading...
Searching...
No Matches
FruitManager.hpp
1#ifndef FRUITMANAGER_H_DEFINED
2#define FRUITMANAGER_H_DEFINED
3
4#include <Game/Player.hpp>
5#include <Game/Board.hpp>
6#include <Interface/Window.hpp>
7
8#include <vector>
9
11struct Fruit
12{
13 int x;
14 int y;
15 Fruit(int x, int y):
16 x(x),
17 y(y)
18 { }
19};
20
23{
24public:
27 FruitManager(int amount);
28
29 virtual ~FruitManager() {};
30
32 bool eatenFruit(Player* player);
33
36 void update(Player* player, Board* board);
37
44 int getAmount();
45
48 void add(int x, int y);
49
54 void addRandomly(Board* board, Player* player);
55
56 void draw(Window* win);
57
58private:
59 std::vector<Fruit> fruit;
60 int amount;
61};
62
63#endif //FRUITMANAGER_H_DEFINED
64
A level where the snake runs and eats fruits.
Definition Board.hpp:33
FruitManager(int amount)
Creates a Fruit container that has at most amount fruits at once on the screen.
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.
bool eatenFruit(Player *player)
Tells if the player has eaten a fruit this frame.
A segment of the terminal screen (2D char matrix).
Definition Window.hpp:17