I'm currently building a 2D sprite-based Asteroids game. I've been building a class for the main Game (initialising, releasing and what-not). I also want to build my own Sprite class to make things easier. So far I've inherited the public elements of the Game class... Now I'm having real problems with the Sprite class, the main rendering loop and generally just fitting everything in in the right spot.
Here are the header files containing the Game and Sprite classes:
class Game
{
public:
Game();
~Game();
void InitWindow();
void InitD3D();
void CleanD3D();
void CleanWindow();
void renderFrame(LPD3DXSPRITE);
HWND GetHWND() { return m_hWnd; }
LPDIRECT3DDEVICE9 GetDevice() { return m_d3dDevice; }
friend class Sprite;
private:
HWND m_hWnd;
LPDIRECT3D9 m_d3dObject;
LPDIRECT3DDEVICE9 m_d3dDevice;
LPD3DXFONT m_d3dFont;
D3DPRESENT_PARAMETERS m_d3dpp;
};
and the Sprite class...
class Sprite : public Game
{
private:
LPDIRECT3DTEXTURE9 m_Sprite;
LPD3DXSPRITE m_d3dSprite;
public:
Sprite();
~Sprite();
void Load(LPCTSTR );
void Draw(float, float, int);
void Draw(float, float);
void RotateZ(float);
void Translation(float, float);
friend class Game;
LPDIRECT3DTEXTURE9 GetSprite() { return m_Sprite; }
LPD3DXSPRITE GetD3DSprite() { return m_d3dSprite; }
};
Cheers.