finish mirroring. abstract entity removal
This commit is contained in:
14
src/Fish.cpp
14
src/Fish.cpp
@@ -9,10 +9,9 @@ std::unordered_map<char, char> Fish::color_map;
|
||||
Fish::Fish() : Fish(getRandomAssetIndex()) {}
|
||||
|
||||
Fish::Fish(int asset_index)
|
||||
: Entity(), image(fishAssetPairs[asset_index].image),
|
||||
: Entity(asset_index % 2 == 0), image(fishAssetPairs[asset_index].image),
|
||||
mask(fishAssetPairs[asset_index].mask),
|
||||
speed(Random::floatInRange(0.25f, 2.25f)),
|
||||
moving_right(asset_index % 2 == 0) {
|
||||
speed(Random::floatInRange(0.25f, 2.25f)) {
|
||||
|
||||
const auto &aquarium = Aquarium::getInstance();
|
||||
y = Random::intInRange(static_cast<int>(image.size()) + 6,
|
||||
@@ -50,15 +49,6 @@ int Fish::getRandomAssetIndex() {
|
||||
|
||||
void Fish::update() noexcept { x += moving_right ? speed : -speed; }
|
||||
|
||||
bool Fish::shouldBeRemoved() const noexcept {
|
||||
const auto &aquarium = Aquarium::getInstance();
|
||||
if (moving_right) {
|
||||
return x > static_cast<float>(aquarium.getWidth());
|
||||
} else {
|
||||
return (x + static_cast<float>(image[0].length())) < 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<Entity> Fish::createReplacement() const {
|
||||
return std::make_unique<Fish>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user