Blitz2D Newbies: Making simple maps using the Data function
by Erebel55

Hello again everyone this is just my second tutorial and I hope it will help you. In this tutorial we will be covering how to make a map by using the Data function and tiles. You will have to make your own tiles because I uploaded them by using the uploader provided and the links didnt work. So just make like different color squares in paint. I dont take credit for this code im just passing it on to you guess. Radiumgames and javabean2 put it together for me. Thanks guys. Ok now i will go threw the code step by step even though its pretty simple. First I will set the graphics mode and set the buffer to backbuffer so it will be ready to flip.


Next I will set the arrow keys to there scancodes in a constant function.


Next I will load all of the tiles I will be using in this tutorial.


Next I will call all the variables and dimension the map. The offsetx and the offsety are for scrolling purposes only.


Here is the part of the code that does the actual work of loading the map data.


Next we will be putting in the main loop,handle the scrolling,and drawing all the tiles.


Lastly here is the actual data so it tells the computer were to place the tiles. w = snow, and d = dirt.


If you want to change the size of your map you must first change the maplength and mapheight variables then you must change how many letters are across in the data function and how many are up and down. Like say we wanted a map 10 by 10. Then we would have to change maplength to 9 and mapheight to 9 because the computer always starts counting at 0. Then you would have to do the data code like this.


Then you have your 10 by 10 code if you follow the other steps i have in my code above. That is it for this tutorial have fun messing around with it because that is always the best way to learn. The example source is listed below.



For a printable copy of this article, please click HERE.


This site is Copyright© 2000-2004, BlitzCoder. All rights reserved.