[XNA] Tilemap Help?

Started by G_G, August 04, 2010, 11:07:39 pm

Previous topic - Next topic

G_G

In xna, my way of drawing a map in XNA was terrible. It looped through each line of the map, reading the tile number. Then drew it. Luckily no lag but I'm sure it was an inefficient way. Another thing, my way didn't have autotiles.

Anyone know of a tilemap class or is willing to help me get started on one? Preferably one that includes autotiles :P

winkio

I could write you the code for autotiles.  It's not hard at all.  And I made a tile engine for an xna game last fall.  I'll see if I can dig it up.

In terms of handling the actual tiles, you should have an object for each one, and you should be able to test if it's on screen as a method of that object, so each frame, you should loop through and test if each tile is on screen, and if it is, draw it.  The main advantage of objects instead of an array of numbers is that you can store more data on each tile, such as passability, terrain tag, etc.

G_G

That'd be really helpful winkio =D If you could do that, I'd also be your, well I dunno, I'm already your bitch so xD

Agckuu Coceg

I'm not retarded, but I'm busy. Sorry for patience.