This topic is now archived and is closed to further replies.


My D3D 2D Tile System

Recommended Posts

Ok here is the definition for my tile class, that is a single tile on the map:
//--Note, GFXObjects is a class I created earlier holding D3D

//Objects to draw and such

class TILE2D : protected GFXObject
	float	cd_WorldX, cd_WorldY;				//center x,y position relative to world

	float	cd_TextureTop, cd_TextureLeft;		//Texel coordinates

	float	cd_TextureBottom, cd_TextureRight;

	long	cd_ID;								//tile ID, indicate terrain type and thus texture

	GFXVertex5			cd_Vertices[4];			//rectangle contruct vertices

	LPD3DVERTEXBUFFER	cd_pVB;					//D3D vertex buffer

	BOOL	cd_bCreated;						//status indication



	void SetPosition(float x, float y)
		cd_WorldX = x;
		cd_WorldY = y;

	void SetTexel(float Top, float Left, float Bottom, float Right)
		cd_TextureTop = Top;
		cd_TextureLeft = Left;
		cd_TextureBottom = Bottom;
		cd_TextureRight = Right;

	void SetID(long ID)
		cd_ID = ID;

	float GetY() const { return(cd_WorldY); }
	float GetX() const { return(cd_WorldX); }

	long Create();
	void Destroy();

	long Draw();

Share this post

Link to post
Share on other sites