summaryrefslogtreecommitdiff
path: root/src/graphic
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphic')
-rw-r--r--src/graphic/spriteset.cpp18
-rw-r--r--src/graphic/spriteset.h9
2 files changed, 26 insertions, 1 deletions
diff --git a/src/graphic/spriteset.cpp b/src/graphic/spriteset.cpp
index b008a701..3b190f31 100644
--- a/src/graphic/spriteset.cpp
+++ b/src/graphic/spriteset.cpp
@@ -23,6 +23,8 @@
#include "spriteset.h"
+#include "../log.h"
+
#include "../resources/image.h"
#include "../utils/dtor.h"
@@ -36,9 +38,25 @@ Spriteset::Spriteset(Image *img, int width, int height)
mSpriteset.push_back(img->getSubImage(x, y, width, height));
}
}
+ mWidth = width;
+ mHeight = height;
}
Spriteset::~Spriteset()
{
for_each(mSpriteset.begin(), mSpriteset.end(), make_dtor(mSpriteset));
}
+
+Image *
+Spriteset::get(size_type i)
+{
+ if (i > mSpriteset.size())
+ {
+ logger->log("Warning: Sprite #%i does not exist in this spriteset", i);
+ return NULL;
+ }
+ else
+ {
+ return mSpriteset[i];
+ }
+}
diff --git a/src/graphic/spriteset.h b/src/graphic/spriteset.h
index 08ff65f5..94ccb742 100644
--- a/src/graphic/spriteset.h
+++ b/src/graphic/spriteset.h
@@ -44,14 +44,21 @@ class Spriteset {
*/
~Spriteset();
+ int getWidth() { return mWidth; };
+
+ int getHeight() { return mHeight; };
+
typedef std::vector<Image*>::size_type size_type;
- Image* get(size_type i) { return mSpriteset[i]; }
+ Image * get(size_type i);
size_type size() { return mSpriteset.size(); }
private:
// Vector storing the whole spriteset.
std::vector<Image*> mSpriteset;
+ //height and width of the images in the spriteset
+ int mHeight;
+ int mWidth;
};
#endif