summaryrefslogtreecommitdiff
path: root/Sprite.cpp
diff options
context:
space:
mode:
authorLuke Bratch <l_bratch@yahoo.co.uk>2010-11-26 12:49:49 +0000
committerLuke Bratch <l_bratch@yahoo.co.uk>2010-11-26 12:49:49 +0000
commit4718c83d9204a0a9e2e0add143e829bbb9c0bff0 (patch)
tree51b5192285126af720c8d7df3b45ad6261e8b218 /Sprite.cpp
parent5dd6f1089a86e69889056f3853b373025f68026f (diff)
Implement Sprite::get/setClip for sprite sheet clipping & Creature::Orient for setting a
Creature's clip/orientation
Diffstat (limited to 'Sprite.cpp')
-rw-r--r--Sprite.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/Sprite.cpp b/Sprite.cpp
index d87368a..3b10208 100644
--- a/Sprite.cpp
+++ b/Sprite.cpp
@@ -28,4 +28,21 @@ bool Sprite::visible() {
bool Sprite::setImage(std::string path) {
image = loadImage(path);
+ // Set initial clip to the whole image
+ clipNo = 0;
+ clip[0].x = 0;
+ clip[0].y = 0;
+ clip[0].w = image->w;
+ clip[0].h = image->h;
+}
+
+SDL_Rect* Sprite::getClip() {
+ return &clip[clipNo];
+}
+
+void Sprite::setClip(int clipNo, int x, int y, int w, int h) {
+ clip[clipNo].x = x;
+ clip[clipNo].y = y;
+ clip[clipNo].w = w;
+ clip[clipNo].h = h;
}