2016-03-12 23:22:28 +00:00
|
|
|
#ifndef DEF_XSPRITE_H
|
|
|
|
|
|
|
|
#define DEF_XSPRITE_H
|
|
|
|
|
|
|
|
class xSprite{
|
|
|
|
|
|
|
|
public:
|
|
|
|
xSprite(xManager *m); // Sprite vide
|
|
|
|
xSprite(xManager *m, const int rgb[]); // Sprite couleur
|
|
|
|
xSprite(xManager *m, const char *url); // Sprite image
|
2016-03-13 13:53:39 +00:00
|
|
|
xSprite(xManager *m, SDL_Texture *t); // Sprite texture
|
2016-03-12 23:22:28 +00:00
|
|
|
~xSprite();
|
|
|
|
|
2016-03-16 11:08:22 +00:00
|
|
|
// Modifications de la texture
|
|
|
|
void setTexture(const int rgb[]); // Sprite couleur
|
|
|
|
void setTexture(const char *url); // Sprite image
|
|
|
|
void setTexture(SDL_Texture *t); // Sprite texture
|
|
|
|
|
2016-03-14 18:28:18 +00:00
|
|
|
|
2016-03-15 21:56:39 +00:00
|
|
|
vector<int> move(SDL_Rect newpos); // Deplace le sprite
|
|
|
|
vector<int> move(int x, int y); // Deplace le sprite
|
2016-03-14 18:28:18 +00:00
|
|
|
|
2016-03-16 09:17:28 +00:00
|
|
|
// Action en cas de collision
|
|
|
|
virtual void onCollide(vector<int> from, xSprite* by);
|
|
|
|
|
|
|
|
string getType(); // renvoie le type de sprite
|
|
|
|
void setType(string newtype); // modifie le type de sprite
|
|
|
|
|
2016-03-12 23:22:28 +00:00
|
|
|
void dimensions(); // Dimensions par defaut
|
|
|
|
void dimensions(SDL_Rect r); // Dimensions sortie
|
|
|
|
void dimensions(SDL_Rect r, SDL_Rect clip); // Dimensions in/out
|
|
|
|
|
2016-03-14 18:28:18 +00:00
|
|
|
virtual void push(string index); // Ajoute a l'affichage
|
|
|
|
void pull(string index); // Retire de l'affichage
|
|
|
|
void pull(); // Retire de l'affichage
|
2016-03-12 23:22:28 +00:00
|
|
|
|
|
|
|
void update(); // Fait renmonter la mise a jour du manager
|
|
|
|
|
|
|
|
// GETTERS
|
|
|
|
SDL_Texture *texture();
|
2016-03-13 13:53:39 +00:00
|
|
|
xManager *manager();
|
2016-03-12 23:22:28 +00:00
|
|
|
|
2016-03-13 13:53:39 +00:00
|
|
|
SDL_Rect *dst();
|
|
|
|
SDL_Rect *src();
|
2016-03-12 23:22:28 +00:00
|
|
|
|
2016-03-14 18:28:18 +00:00
|
|
|
protected:
|
2016-03-16 09:17:28 +00:00
|
|
|
string _type;
|
|
|
|
|
|
|
|
xManager *_manager;
|
|
|
|
SDL_Texture *_texture;
|
2016-03-12 23:22:28 +00:00
|
|
|
|
|
|
|
SDL_Rect _dst;
|
|
|
|
SDL_Rect _src;
|
|
|
|
|
2016-03-14 18:28:18 +00:00
|
|
|
// Enregistre le dernier index utilise
|
|
|
|
string _index;
|
|
|
|
|
2016-03-15 21:56:39 +00:00
|
|
|
// Protection inter-thread
|
|
|
|
mutex _mutex_move;
|
|
|
|
|
2016-03-12 23:22:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|