2D map, drawing objects C# / XNA

Started by
11 comments, last by MadHaTr 16 years, 3 months ago
Bump
Advertisement
I am making a side scroller at the moment and this is what I have done.

Everything that is going to be drawn has a mapPosition property, that is there position on the map relative to the top left corner of the map.

The player also has a screenPosition property. This will never change since the player is always in the middle of the window.

When I am drawing something to the screen I test if its mapPosition is less than the screen width and height away from the players mapPosition, if it is I draw it to the screen. Then I draw it like this:

spriteBatch.Draw(spriteBatch, object.mapPosition + (player.screenPosition - player.mapPosition), Color.White);

That will draw it to the correct position on the screen.

I hope that makes sense.
awesty - I've PM'd you about some things.

Also I need people to review my class. If you look at my class and the method in my main code you can see that if I add or remove any airports it is very time consuming. Not very effecient at all. Also I need help with the drawing mechanism, it as well is not very effiencent. If I add a new airport I need to add all this new code to draw it. So i need help makeing my gameobjects class work better with my drawing method.

This topic is closed to new replies.

Advertisement