commit bc5b7b654be150bfefe7694ce3635a1a6fca17f0
parent b6d4ad791c391424c3950534470f2b104cdf64f2
Author: amrfti <andrew@kloet.net>
Date: Tue, 8 Jul 2025 13:18:16 -0400
add input delay
Diffstat:
4 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/Aquarium.cpp b/src/Aquarium.cpp
@@ -87,7 +87,7 @@ void Aquarium::redraw() {
entities_need_sorting = true;
}
- // Add new entities (only if we have them)
+ // Add new entities if we have them
if (!newEntities.empty()) {
// Reserve space to minimize reallocations
entities.reserve(entities.size() + newEntities.size());
diff --git a/src/Fish.cpp b/src/Fish.cpp
@@ -9,7 +9,8 @@ std::unordered_map<char, char> Fish::color_map;
Fish::Fish() : Fish(getRandomAssetIndex()) {}
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),
speed(Random::floatInRange(0.25f, 2.25f)) {
@@ -45,7 +46,8 @@ void Fish::randomizeMask() {
}
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; }
diff --git a/src/SpriteUtils.h b/src/SpriteUtils.h
@@ -1,4 +1,3 @@
-// SpriteUtils.h - Unified mirroring for all asset types
#pragma once
#include <algorithm>
#include <string>
diff --git a/src/main.cpp b/src/main.cpp
@@ -22,10 +22,14 @@ int main(int argc, char *argv[]) {
while (true) {
aquarium.redraw();
int ch = getch();
- if (ch == 'q')
- break;
- if (ch == 'r')
- aquarium.resize();
+ if (ch != ERR) {
+ if (ch == 'q')
+ break;
+ if (ch == 'r')
+ aquarium.resize();
+ flushinp();
+ usleep(100000);
+ }
}
return 0;