From: Ivan Hernandez Date: Tue, 28 Jul 2009 03:07:28 +0000 (-0500) Subject: Rearranged the classes so that Actors now take care of animation and the X-Git-Url: http://git.mmlx.us/?a=commitdiff_plain;h=1fad49fd286c0599ea0087878095b300f0f7b279;p=IvanGame.git Rearranged the classes so that Actors now take care of animation and the sprite just has an actor. --- diff --git a/Actor.cpp b/Actor.cpp new file mode 100644 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 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 index 0000000..45ef5e8 --- /dev/null +++ b/Actor.h @@ -0,0 +1,18 @@ +#ifndef SPRITE +#define SPRITE +#include "Animation.h" +#include +#include + +class Sprite +{ + public: + void draw(); + std::vector mSpriteAnimations; + bool mAnimating; + int mCurrentAnimation; + bool mDrawn; + bool mVisible; + int mAnimation; +} +