Levels

The Levls class is the main class that contain all the nested classes wich form the levels of the game

class Levels
{
public:

    class Level {
    public:
        class EntityEvents
        {
        private:
            std::vector<std::pair<size_t, std::vector<size_t>>> _spawns;
            unsigned char _entity;
            std::vector<std::pair<size_t, std::vector<size_t>>>::iterator _it;
            bool _init = true;
        public:
            EntityEvents(unsigned char entity);
            ~EntityEvents();
            std::vector<size_t> getSpawns(size_t currentTimecode);
            void addSpawn(size_t timecode, size_t pos);
            unsigned char getEntity() const;
            void sort();
            bool isFinished() const;
            void setInit(bool init);
        };

        class StrobeEvent
        {
        private:
            std::vector<std::tuple<size_t, unsigned char, bool>> _strobe;
            std::vector<std::tuple<size_t, unsigned char, bool>>::iterator _it;
            bool _init = true;
        public:
            StrobeEvent();
            ~StrobeEvent();
            std::vector<std::tuple<size_t, unsigned char, bool>> getEvents(size_t currentTimecode);
            void addColor(size_t timecode, unsigned char color, size_t duration);
            void sort();
            bool isFinished() const;
            void setInit(bool init);
        };

        Level(const std::string &path);
        ~Level();
        std::vector<EntityEvents> &getEvents();
        StrobeEvent &getStrobes();
        unsigned char getSong() const;
        bool isEnded() const;
    private:
        void parsSong(const std::string &line, const std::string &path, size_t line_nb);
        void parsEvents(const std::string &line, const std::string &path, size_t line_nb);
        std::vector<EntityEvents> _events;
        StrobeEvent _strobes;
        unsigned char _song = 0;
        char _parserEntity = -1;
    };

    Levels(std::vector<std::string> files);
    ~Levels();
    void start();
    void update(Room &room);
    const Level &getLevel() const;
};

Construtor

parameters:

  • The vector of string that contain all the file of the levels scripts

Start

This method start the game and initialise the timers

Update

This method update the level and spawn the needed entities in the room in parameter

GetLevel

this method return the curent level that is currently playing

Last updated