add input delay
This commit is contained in:
@@ -87,7 +87,7 @@ void Aquarium::redraw() {
|
|||||||
entities_need_sorting = true;
|
entities_need_sorting = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new entities (only if we have them)
|
// Add new entities if we have them
|
||||||
if (!newEntities.empty()) {
|
if (!newEntities.empty()) {
|
||||||
// Reserve space to minimize reallocations
|
// Reserve space to minimize reallocations
|
||||||
entities.reserve(entities.size() + newEntities.size());
|
entities.reserve(entities.size() + newEntities.size());
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ std::unordered_map<char, char> Fish::color_map;
|
|||||||
Fish::Fish() : Fish(getRandomAssetIndex()) {}
|
Fish::Fish() : Fish(getRandomAssetIndex()) {}
|
||||||
|
|
||||||
Fish::Fish(int asset_index)
|
Fish::Fish(int asset_index)
|
||||||
: Entity(asset_index % 2 == 0), image(getFishAssetPairs()[asset_index].image),
|
: Entity(asset_index % 2 == 0),
|
||||||
|
image(getFishAssetPairs()[asset_index].image),
|
||||||
mask(getFishAssetPairs()[asset_index].mask),
|
mask(getFishAssetPairs()[asset_index].mask),
|
||||||
speed(Random::floatInRange(0.25f, 2.25f)) {
|
speed(Random::floatInRange(0.25f, 2.25f)) {
|
||||||
|
|
||||||
@@ -45,7 +46,8 @@ void Fish::randomizeMask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Fish::getRandomAssetIndex() {
|
int Fish::getRandomAssetIndex() {
|
||||||
return Random::intInRange(0, static_cast<int>(getFishAssetPairs().size()) - 1);
|
return Random::intInRange(0,
|
||||||
|
static_cast<int>(getFishAssetPairs().size()) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fish::update() noexcept { x += moving_right ? speed : -speed; }
|
void Fish::update() noexcept { x += moving_right ? speed : -speed; }
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// SpriteUtils.h - Unified mirroring for all asset types
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|||||||
12
src/main.cpp
12
src/main.cpp
@@ -22,10 +22,14 @@ int main(int argc, char *argv[]) {
|
|||||||
while (true) {
|
while (true) {
|
||||||
aquarium.redraw();
|
aquarium.redraw();
|
||||||
int ch = getch();
|
int ch = getch();
|
||||||
if (ch == 'q')
|
if (ch != ERR) {
|
||||||
break;
|
if (ch == 'q')
|
||||||
if (ch == 'r')
|
break;
|
||||||
aquarium.resize();
|
if (ch == 'r')
|
||||||
|
aquarium.resize();
|
||||||
|
flushinp();
|
||||||
|
usleep(100000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user