This might not be what you are looking for, but it does demonstrate collision checking in a grid based system.
// Project: movement test
// Created: 2015-12-08
// set window properties
SetWindowTitle( "movement test 1" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
// An array to hold the floor and wall strings.
Tile$ as string[10]
// I'm generating the floor and walls here
// but you can load them from a file if needed.
// If you load them from a file, you don't even
// have to use this array, just the integer array.
Tile$[1] = "##########"
Tile$[2] = "#........#"
Tile$[3] = "#.######.#"
Tile$[4] = "#.#....#.#"
Tile$[5] = "#.#....#.#"
Tile$[6] = "#.##.###.#"
Tile$[7] = "#........#"
Tile$[8] = "#........#"
Tile$[9] = "#........#"
Tile$[10] = "##########"
// This array holds the actual data for the floor/walls.
Tile as integer[10,10]
// This array holds the sprite ID number for each sprite.
// If you are using 3D objects, or some other method to
// display the walls and floor, you would change this.
SpriteID as integer[10,10]
// Here we transfer the string data to the integer array,
// and create sprites to show the floor and walls.
for y = 1 to 10
for x = 1 to 10
// Get the data from each character and
// store it in the Tile array - 0 for floor, 1 for wall,
// but you can use many other types of terrain.
a$ = mid(Tile$[y],x,1)
select a$
case "#"
Tile[y,x] = 1
endcase
case "."
Tile[y,x] = 0
endcase
case default
endcase
endselect
// Make a sprite for each tile, size it,
// color it, and put it on the screen.
SpriteID[y,x] = CreateSprite(0)
SetSpriteSize(SpriteID[y,x], 64, 64)
SetSpritePositionByOffset(SpriteID[y,x], 150 + (x * 64), 25 + (y * 64))
if Tile[y,x] = 1 then SetSpriteColor(SpriteID[y,x], 150, 150, 150,255)
next x
next y
// Player starting position.
PlayerY = 8
PlayerX = 5
// Make a sprite for the player and put it on the starting position floor tile.
PlayerSprite = CreateSprite(0)
SetSpriteSize(PlayerSprite, 44, 44)
SetSpriteColor(PlayerSprite, 255, 0, 0, 255)
SetSpritePositionByOffset(PlayerSprite, 150 + (PlayerX * 64), 25 + (PlayerY * 64))
// Main program loop.
do
// Check chosen direction to see if there is floor there.
// If so, move the player sprite in that direction.
if GetRawKeyState(37) // left arrow is pressed
if Tile[PlayerY, PlayerX - 1] = 0
for x = 1 to 32
SetSpritePositionByOffset(PlayerSprite, GetSpriteXByOffset(PlayerSprite) - 2, GetSpriteYByOffset(PlayerSprite))
sync()
next x
PlayerX = PlayerX - 1
endif
endif
if GetRawKeyState(39) // right arrow is pressed
if Tile[PlayerY, PlayerX + 1] = 0
for x = 1 to 32
SetSpritePositionByOffset(PlayerSprite, GetSpriteXByOffset(PlayerSprite) + 2, GetSpriteYByOffset(PlayerSprite))
sync()
next x
PlayerX = PlayerX + 1
endif
endif
if GetRawKeyState(38) // up arrow is pressed
if Tile[PlayerY - 1, PlayerX] = 0
for x = 1 to 32
SetSpritePositionByOffset(PlayerSprite, GetSpriteXByOffset(PlayerSprite), GetSpriteYByOffset(PlayerSprite) - 2)
sync()
next x
PlayerY = PlayerY - 1
endif
endif
if GetRawKeyState(40) // down arrow is pressed
if Tile[PlayerY + 1, PlayerX] = 0
for x = 1 to 32
SetSpritePositionByOffset(PlayerSprite, GetSpriteXByOffset(PlayerSprite), GetSpriteYByOffset(PlayerSprite) + 2)
sync()
next x
PlayerY = PlayerY + 1
endif
endif
Sync()
loop
No media needed, very basic, with comments.