xmario/xSDL/xSprite.h

60 lines
1.3 KiB
C++

#ifndef DEF_XSPRITE_H
#define DEF_XSPRITE_H
#include <string>
#include <vector>
#include <mutex>
#include "SDL.h"
#include "SDL_image.h"
#include "xElement.h"
using namespace std;
class xSprite : public xElement {
public:
xSprite(); // empty
xSprite(const int rgba[]); // color sprite
xSprite(const char *url); // image sprite
xSprite(SDL_Surface *s); // copy sprite
~xSprite();
// replace surface
void setSurface(const int rgba[]); // color sprite
void setSurface(const char *url); // image sprite
void setSurface(SDL_Surface *t); // copy surface
// move the sprite
// const bool* move(double xSpeed, double ySpeed);
// action to apply on collision
// virtual void onCollide(vector<bool> from, xSprite* by);
// get/set sprite type
string getType();
void setType(string newtype);
// set dimensions
void dimensions(); // defauts
void dimensions(SDL_Rect r);
void dimensions(SDL_Rect r, SDL_Rect clip); // w/ clip
// getters
SDL_Surface *surface();
SDL_Rect *dst();
SDL_Rect *src();
// implement xElement
virtual void draw(SDL_Renderer* renderer) override;
protected:
string _type;
SDL_Surface* _surface = NULL;
SDL_Rect _dst;
SDL_Rect _src;
mutex _mutex;
};
#endif