#pragma once #include "animation.h" #include "map.h" #include "size2d.h" #include "vec2d.h" struct SDL_Renderer; struct Player { enum class States { REST = 0, TAKEOFF = 1, FLIGHT = 2, LANDING = 3, WALK = 4, FALL = 5 }; explicit Player(SDL_Renderer* renderer); void set_state(const States& s); void handle_keyboard(); const Animation& sprite(const States& state); void update_state(const double dt, const Map& map); void draw(); // coordinates of the character vec2d pos{150., 200.}; // speed of the character vec2d speed{0., 0.}; /*! * \brief backwards - facing left or right */ bool backwards{false}; // will be used to differentiate high jump from a long jump vec2d jump{0., 0.}; /*! * \brief state - current sprite */ States state{States::REST}; TimeStamp timestamp{Clock::now()}; /*! * \brief renderer - draw here */ SDL_Renderer* renderer{nullptr}; // size of the sprite on the screen size2d sprite_size{256, 128}; /*! * \brief sprites - sprite sequences to be drawn */ const std::array sprites; };