- //---------------------------
- // Includes
- //---------------------------
- #include "GridNode.h"
- #include "resource.h"
- //---------------------------
- // Defines
- //---------------------------
- #define GAME_ENGINE (GameEngine::GetSingleton())
- //---------------------------
- // Constructor & Destructor
- //---------------------------
- GridNode::GridNode(int x, int y, int type, bool walkable): m_xPos(x),
- m_yPos(y),
- m_Type(type),
- m_bWalkable(walkable),
- m_bmpDirtPtr(0),
- m_bmpGrassPtr(0),
- m_bmpWallPtr(0),
- m_bmpWaterPtr(0)
- {
- // nothing to create
- }
- GridNode::~GridNode()
- {
- // nothing to destroy
- }
- void GridNode::Create()
- {
- m_bmpWaterPtr = new Bitmap(IDB_WATER, "BITMAP");
- m_bmpWallPtr = new Bitmap(IDB_WALL, "BITMAP");
- m_bmpGrassPtr = new Bitmap(IDB_GRASS, "BITMAP");
- m_bmpDirtPtr = new Bitmap(IDB_DIRT, "BITMAP");
- if(!m_bmpWaterPtr->Exists() || !m_bmpWallPtr->Exists() || !m_bmpGrassPtr->Exists() || !m_bmpDirtPtr->Exists())
- {
- GAME_ENGINE->MessageBox(String("Can't load images!"));
- }
- }
- void GridNode::Delete()
- {
- delete m_bmpDirtPtr;
- delete m_bmpGrassPtr;
- delete m_bmpWallPtr;
- delete m_bmpWaterPtr;
- }
- void GridNode::Render()
- {
- switch (m_Type)
- {
- case 1:
- GAME_ENGINE->DrawBitmap(m_bmpGrassPtr, m_xPos, m_yPos);
- break;
- case 2:
- GAME_ENGINE->DrawBitmap(m_bmpDirtPtr, m_xPos, m_yPos);
- break;
- case 3:
- GAME_ENGINE->DrawBitmap(m_bmpWaterPtr, m_xPos, m_yPos);
- break;
- case 4:
- GAME_ENGINE->DrawBitmap(m_bmpWallPtr, m_xPos, m_yPos);
- break;
- case 0:
- GAME_ENGINE->FillRect(-30,-30,25,25);
- break;
- }
- }
- void GridNode::SetWalkable(bool walkable)
- {
- m_bWalkable = walkable;
- }
- void GridNode::SetPosition( int x, int y )
- {
- m_xPos = x;
- m_yPos = y;
- }
- void GridNode::SetType(int type)
- {
- m_Type = type;
- }
- int GridNode::GetType()
- {
- return m_Type;
- }
- POSITIE GridNode::GetPosition()
- {
- POSITIE temp;
- temp.x = m_xPos;
- temp.y = m_yPos;
- return temp;
- }
- bool GridNode::GetWalkable()
- {
- return m_bWalkable;
- }
- //---------------------------
- // Eigen methoden
- //---------------------------
- // vul aan met je eigen methoden.
Undefined
By: gridnode | Date: Feb 10 2010 22:52 | Format: None | Expires: never | Size: 2.21 KB | Hits: 851
Latest pastes
1 days ago
1 days ago
2 days ago
3 days ago
5 days ago