Jump to content
  • Advertisement
Sign in to follow this  
HorrorVision

Displaying Isometric Maps *solved*

This topic is 4062 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

EDIT: Ok the problem is solved, i rewrote the code and used another method. new code below, scrolling is smooth, and i think its fast enough. EDIT: I changed the code, so now it shows the real map at least if the m_mapX and m_mapY variables are 0. still the scrolling rips everything :/ Hi guys, im currently working on my first isometric engine, and im really stuck on the drawing stuff, and the more i think, the more errors i put into the code lol. Here's what i have
int IsoMap::Render(void)
{
	for (int n = 0; n < m_mapDimension.GetX() * m_mapDimension.GetY(); n ++)
	{
		if (m_map[n].GetValid())
		{
			IntPoint tilePoint = GetScreenPosition (n);
			tilePoint.SetX (tilePoint.GetX() - m_screenPosition.GetX());
			tilePoint.SetY (tilePoint.GetY() - m_screenPosition.GetY());

			if (m_viewRect.PointInRect (tilePoint.GetX(), tilePoint.GetY()) || 
				m_viewRect.PointInRect (tilePoint.GetX() + m_tileDimension.GetX(), tilePoint.GetY()) ||
				m_viewRect.PointInRect (tilePoint.GetX(), tilePoint.GetY() + m_tileDimension.GetY()) ||
				m_viewRect.PointInRect (tilePoint.GetX() + m_tileDimension.GetX(), tilePoint.GetY() + m_tileDimension.GetY()))
			{
				IsoTilesetSprite* cell = m_map [n].GetSprite ();

				cell->m_sprite->SetPosition (tilePoint.GetX(), tilePoint.GetY());
				cell->m_sprite->Render ();
			}
		}
	}
   	
	return TRUE;
}

IntPoint IsoMap::GetScreenPosition(int a_index)
{
	IntPoint screenPos;
	if (a_index > m_mapDimension.GetX() * m_mapDimension.GetY())
		return screenPos;
	
	int my = (a_index / (m_mapDimension.GetX()));
	int mx = a_index - (my * (m_mapDimension.GetX()));

	screenPos.SetX ((mx * (m_tileDimension.GetX() / 2)) - 
		(my * (m_tileDimension.GetX() / 2)));

	screenPos.SetY ((my * (m_tileDimension.GetY() / 2)) + 
		(mx * (m_tileDimension.GetY() / 2)));

	return screenPos;
}

m_mapX and m_mapY are the current positions of the map, starting with 0, they increase/decrease with a scroll function, both are float [Edited by - HorrorVision on June 9, 2007 8:48:51 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!