xmario/xSDL/xSpriteGroup.h

53 lines
1.1 KiB
C
Raw Permalink Normal View History

#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();
// apply relative displace for each sprite
void displace(SDL_Rect relative_displace);
void displace(int x, int y, int w, int h);
// 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:
set<xSprite*> _sprites;
// if not animated, draw all sprites, else draw one at a time
bool _animated = false;
// active sprite for animation
size_t _active_sprite = 0;
uint32_t _animation_interval = 0;
mutex _mutex;
};
#endif