REBASE AWESOME

This commit is contained in:
2025-05-23 14:59:24 -04:00
parent b4e08ff28d
commit 593bbd6786
19 changed files with 468 additions and 459 deletions

View File

@@ -1,21 +1,35 @@
#pragma once
#include <string>
#include <vector>
#include "Entity.h"
#include <array>
class Waterline {
class Waterline : public Entity {
private:
static constexpr int WATERLINE_Y = 5;
static constexpr char WATERLINE_COLOR = 'c';
static constexpr size_t NUM_WAVE_LAYERS = 4;
size_t x, y;
std::vector<std::string> shape;
std::vector<std::string> colorLines;
// Use arrays instead of vectors for fixed-size data
std::array<std::string, NUM_WAVE_LAYERS> shape;
std::array<std::string, NUM_WAVE_LAYERS> colorLines;
void shiftString(std::string &str, int direction);
void initializeShape();
// Pre-compute shift operations
void shiftStringLeft(std::string &str);
void shiftStringRight(std::string &str);
public:
Waterline();
void draw() const;
void update();
void update() noexcept override;
const std::vector<std::string> &getImage() const override;
const std::vector<std::string> &getMask() const override;
char getDefaultColor() const noexcept override { return WATERLINE_COLOR; }
bool shouldBeRemoved() const noexcept override { return false; }
std::unique_ptr<Entity> createReplacement() const override { return nullptr; }
int getPreferredLayer() const noexcept override { return 0; }
private:
// Cache vectors to avoid allocation each frame
mutable std::vector<std::string> cached_image;
mutable std::vector<std::string> cached_mask;
};