I'm not sure this is what you want, but here's an example on how to do collision detection on a simple tile map:
#Include "fbgfx.bi"
Declare Function Collision(x As Integer, y As Integer) As Integer
'A variable to hold some tiles
Dim As FB.IMAGE Ptr Tile(1)
'An array to hold the tile map
Dim Shared As Integer Map(9, 9)
'Setup a small GFX window
ScreenRes 320, 240, 32
'Create a couple of tiles
Tile(0) = ImageCreate(20, 20, RGB(192, 192, 192))
Tile(1) = ImageCreate(20, 20, RGB(45, 45, 45))
'Copy the map data into the Map array
Restore TileMap
For y As Integer = 0 To 9
For x As Integer = 0 To 9
Read Map(x, y)
Next
Next
'Create some needed variables
Dim As Integer Quit, PutX, PutY, PlayerX = 30, PlayerY = 30
'The main loop
Do
'Get some keyboard input, and move the player
If MultiKey(FB.SC_ESCAPE) Then Quit = -1
If MultiKey(FB.SC_UP) Then
If Not Collision(PlayerX, PlayerY - 1) Then PlayerY -= 1
End If
If MultiKey(FB.SC_DOWN) Then
If Not Collision(PlayerX, PlayerY + 1) Then PlayerY += 1
End If
If MultiKey(FB.SC_LEFT) Then
If Not Collision(PlayerX - 1, PlayerY) Then PlayerX -= 1
End If
If MultiKey(FB.SC_RIGHT) Then
If Not Collision(PlayerX + 1, PlayerY) Then PlayerX += 1
End If
'Draw the tile map
ScreenLock
PutY = 0
For y As Integer = 0 To 9
PutX = 0
For x As Integer = 0 To 9
Put (PutX, PutY), Tile(Map(x, y)), PSet
PutX += 20
Next
PutY += 20
Next
'Draw the "player"
PSet (PlayerX, PlayerY), RGB(255, 255, 255)
'Sync the drawing to the monitors refressrate
ScreenSync
ScreenUnLock
Loop Until Quit
'The collison check function
Function Collision(x As Integer, y As Integer) As Integer
Dim As Integer MapX, MapY
'Tile widht and height = 20
MapX = x \ 20
MapY = y \ 20
If Map(MapX, MapY) = 1 Then
Return -1
Else
Return 0
End If
End Function
TileMap:
Data 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
Data 1, 0, 0, 0, 0, 0, 0, 0, 0, 1
Data 1, 0, 0, 0, 0, 0, 0, 0, 0, 1
Data 1, 0, 0, 0, 0, 0, 0, 0, 0, 1
Data 1, 0, 0, 1, 1, 0, 0, 0, 0, 1
Data 1, 0, 0, 0, 0, 0, 0, 0, 0, 1
Data 1, 0, 0, 0, 0, 0, 0, 0, 0, 1
Data 1, 0, 0, 0, 0, 0, 0, 0, 0, 1
Data 1, 0, 0, 0, 0, 0, 0, 0, 0, 1
Data 1, 1, 1, 1, 1, 1, 1, 1, 1, 1