Hi, i've been working on tile coding for a while and came accross some old code that i had from previous attemps, the problem is i do not under stand how the tiling works. like how the use of the data command sets the tile used etc. i need to know this because i'm trying to add a player but dont know how to identify the specific tile being used for collision or to destroy a tile when i player touches it:
.map
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;Set Up Graphics Mode
Graphics 640,480,32,2
SetBuffer BackBuffer()
;Find and print the maximum tiles that can be displayed on screen
maxtilesx = GraphicsWidth() / 32
maxtilesy = GraphicsHeight() / 32
Print maxtilesx
Print maxtilesy
Restore map
Dim tiles(maxtilesx, maxtilesy)
For y=0 To maxtilesy-1
For x=0 To maxtilesx-1
Read tiles(x, y)
Next
Next
Tileset=LoadAnimImage("boxes.bmp",32,32,0,5)
While Not KeyHit(1)
Cls
For y=0 To maxtilesy-1
For x=0 To maxtilesx-1
DrawImage tileset,x*32,y*32,tiles(x,y)
Next
Next
Color 0,0,0
Text 0,0, "tile x: " + (MouseX()/32+1)
Text 0,10, "tile y: " + (MouseY()/32+1)
Flip
Wend
End
Can anyone explain this to me please.
.map
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0
Data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;Set Up Graphics Mode
Graphics 640,480,32,2
SetBuffer BackBuffer()
;Find and print the maximum tiles that can be displayed on screen
maxtilesx = GraphicsWidth() / 32
maxtilesy = GraphicsHeight() / 32
Print maxtilesx
Print maxtilesy
Restore map
Dim tiles(maxtilesx, maxtilesy)
For y=0 To maxtilesy-1
For x=0 To maxtilesx-1
Read tiles(x, y)
Next
Next
Tileset=LoadAnimImage("boxes.bmp",32,32,0,5)
While Not KeyHit(1)
Cls
For y=0 To maxtilesy-1
For x=0 To maxtilesx-1
DrawImage tileset,x*32,y*32,tiles(x,y)
Next
Next
Color 0,0,0
Text 0,0, "tile x: " + (MouseX()/32+1)
Text 0,10, "tile y: " + (MouseY()/32+1)
Flip
Wend
End
Can anyone explain this to me please.