/*
File Name: Sprite.h
Created By: Andy Odle
Date: Oct 13, 2009

Description: 
    
    
*/

#ifndef Sprite_h
#define Sprite_h

#include "./source/inc/MathGOC.h"

#include <string>
using namespace std;

#include "./source/inc/Thing.h"
#include "./source/PlatformSpecific/inc/TextureGOC.h"


// What side did you collide with.
struct CollidedSide
{
    static const unsigned int TOP_COLLISION = 0x0075;
    static const unsigned int BOTTOM_COLLISION = 0x0076;
    static const unsigned int LEFT_COLLISIOIN = 0x0077;
    static const unsigned int RIGHT_COLLISION = 0x0078;
    static const unsigned int NO_COLLISION = 0x0079;
    static const unsigned int YES_COLLISION = 0x0080;
};

class Sprite : public Thing
{
    
    public:

        Sprite();
        ~Sprite();
        
        void Set2DPosition(float xCor_p = 0.0f, 
                           float yCor_p = 0.0f, 
                           float zCor_p = 0.0f, 
                           float width_p = 0.0f, 
                           float height_p = 0.0f);

        void Set2DPosition(PointGOC &position_p, 
                           float width_p, 
                           float height_p);
                         
        bool IsVisible(){return visible_m;}
        
        void SetVisible(bool visible_p);
        
        // Collision detection algroithms.
        unsigned int HasCollidedLeft(Sprite *collidedWithSprite_p);
        unsigned int HasCollidedRight(Sprite *collidedWithSprite_p);
        unsigned int HasCollidedTop(Sprite *collidedWithSprite_p);
        unsigned int HasCollidedBottom(Sprite *collidedWithSprite_p);
        unsigned int HasCollided(Sprite *collidedWithSprite_p);

        // Set the angle of roataion for an sprite.
        void RotateLeft(float angle_p);
        void RotateRight(float angle_p);

        // Get the stored angle.
        float GetAngle(){return currentAngle_m;}
        
        // Set the stored cordinate data.
        void SetXCor(float xCor_p);
        void SetYCor(float yCor_p);
        void SetZCor(float zCor_p);

        // Get the stored stored cordinates.
        float GetXcor(){return position_m.xCor_m;}
        float GetYcor(){return position_m.yCor_m;}
        float GetZcor(){return position_m.zCor_m;}
        PointGOC GetPosition(){return position_m;}

        // Get the sprite's rectangle.
        RectangleGOC &GetSpriteRectangle(){return rectangle_m;}

        // Set the width and height data.
        void SetWidth(float width_p);
        void SetHeight(float height_p);

        // Get the stored width and height.
        float GetWidth(){return width_m;}
        float GetHeight(){return height_m;}

        // Get the Max cordinates.
        float GetMaxXCor(){return position_m.xCor_m + width_m;}
        float GetMaxYCor(){return position_m.yCor_m + height_m;}

        // Get the Middle cordinates.
        PointGOC &GetCenterPoint(){return center_m;}

        TextureGOC *GetTexture(){return texture_m;}
        
        // Required Thing interface.
        void Initialize();
        void Update();    
        void Draw();
        void Destory();
    
    private:
    
        bool visible_m;            // Is the sprite visible?
        bool solid_m;              // Is the sprite solid?
        bool animated_m;           // Is the sprite animated?
        PointGOC position_m;       // Sprite's coordinates.
        PointGOC center_m;         // Sprite's center coordinate.
        RectangleGOC rectangle_m;  // Sprite's rectangular coordinates.
        TextureGOC *texture_m;     // Sprite's texture.
        float width_m;             // width of the sprite.
        float height_m;            // height of the sprite.
        bool textureLoaded_m;      // Is the texture loaded?
        unsigned int textureID_m;  // Loaded texture id.
        float currentAngle_m;
    
        // Transparancy Color
};

#endif
