Rearranged the classes so that Actors now take care of animation and the
authorIvan Hernandez <iturtleman128@gmail.com>
Tue, 28 Jul 2009 03:07:28 +0000 (22:07 -0500)
committerIvan Hernandez <iturtleman128@gmail.com>
Tue, 28 Jul 2009 03:07:28 +0000 (22:07 -0500)
sprite just has an actor.

Actor.cpp [new file with mode: 0644]
Actor.h [new file with mode: 0644]

diff --git a/Actor.cpp b/Actor.cpp
new file mode 100644 (file)
index 0000000..6a32c04
--- /dev/null
+++ b/Actor.cpp
@@ -0,0 +1,26 @@
+//the beggining
+{
+       mFrame(0),
+       mCurrentAnimation(0),
+       mSpriteAnimations.push_back(anim);
+       if(mSpriteAnimations[mCurrentAnimation] -> mBuilt)
+       {
+               if (mSpriteAnimations[mCurrentAnimation]->mNumFrames > 1) mAnimating = 1;
+       }
+}
+Actor::Draw()
+{
+       if(mAnimating == 1) {
+               if(mLastUpdate+mSpriteAnimations[mCurrentAnimation]->mAnim[mFrame].pause*mSpeed<SDL_GetTicks()) {
+                       mFrame++;
+                       if(mFrame > mSpriteAnimations[mCurrentAnimation]->mNumFrames-1) mFrame=0;
+                       mLastUpdate = SDL_GetTicks();
+               }
+       }
+       SDL_Rect dest;
+       dest.x = mX;
+       dest.y = mY;
+       if(mVisible == true)
+               SDL_BlitSurface(mSpriteAnimations[mCurrentAnimation]->mAnim[mFrame].image,NULL,mScreen,&dest);
+}
+
diff --git a/Actor.h b/Actor.h
new file mode 100644 (file)
index 0000000..45ef5e8
--- /dev/null
+++ b/Actor.h
@@ -0,0 +1,18 @@
+#ifndef SPRITE
+#define SPRITE
+#include "Animation.h"
+#include <SDL/SDL.h>
+#include <vector>
+
+class Sprite
+{
+       public:
+       void draw();
+       std::vector<Animation*> mSpriteAnimations;
+       bool mAnimating;        
+       int mCurrentAnimation;
+       bool mDrawn;
+       bool mVisible;
+       int mAnimation;
+}
+