Archived

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

OB1st

MapX = XPos / m_Tiles->GetWidth(0);

Recommended Posts

MapX = XPos / m_Tiles->GetWidth(0); This is from prog RPG book. This is a single line of code from cMap class of chapter 11. m_tiles is a member of type cTiles. GetWidth(0) returns the width of the tile. My question is why passing a(0) rather than a variable? Does it mean that the tile width is the same for all the tiles we intend to draw. Sorry for not being able to explain the question any better, otherwise the question will be long and I have to post lots of code. Thanks

Share this post


Link to post
Share on other sites
you say that GetWidth(0) returns the width of the tile,

if that is so then why does it need input ''0'' at all?

find out what the parameter is for, and you will find out why it is always 0 :-)


Raymond Jacobs,
Profesional Web Applications Developer,
Weekend Game Developer,
www.EtherealDarkness.com

Share this post


Link to post
Share on other sites
The parameter of that function is the texture number to check. The cTiles class allows multiple textures to be loaded, but the cMap class only uses the first one, so it always checks texture 0.

Share this post


Link to post
Share on other sites