1#include <Interface/Animation/AnimationSnakes.hpp>
2#include <Interface/Colors.hpp>
3#include <Misc/Utils.hpp>
5AnimationSnakes::AnimationSnakes(
Window* window):
20 if ((addTimer.delta_ms() > delay) &&
21 (this->lilsnakes.size() < MAX_SNAKES))
38 if (updateTimer.delta_ms() > 50)
40 std::vector<LilSnake>::iterator it = this->lilsnakes.begin();
42 while (it != this->lilsnakes.end())
44 if (((*it).y - (*it).size) > (this->window->getH() - 1))
46 it = this->lilsnakes.erase(it);
59 for (
unsigned int i = 0; i < (this->lilsnakes.size()); i++)
61 window->printChar(
'@',
64 Colors::pair(COLOR_GREEN, COLOR_DEFAULT,
true));
66 for (
int j = 1; j < (this->lilsnakes[i].size); j++)
68 window->printChar(
'o',
70 this->lilsnakes[i].y - j,
71 Colors::pair(COLOR_GREEN, COLOR_DEFAULT));
76void AnimationSnakes::addSnake()
82 this->lilsnakes.push_back(
LilSnake(newx, newy, size));
void update()
Updates Animation's internal state.
void load()
Loads all internal things.
void draw()
Shows Animation on the screen.
Abstract interface to any kind of Animation.
A segment of the terminal screen (2D char matrix).
bool booleanWithChance(float percent)
Random boolean with chance of #percent.
int between(int min, int max)
Random number between min and max.