Sprite now has scale
authorIvan Hernanez <iturtleman128@gmail.com>
Mon, 28 May 2012 04:56:07 +0000 (23:56 -0500)
committerIvan Hernanez <iturtleman128@gmail.com>
Mon, 28 May 2012 04:56:07 +0000 (23:56 -0500)
Sprite.cpp
Sprite.h
WorldObject.h

index ccc19a6..3d15232 100644 (file)
@@ -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 );
index ad75f00..0bb6ab4 100644 (file)
--- 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. */
index 09794d0..3995954 100644 (file)
@@ -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