Maps
Blitz3D Forums/Blitz3D Programming/Maps
| ||
Hi, Im very much a newb to the world of blitz, so im a bit stuck with maps. How do I go about making maps? I have blitz 3d, but I want to make a 2d map. I looked at blitz boulders, but it doesent really explain how to make maps. Any help would be brilliant, thanks. |
| ||
ps. Sorry if ive got this in the wrong forum! just saw the begginers forum. |
| ||
Well, i suppose you mean tile maps? Well, my way of creating a tile map would be to set up an array, say 24x24. Just an example :) dim map(24,24) Now the way this works is you have another array with all the 'tiles' in it. Small images that can be joined together to make a map. You might have say a grass tile, a wall tile, a path tile. So... dim tiles(2); to store 3 tiles in ( 0 counts too) tiles(0)=loadimage("grass.png"); load in the grass image tiles(1)=loadimage("wall.png"); load in the wall image tiles(2)=loadimage("path.png"); load in the path image Now, each image loaded in must be the same size as the last. So say each tiles(image) is 20 x 20. So, if your gonna have a tile map of 24x24 tiles, you need to make sure it all fits in the screen. width = 24*20 = 480 height= 24*20 = 480 Ok, so the tile map is gonna take up 480 pixels by 480 pixels, which is fine. Just make sure to set the resolution to something that size, like: Graphics 640,480 should do fine. Now to actually display the map, you need to know what each of the tiles in the map( , ) array are. You would do this by creating a bunch of data commands. Imagine the map size was alot smaller, say 6x6 ( in an array, it would be (5,5) ) data 0,1,1,1,1,0 data 2,2,2,2,2,2 data 0,0,0,0,0,0 data 0,0,0,0,0,0 data 0,0,0,0,0,0 data 0,0,0,0,0,0 Now, these data statements will determine what the tilemp looks like. They are read into the array MAP( , ), like so. For x=0 to 5 For y=0 to 5 read map(x,y) Next Next If you haven't grasped reading in data, you should try and learn this, very important for alot of things :) So that will read the data contents into the array. As you can see by looking at the data statements, the top of the map will have some wall tiles in it, as the wall tile is stored as tiles(1). tiles(2) is the path tile. You basically draw the whole contents of the array onto the screen: For x=0 to 5 For y=0 to 5 DrawImage tiles( map(x,y) ), x*20 , y*20 Next Next The drawimage part: Tiles is the array where the actual tile images are held. So in the Map array are the tile numbers to be drawn. So if x=1 and y=0 then the contents of Map(x,y)>>>Map(1,0)=1 (refer back to the data statement to check :) ) so that means, tiles( map(x,y) ) >>tiles( map(1,0) ) >>tiles( 1) so draw tiles(1), which is the wall tile :) x*20, is the width of each tile. This is so, the tiles are doisplayed correctly regarding their width. Same with height. That's what i know about tiles maps anyway :) When you get better at them, you can code your own editor, to take the pain away from using data statements. Well, hope i explained it a bit :) |
| ||
Thankyou so much! its works a treat :). |
| ||
Np, i'm saving that infact, incase i get stuck :D |
| ||
Check out Mappy. http://www.geocities.com/SiliconValley/Vista/7336/robmpy.htm cb |