nsnake
Classic snake game for the terminal
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 
11 struct Fruit
12 {
13  int x;
14  int y;
15  Fruit(int x, int y):
16  x(x),
17  y(y)
18  { }
19 };
20 
23 {
24 public:
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 
58 private:
59  std::vector<Fruit> fruit;
60  int amount;
61 };
62 
63 #endif //FRUITMANAGER_H_DEFINED
64 
A single fruit.
A segment of the terminal screen (2D char matrix).
Definition: Window.hpp:16
Controls how many Fruits are there and how they&#39;re spawned.
A level where the snake runs and eats fruits.
Definition: Board.hpp:32