loading tiles with type
Blitz3D Forums/Blitz3D Beginners Area/loading tiles with type
| ||
Hi, Hope someone can help? I am doing a 2d break out type of game in blitz3d, and I have used an array to load my bricks, all works well. my problem is, I want to use a type to load the graphic tiles, I am using, Data 0,0,0,0,0 and so on to load the tiles, I do not want to change this if possible as I have the levels finished. I have used some Ideas from another post in the the forums. ;setup the TypeArray. Dim MapArray.TTile(ScreenWidth_For_Tiles,ScreenHeight_For_Tiles) ; made this to fit the screen resolution ;My level data Data 0,0,0,0,0,0,0 and so on Type TTile Field frame[8] Field x Field y End Type For y = 0 To ScreenWidth_For_Tiles For x = 0 To ScreenHeight_For_Tiles MapArray(x,y)=New TTile Next Next in my main loop this DrawImage TileSet_Level_one,MapArray(x,y) this does not work at all, could somone help me thanks. |
| ||
Hmm. I don't know why you want to use a type for the graphic files. Are you loading a graphic for every individual tile or just have a pointer in each array entry to the graphic? |
| ||
thanks for the reply Enay yes I am using individual tiles. well I made a grid using Data 0,1,0,2,3 loaded them in to array map(x,y) I wanted to do it with Types, because I do not know how to remove a block, from an array, when the ball hits the tile. thought this was easy in the types ie. ( delete t ) for example. I also have other types in the program my Bat,ball and so on. this would make Collision questions easy. |
| ||
BTW to remove data from an array just do Dim array(20) for the full array or array(7) = 0 for one element in the array |
| ||
> I wanted to do it with Types, because I do not > know how to remove a block, from an array, when > the ball hits the tile. Well you don't need to remove it from the array to delete it. Just disable it. Use flags. For example when a ball hits a block turn the flag off. If a tile doesn't exist then that level starts with a flag off. So basically your level will be like a set of lights, they just get turned off when they are hit by a ball. Do something like this:- Graphics 640,480,16,2 SeedRnd MilliSecs() ; 16x16 grid then data/flag (0/1) as third entry Dim grid(15,15,1) For row = 0 To 15 For column = 0 To 15 ; Fill each tile up with random info grid(row,column,0)=Rand(0,9) ; Turn each flag on or off randomly grid(row,column,1)=Rand(0,1) Next Next Repeat ; Flag check For row = 0 To 15 For column = 0 To 15 ; Is the flag on? If grid(row,column,1)=1 Then ; If so then draw it Color 0,Rand(100,255),0 Rect (row*16),(column*16),16,16,1 EndIf Next Next ; Draw all the data For row = 0 To 15 For column = 0 To 15 Color 255,255,255 ; This proves the data is still there even if the tile isn't drawn Text 4+(row*16),4+(column*16),grid(row,column,0) Next Next Until KeyDown(1) |