Non-tile based platform maps.

BlitzMax Forums/BlitzMax Beginners Area/Non-tile based platform maps.

allranger(Posted 2012) [#1]
I was just working on my platform game and realized that some of the stuff I want to do will not work with tile based maps. (Or I am having a brain block).

So I have my levels saved to XML files. Here is a simple one I use to test:

<?xml version="1.0"?>
<world>
<information>
<name>Grassland</name>
</information>

<section>
<columns>2</columns>
<rows>2</rows>
<location x="1" y="1">
<tile>0001</tile>
</location>
<location x="1" y="2">
<tile>0001</tile>
</location>
<location x="2" y="1">
<tile>0001</tile>
</location>
<location x="2" y="2">
<tile>0001</tile>
</location>
</section>

</world>

So in this example the map is 2 x 2. The tiles are 32 x 32.

Now the problem I am having is that some of the stuff I am starting it add is limited by the tiles, (enemies, background stuff, etc.). But I cannot figure out exactly how make my map non-tile based. What I am thinking is that I can save the object with the pixel coordinates, then when I load the map, anything that has a correct coordinate will be displayed.

Everything is loaded into a type called "TGameObject" and it has and "X" and a "Y". So I might be able to do some sort of query off that...

I don't know. Is it possible?


ImaginaryHuman(Posted 2012) [#2]
Not quite sure what you're asking but it seems like you need a way to find out where in the map a moving object is ... you basically take the objects X,Y coords and divide them by the tile width and height to find out which tile the object is over, and then use modulo to see the exact position within the tile?


Wiebo(Posted 2012) [#3]
You need a way to find out if an object is near a map object... I am using quadtrees for that in my non-tile based map. Using quadtrees you can quickly find object within a certain area (screen, player hit box, camera, etc)

Maybe you can use quadtrees as well? Take a look here : http://code.google.com/p/noisycode/wiki/quadtree


allranger(Posted 2012) [#4]
You are both kind of answering the question(s) I was asking. My problem is that I have the correct vocabulary yet. After doing some reading and experimenting let me try this again.

I currently have a tile based map. (See 1st post for an example xml file I am using to store the level map).

I am loading the map file into an array. I am creating the array based off the "columns" and "rows" part of the xml file. This has worked find until now.

This is my problem. Let's pretend I have a mario game and my tiles are bricks. I can load the bricks in and display them fine. But, how do I display non brick based objects that do not fit neatly into the array. For example, clouds, trees, enemies, the player....

I only want to display objects on the screen that are currently "on camera." That is easy for the "bricks." I can pull the data out of the array. However, I am getting stuck with the other stuff. The enemies move around so they can't really go in an my array (well, they could but their movement isn't as "blocky" as my array).

So I guess my problem is with the array and not the tile based game. Because really everything in the game is a tile I suppose.

So if I have a non-array option, it begs the question why am I using an array for the bricks anyway?

I was not aware of quadtrees. This may be a workable option for me.

So I guess my question is more along the lines of how do you have a non-array based tile map? If that makes sense. :-)


Jesse(Posted 2012) [#5]
maybe this can help you:
The Guide How to Implement 2d Platform Games