/*
* Starfield Application
*
* University of Abertay Dundee
* May be used for educational purposed only
*
* Author - Dr Henry S Fortuna
*
* $Revision: 1.7 $
* $Date: 2008/01/12 10:32:27 $
*
*/

#ifndef _PRIMITIVES_H_
#define _PRIMITIVES_H_

#include "PS2Defines.h"

class PS2Sprite 
{
public:

	PS2Sprite::PS2Sprite();
	
	PS2Sprite::PS2Sprite(const float x, const float y);
	
	PS2Sprite::~PS2Sprite();
	
	virtual void Render(void) const;
	virtual void RenderPerspective(void) const;
	
	void MoveTo(const float x, const float y, const float z);

	void SetSize(const float h, const float w);
	
	void MoveDeltaX(const float x);
	
	void MoveDeltaY(const float y);

	void MoveDeltaZ(const float z);	
	void MoveDeltaZ(void);	

	void MoveDeltaZBack(const float z);
	void MoveDeltaZBack(void);

	float GetX(void);

	float GetY(void);

	float GetZ(void);
	
	float GetHeight(void);

	float GetWidth(void);

	float Scale(void);
	
	float GetVz(void)
		{return m_Vz;}
		
	void SetVz(const float Vz)
		{m_Vz = Vz;}



protected:

	void Initialise(void);		// Initialise variables

	float m_x, m_y;				// position on screen
	float m_z;					// z depth (big = near)
	float m_w, m_h;				// width and height
	float m_Vx, m_Vy, m_Vz;		// Velocity x and y and z

	uint8 m_r, m_g, m_b, m_a;	// colour and alpha
	
	struct Vector2				// Local Space
	{							// Vertex coordinates
		float x, y;
	}m_TopLeft, m_BottomLeft, m_TopRight, m_BottomRight;
};


class PS2SpriteT : public PS2Sprite
{
public:
	
	PS2SpriteT();
	~PS2SpriteT();
	
	virtual void Render(void) const;
	virtual void RenderPerspective(void) const;
	void ChangeSize(int x, int y);

	void ChangePic(int x, int y);

	float GetPic(void);

	void SetAnimCount(int speed, int num_frames);

	void Animate(void);

	void AnimateOnce(void);

	bool animate;
	
protected:
	
	int m_tu, m_tv;	// Texture coordinates (top left)		
	int m_tw, m_th;				// Texture coordinates (width and height)
	int m_AnimCountMax;		// Max counter value
	int m_AnimCounter;		// Animation Counter
	int m_NumFrames;		// Number of animation frames
};

#endif