52 lines
1.0 KiB
C
52 lines
1.0 KiB
C
|
#ifndef DEF_XSPRITEGROUP_H
|
||
|
#define DEF_XSPRITEGROUP_H
|
||
|
|
||
|
#include <string>
|
||
|
#include <vector>
|
||
|
#include <mutex>
|
||
|
#include "SDL.h"
|
||
|
#include "SDL_image.h"
|
||
|
#include "xDrawable.h"
|
||
|
#include "xOrchestrable.h"
|
||
|
#include "xApplication.h"
|
||
|
#include "xSprite.h"
|
||
|
using namespace std;
|
||
|
|
||
|
class xSpriteGroup : public xDrawable, public xOrchestrable {
|
||
|
|
||
|
public:
|
||
|
xSpriteGroup();
|
||
|
virtual ~xSpriteGroup();
|
||
|
|
||
|
// manage sprite list
|
||
|
void add(xSprite* sprite);
|
||
|
void remove(xSprite* sprite);
|
||
|
void clear();
|
||
|
|
||
|
// set absolute move for each sprite
|
||
|
void moveTo(int x, int y);
|
||
|
|
||
|
// implement xDrawable
|
||
|
virtual void draw(SDL_Renderer* renderer) override;
|
||
|
|
||
|
// implement xOrchestrable
|
||
|
void tick(const uint32_t ticks);
|
||
|
|
||
|
// animation handles
|
||
|
void animate(uint32_t interval);
|
||
|
void freeze();
|
||
|
|
||
|
protected:
|
||
|
SDL_Rect _move;
|
||
|
|
||
|
set<xSprite*> _sprites;
|
||
|
|
||
|
// active sprite for animation ; equal to 0 if not an animated sprite
|
||
|
size_t _active_sprite = 0;
|
||
|
uint32_t _animation_interval;
|
||
|
|
||
|
mutex _mutex;
|
||
|
|
||
|
};
|
||
|
|
||
|
#endif
|