From: Ivan Hernanez Date: Mon, 28 May 2012 04:56:07 +0000 (-0500) Subject: Sprite now has scale X-Git-Url: http://git.mmlx.us/?a=commitdiff_plain;h=d8a1bc05f087cc41df7d308932da1797eb19c64d;p=IvanGame.git Sprite now has scale --- diff --git a/Sprite.cpp b/Sprite.cpp index ccc19a6..3d15232 100644 --- a/Sprite.cpp +++ b/Sprite.cpp @@ -49,6 +49,7 @@ void Sprite::draw() glTranslated(mPos.x,mPos.y,0);//move to position glTranslated(frame->animationPeg.x,frame->animationPeg.y,0);//move back to where it was glRotatef(mAngle,0.0f,0.0f,1.0f);//rotate shape + glScaled(mScale); glTranslated(-frame->animationPeg.x,-frame->animationPeg.y,0);//place animation peg on origin glBindTexture(GL_TEXTURE_2D, frame->image); glBegin( GL_QUADS ); diff --git a/Sprite.h b/Sprite.h index ad75f00..0bb6ab4 100644 --- a/Sprite.h +++ b/Sprite.h @@ -21,13 +21,13 @@ class Sprite : public WorldObject SpriteFrame* getAnimation(){ return &mActor.mAnimations[mActor.mCurrentAnimation]->mFrames[mActor.mFrame]; }/**< returns active animation. (actually the current frame within the animation) \todo see if this is slower maybe undo */ void setFrame(int frame) { mActor.mFrame = frame; }/**< cahnges to the specified frame of the animation beginning at 0. */ int getFrame() { return mActor.mFrame; }/**< returns active frame. */ - void setSpeed(float speed) {mSpeed = speed;}/**< sets the Sprite's speed. */ - float getSpeed() {return mSpeed;}/**< returns a Sprite's current speed. */ - std::string getName(){ return mName;}/**< returns the Sprite's name */ - void toggleAnim(){ mAnimating = !mAnimating;}/**< Pauses or resumes an animation. */ - void startAnim() {mAnimating = 1;}/**< Causes the animation to play. */ - void stopAnim() {mAnimating = 0;}/**< Causes the animation to stop. */ - void rewind() {mActor.mFrame = 0;}/**< Resets the Sprite's animation to the first frame. */ + void setSpeed(float speed) { mSpeed = speed; }/**< sets the Sprite's speed. */ + float getSpeed() { return mSpeed;}/**< returns a Sprite's current speed. */ + std::string getName(){ return mName; }/**< returns the Sprite's name */ + void toggleAnim(){ mAnimating = !mAnimating; }/**< Pauses or resumes an animation. */ + void startAnim() {mAnimating = 1; }/**< Causes the animation to play. */ + void stopAnim() {mAnimating = 0; }/**< Causes the animation to stop. */ + void rewind() {mActor.mFrame = 0; }/**< Resets the Sprite's animation to the first frame. */ void draw();/**< draws Sprite. */ void drawCollisions();/**< Draws Collision data for the Object (from outside) */ Sprite* collisionWithSprite(string name);/**< checks for collision with sprite of a given name. */ diff --git a/WorldObject.h b/WorldObject.h index 09794d0..3995954 100644 --- a/WorldObject.h +++ b/WorldObject.h @@ -29,6 +29,7 @@ protected: bool mVisible;/**< Determine if Object should be visible */ float mTransparency;/**< Transparency! */ float mAngle;/**< Angle of rotation */ + float mScale;/**< Scale for the sprite*/ int ZOrder;/**< Stacking order. Determines what draws on top. \todo implement. */ }; #endif