Cpp:Building A Simple Tile Engine:Part 3
From GDWiki
[edit] Part 3: Creating tiles
I haven't got the time to finish this article right now, so until I have here's a stub box for you to look at:
- This article is a stub. You can help out by expanding it.
[edit] File: Tile.h
#ifndef TILE_H #define TILE_H #include "Entity.h" /** Tile entity */ class CTile: public CEntity { public: CTile(); virtual ~CTile(); virtual void VThink ( const int& iElapsedTime ); virtual void VRender ( SDL_Surface* pDestSurface ); virtual bool VLoad ( TiXmlElement* pXMLData ); virtual TiXmlElement VGetSaveData(); }; #endif // TILE_H
[edit] File: Tile.cpp
#include "Tile.h" CTile::CTile() { } CTile::~CTile() { } bool CTile::VLoad( TiXmlElement* pXMLData ) { CEntity::VLoad( pXMLData ); int iTileX = atoi( pXMLData->Attribute( "x" ) ); int iTileY = atoi( pXMLData->Attribute( "y" ) ); SetTile( iTileX, iTileY ); return true; } TiXmlElement CTile::VGetSaveData() { TiXmlElement Tile( "tile" ); Tile.SetAttribute( "x", GetTileX() ); Tile.SetAttribute( "y", GetTileY() ); Tile.InsertEndChild( CEntity::VGetSaveData() ); return Tile; } void CTile::VThink( const int& iElapsedTime ) { CEntity::VThink( iElapsedTime ); } void CTile::VRender( SDL_Surface* pDestSurface ) { CEntity::VRender( pDestSurface ); }
Proceed to Part 4: Creating the tile manager
Table of Content - Part 1 - Part 2 - Part 3 - Part 4 - Part 5 - Part 6 - Part 7 - Part 8 - Part X

