The following should help. This is written for DarkBASIC Professional, but should work in DB Classic with a few small changes (not sure which version you are using)
` ASCII Maze
set display mode 800,600,32,1
sync rate 30
sync on
player as string = "@"
wall as string = "#"
block as integer
player_x as integer = 2
player_y as integer = 2
fontsize as integer = 24
maze_width as integer = 16
maze_height as integer = 16
dim maze(maze_width, maze_height)
restore maze1
for y = 1 to maze_height
for x = 1 to maze_width
read block
maze(x,y) = block
next x
next y
set text font "Courier"
set text size fontsize
` Main Loop
do
cls 0
text 600, fontsize, "ASCII Maze"
text 600, fontsize + 80, "X:" + str$(player_x)
text 680, fontsize + 80, "Y:" + str$(player_y)
for y = 1 to maze_height
for x = 1 to maze_width
if maze(x,y) = 1
text x * fontsize, y * fontsize, wall
endif
next x
next y
text player_x * fontsize, player_y * fontsize, player
if upkey()
` Can the player move up?
if maze(player_x, player_y - 1) = 0
dec player_y
endif
endif
if downkey()
` Can the player move down?
if maze(player_x, player_y + 1) = 0
inc player_y
endif
endif
if leftkey()
` Can the player move left?
if maze(player_x - 1, player_y) = 0
dec player_x
endif
endif
if rightkey()
` Can the player move right?
if maze(player_x + 1, player_y) = 0
inc player_x
endif
endif
sync
loop
maze1:
data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
data 1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1
data 1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1
data 1,0,1,1,1,1,0,0,1,0,0,1,1,1,1,1
data 1,0,1,0,0,0,0,0,1,1,1,1,0,0,0,1
data 1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1
data 1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1
data 1,0,0,0,0,0,1,1,1,0,0,1,0,0,0,1
data 1,0,0,0,0,0,1,0,0,0,0,1,0,0,1,1
data 1,0,0,0,0,0,1,0,0,0,0,1,0,0,1,1
data 1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1
data 1,0,0,0,1,1,1,0,0,1,0,1,0,0,0,1
data 1,0,0,0,0,0,1,0,0,1,0,1,0,0,0,1
data 1,0,0,0,0,0,1,1,1,1,0,1,0,0,0,1
data 1,0,1,1,1,0,1,0,0,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
It should be pretty self-explanatory, but feel free to ask questions.
Cheers,
Rich
"Bite my shiny metal ass" (Futurama)
"Don't ping my cheese with your bandwidth" (Dilbert)