#ifndef VDDIRECT3D_H
#define VDDIRECT3D_H



/* **********************************************************************************************************************
   Included Header Files
   **********************************************************************************************************************/

#include <d3d9.h>
#include <d3dx9.h>
#include <windows.h>
#include <list>
#include <vector>
#include "VDSprite.h"
#include "VDError.h"
using namespace std;



/* **********************************************************************************************************************
   Linked Libraries
   **********************************************************************************************************************/

#pragma comment(lib, "d3d9.lib")
#ifdef _DEBUG
    #pragma comment(lib, "d3dx9d.lib")
#else
    #pragma comment(lib, "d3dx9.lib")
#endif



/* **********************************************************************************************************************
   VDDirect3D
   **********************************************************************************************************************/

class VDDirect3D {
public:
    VDDirect3D();
    virtual ~VDDirect3D();

         void FreeMemory();
         void InitializeDirect3D(HWND window);
         void Render(const RECT *area, int numUpdates, int windowWidth, int windowHeight, int userLocationX, int userLocationY);
         void RenderSprite(const RECT *area, HWND window, VDSprite *aSprite);
    VDSprite* AddSprite(LPCTSTR textureFile, RECT sourceRect, float x, float y, D3DCOLOR colorKey, int isStatic, int isNPC);
    VDSprite* AddPlayerSprite(LPCTSTR textureFile, RECT sourceRect, float x, float y, D3DCOLOR colorKey, int isStatic, int isNPC);
         void RemoveTileSprite(float x, float y);
         void RemoveNPCSprite(float x, float y);
         void MovingPlayer(int direction);
         BOOL IsNPCMoving(float x, float y);
         void MovingNPC(float x, float y, int direction);
         void RemoveDeadSprites();
         void ClearScreen();
       LPCSTR AddText(LPCSTR theMessage, int theLeft, int theTop, int theRight, int theBottom, D3DCOLOR theColor);
         void RemoveText(LPCSTR theMessage);
         void RemoveTexts();

    LPDIRECT3DDEVICE9 GetDirect3DRenderer();
         LPD3DXSPRITE GetSpriteRenderer();
private:
    typedef struct Text {
            RECT textBox;
            char message[500];
        D3DCOLOR color;
    };
                LPDIRECT3D9 direct3D;                // Direct3D
          LPDIRECT3DDEVICE9 direct3DDevice;          // display adapter device
      D3DPRESENT_PARAMETERS presentationParameters;  // presentation parameters
               LPD3DXSPRITE sprite;                  // sprite rendering unit
           vector<VDSprite> tileSprites;             // list of the sprites
           vector<VDSprite> npcSprites;              // list of the npc sprites
                  VDSprite* playerSprite;            // player sprite
                 LPD3DXFONT font;                    // font for displaying text
                 list<Text> text;                    // list of texts
};



#endif  // VDDIRECT3D_H