#define _SPRITE
#include "Graphics.h"
+#include "Engine/mmanager.h"
/*
Represents a sprite
*/
-class Sprite
+class Sprite : public IMMObject
{
private:
Texture *tex;
dy - tile index in Y
colour - the colour mask to use*/
void blit(int x, int y, float scalex, float scaley, int dx, int dy, colour c);
-
+ AUTO_SIZE;
};
#endif
--- /dev/null
+#include "SpriteManager.h"
+
+
+
+CSpriteManager::CSpriteManager(Graphics *g, SpriteData *sd)
+{
+ /* Load all sprites */
+ while (sd->id != 0)
+ {
+ /* Colour given is for transparency, Sprite has no constructor
+ * without a key colour... */
+ Sprite* s = new Sprite(sd->filename, COLOUR_RGBA(248, 0, 248, 255), sd->width, sd->height, g);
+ if (s) {
+ /* Ensure the needed spot is present */
+ while (this->loadedSprites.size() <= sd->id)
+ this->loadedSprites.push_back(NULL);
+ this->loadedSprites[sd->id] = CMMPointer<Sprite>(s);
+ }
+ sd++;
+ }
+}
+
+CMMPointer<Sprite> CSpriteManager::getSprite(unsigned int id)
+{
+ return this->loadedSprites[id];
+}
--- /dev/null
+#if !defined(SPRITE_MANAGER_H__INCLUDED)
+#define SPRITE_MANAGER_H__INCLUDED
+
+#include <vector>
+#include <cassert>
+#include "Engine/mmanager.h"
+#include "Amaltheia/Sprite.h"
+#include "Amaltheia/Graphics.h"
+
+/**
+ * Used to hold data about default sprites.
+ */
+struct SpriteData {
+ unsigned int id;
+ char* filename;
+ int width;
+ int height;
+};
+
+
+class CSpriteManager
+{
+public:
+ CSpriteManager(Graphics* g, SpriteData *sd);
+ CMMPointer<Sprite> getSprite(unsigned int id);
+private:
+ std::vector< CMMPointer<Sprite> > loadedSprites;
+};
+#endif // SPRITE_MANAGER_H__INCLUDED