61 lines
1.3 KiB
C++
61 lines
1.3 KiB
C++
#ifndef Sprite_h_
|
|
#define Sprite_h_
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <sstream>
|
|
#include <algorithm>
|
|
|
|
#include <SDL.h>
|
|
#include <SDL_image.h>
|
|
|
|
#include "Node.hpp"
|
|
#include "Game.hpp"
|
|
#include "Box.hpp"
|
|
#include "Animation.hpp"
|
|
|
|
struct Sprite : Node
|
|
{
|
|
|
|
std::vector<SDL_Texture*> frames;
|
|
std::vector<fs::path> frame_paths;
|
|
int frame_ii = 0;
|
|
Box box;
|
|
Animation frame_animation = Animation(&Sprite::advance_frame, this);
|
|
Animation blink_animation = Animation(&Sprite::toggle_hidden, this, 500);
|
|
bool is_hidden = false;
|
|
glm::vec2 step = {0, 0};
|
|
|
|
Sprite(Node*);
|
|
Sprite(Node*, std::string);
|
|
void set_frame_length(float);
|
|
void associate(std::string);
|
|
void load();
|
|
void load_file(fs::path);
|
|
void add_frame(SDL_Texture*);
|
|
void unload();
|
|
void advance_frame();
|
|
void hide();
|
|
void unhide();
|
|
void toggle_hidden();
|
|
void set_step(glm::vec2);
|
|
float get_w();
|
|
float get_h();
|
|
glm::vec2 get_size();
|
|
float get_top();
|
|
float get_right();
|
|
float get_bottom();
|
|
float get_left();
|
|
glm::vec2 get_nw();
|
|
glm::vec2 get_north();
|
|
glm::vec2 get_west();
|
|
void set_nw(glm::vec2);
|
|
void move(glm::vec2, bool = true);
|
|
void update();
|
|
std::string get_class_name() { return "Sprite"; }
|
|
~Sprite() { unload(); }
|
|
|
|
};
|
|
|
|
#endif
|