19 lines
489 B
C++
19 lines
489 B
C++
#include "Bubble.h"
|
|
#include "Aquarium.h"
|
|
#include <ncurses.h>
|
|
|
|
Bubble::Bubble(size_t x, size_t y) : x(x), y(y) {}
|
|
|
|
void Bubble::update() {
|
|
--y;
|
|
++lifetime;
|
|
}
|
|
|
|
void Bubble::draw() const {
|
|
static const std::string colorString(1, BUBBLE_COLOR);
|
|
// Clamp frame index
|
|
int frameIndex = std::min(lifetime / FRAMES_PER_ANIMATION, MAX_FRAME_INDEX);
|
|
Aquarium::getInstance().drawToBackBuffer(y, x, 0, BUBBLE_FRAMES[frameIndex],
|
|
colorString);
|
|
}
|