Page 1 of 1
Tile Engine in C# and XNA
Posted: Tue May 25, 2010 10:05 am
by epicasian
How would you attempt this?
I am thinking of doing it like this:
Load Map.txt file into an integer array, (Make each layer a different array)
Load TileStrip.png into a Texture2D,
Split each 32x32 tile, and store all the tiles into a Texture2D Tile array,
Create a dictionary that maps the integer array values to Tile array values.
Any other suggestions?
Thanks,
EpicAsian
Re: Tile Engine in C# and XNA
Posted: Tue May 25, 2010 10:14 am
by Falco Girgis
Everything sounds great except for the last part:
epicasian wrote:Create a dictionary that maps the integer array values to Tile array values.
A dictionary? Why? The integer array values should directly correspond to your tile values. Otherwise you are going to suffer a SERIOUS, unnecessary performance hit. You should be able to access a tile or object at a current level location by doing something like:
level.tileset[level.map[y][x]].solid
That should demonstrate the relationship between the map and the tile/objectsets.
Re: Tile Engine in C# and XNA
Posted: Tue May 25, 2010 10:23 am
by MrDeathNote
I wouldn't divide the tilesheet into an array of Texture2D's. That's really memory intesive. What you should really be doing is storing the bounding rectangle of each tile, so you have an array of rectangles that contain the positions of the tiles in the original texture. I'm going to be making a tutorial very soon about creating a very simple map editor and basic tile engine in XNA because i've had quite a few messages about it. They should be on youtube within 4 to 6 weeks (hopefully), i think they could help you alot.
Re: Tile Engine in C# and XNA
Posted: Tue May 25, 2010 4:01 pm
by epicasian
Thanks for the replies.
MrDeathNote: I think I'm going to try it on my own, but if I can't figure it out, I will most definitely check out your tutorial.:D
Thanks again,
EpicAsian
Re: Tile Engine in C# and XNA
Posted: Tue May 25, 2010 4:56 pm
by MrDeathNote
epicasian wrote:Thanks for the replies.
MrDeathNote: I think I'm going to try it on my own, but if I can't figure it out, I will most definitely check out your tutorial.:D
Thanks again,
EpicAsian
No problem, i think thats great if you can do it by yourself. It makes it a much better learning experience. I made my first tile engine from scratch by myself and it helped me learn a lot. Good luck with it