Cpp:Building A Simple Tile Engine:Part 3

From GPWiki

Files:GUITutorial_warn.gif The Game Programming Wiki has moved! Files:GUITutorial_warn.gif

The wiki is now hosted by GameDev.NET at wiki.gamedev.net. All gpwiki.org content has been moved to the new server.

However, the GPWiki forums are still active! Come say hello.

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 page is far from complete, go ahead and write some more!
You can extend this page by editing it.

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 

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