fissh

termios terminal aquarium. demo at ssh://fish@kloet.net
Download | Log | Files | Refs

Seaweed.h (867B)


      1 #pragma once
      2 #include "Entity.h"
      3 
      4 class Seaweed : public Entity {
      5 private:
      6   static constexpr char PATTERN_LEFT = '(';
      7   static constexpr char PATTERN_RIGHT = ')';
      8 
      9   const size_t height;
     10   const float speed;
     11 
     12   float frame = 0.0f;
     13   size_t lifetime;
     14   bool pattern_flipped = false;
     15   mutable bool frame_dirty = true;
     16 
     17   mutable std::vector<std::string> current_image;
     18   mutable std::vector<std::string> current_mask;
     19 
     20   void generateCurrentFrame() const;
     21 
     22 public:
     23   Seaweed();
     24 
     25   void update() noexcept override;
     26   const std::vector<std::string> &getImage() const override;
     27   const std::vector<std::string> &getMask() const override;
     28   char getDefaultColor() const noexcept override { return 'g'; }
     29 
     30   bool shouldBeRemoved() const noexcept override;
     31   std::unique_ptr<Entity> createReplacement() const override;
     32   int getPreferredLayer() const noexcept override;
     33 };