spacebox/src/Sprite.hpp

52 lines
1.0 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 "Location.hpp"
struct Sprite : Node
{
std::vector<SDL_Texture*> frames;
std::vector<fs::path> frame_paths;
int frame_ii = 0;
Location location;
Sprite(Node *parent) : Node(parent)
{
std::cout << "Constructing Sprite with parent " << parent << std::endl;
}
Sprite(Node *parent, std::string path) : Node(parent)
{
std::cout << "Constructing Sprite with " << parent << " and " << path << std::endl;
associate(path);
}
void associate(std::string);
void load();
void load_file(fs::path);
void add_frame(SDL_Texture*);
void unload();
void update();
template<typename T1, typename T2 = int>
void move(T1 dx, T2 dy = 0)
{
Game *game = get_root();
location.move_ip(game->get_weighted_amount(dx), game->get_weighted_amount(dy));
}
};
#endif