Tile-course making

BlitzMax Forums/BlitzMax Beginners Area/Tile-course making

Zacho(Posted 2011) [#1]
I found this cool example via a link posted by someone in the forums. Here it is: http://home.cmit.net/rwolbeck/programmingtutorial/code/2D%20platformer.htm

Its great and all but it seems to be written in BB, not BMax. In addition to that, some functions aren't functions in BMax (Dim, Data, etc) but my question isnt that. My (two) questions are; how do arrays work and how can I mimic the example in creating levels using tiles?

I haven't used an array before either, or whatever the Data command in the example translates to in Bmax


Zacho(Posted 2011) [#2]
I did some searching in the IDE and found DefData (defines data) and read data....
I am assuming Bmax uses these.

The example I found was in the tempest.exe file in the IDE. its a bit complicated for me so I am trying to look at it. It looks like DefData is called (with other code) when the "S" key is hit.

The data itself looks like:
DefData 0,0, 7,-5, 6,-8, 9,-10, 7,-13, 11,-15
DefData 0,0, 6,3, 6,6, 10,4, 12,4, 13,12
DefData 0,0, 2,7, -4,10, 1,14, -4,17, 1,20
DefData 0,0, -7,4, -7,1, -9,1, -11,6, -14,8
DefData 0,0, -4,-5, -3,-10, -5,-13, -9,-13, -9,-15


When ReadData is called, it is called in two separate functions, ReadLevelData () and ReadFuseballData().

ReadData x
ReadData y

'and

ReadData v


I am guessing for a tile-based thing I have to do something like:

DefData 0 'sky
DefData 1 'block
DefData 2 'etc
DefData 0,0,0,0,0,0,0,0,0,0,0,0,0,0
DefData 0,0,0,0,0,0,0,0,0,1,1,1,1,0
DefData 0,0,0,0,1,1,1,0,0,0,0,0,0,0
DefData 0,0,0,0,0,0,0,0,0,0,0,0,0,0
DefData 1,1,1,1,1,1,1,1,1,1,1,1,1,1

Right? Then somehow link DefData 0 = sky image

and again in my program link DefData = 1 Block and add some collision detection to the block? Right?


Zacho(Posted 2011) [#3]
Change my question, I figured out how to make a map with Mappy, how do I import that so I can use in-game and figure out collision detection?


Kryzon(Posted 2011) [#4]
I think you underestimate your own resourcefulness.
Mappy must export some sort of tile map, so you need to load it with BlitzMax's commands for stream I\O ("I\O" stands for "Input\Output"), such as ReadFile(), ReadLine() etc. All the available commands are listed Here.

To do this right, not only do you need to educate yourself on these commands, but also on the Mappy file's specification (to know how the data is formatted, in what order you're going to read it).
Then interpret the information contained within the map file appropriately: populate your map array with the right tiles etc.


Zacho(Posted 2011) [#5]
I decided against mappy, i went with tile studio and I know how to make the maps and import the code but am looking for a solution to use the code to make a picture :o hehe. ill look into it


Kryzon(Posted 2011) [#6]
Tile-Studio looks like a very neat piece of software.
It seems there's a BlitzMax library for loading its maps - check the "Examples" section down the homepage, it's the first entry. You could use that as reference.


Zacho(Posted 2011) [#7]
There is a trojan in the application in the bmax demo zip file if your wondering, no worries :/

I will look at it a bit tonight and tomorrow and see what I can piece together, thanks!