Okay, a example to look over and learn from... Heh, its my very first time I wrote one, yea! Sorry if it looks like half a raycaster, it works partly like one, just w/o the ray casting...
[syntax="qbasic"]SCREEN 13
CLS 'Clear the screen
DIM map(10, 10) 'Create Map Array
' Load Map DATA into array..
' When over given points like map(1, 1) = 4, and map(2, 2) = 3.. esc
FOR y = 1 TO 10
FOR x = 1 TO 10
READ z
IF z = -1 THEN x1 = x: y1 = y: z = 0 ' Find players position.
map(x, y) = z 'Pack all our Map info into array.
NEXT
NEXT
DO ' Start main LOOP
press$ = INKEY$ ' Promt keys
' Display Map on screen..
FOR y = 1 TO 10
FOR x = 1 TO 10
' Diff numers equal diff tiles, and there location is strored in
' Map(x, y).. Just remember LOCATE is backward Y, X..
' We assign color acording to how we want it displayed
' CHR$(219) equals a "Ã".. You can just hold Alt and type in 219
' When you there-after release Alt it gives you that character
IF map(x, y) = 0 THEN COLOR 6: LOCATE y, x: PRINT CHR$(219) 'Dirt
IF map(x, y) = 2 THEN COLOR 2: LOCATE y, x: PRINT CHR$(219) 'Grass
IF map(x, y) = 3 THEN COLOR 9: LOCATE y, x: PRINT CHR$(219) 'Water
IF map(x, y) = 4 THEN COLOR 7: LOCATE y, x: PRINT CHR$(219) 'Wall
NEXT
NEXT
IF press$ = CHR$(0) + "H" THEN ' On Keypress Up Arrow...
y1 = y1 - 1 ' Move player Up screen..
' Check for walls or water, both are 3 or greater..
IF map(x1, y1) >= 3 THEN y1 = y1 + 1
ELSEIF press$ = CHR$(0) + "P" THEN
' Move player down, also check, we have a door at the bottom
' We need to stall player sence there is no map info
' You can use this to call a new Map
y1 = y1 + 1: IF y1 > 10 THEN y1 = 10: LOCATE 12, 1: PRINT "Can't Pass! No Map down there!"
' Check for walls or water, both are 3 or greater..
IF map(x1, y1) >= 3 THEN y1 = y1 - 1
ELSEIF press$ = CHR$(0) + "M" THEN
' Move player right, also check, we have a door at the right
' We need to stall player sence there is no map info
' You can use this to call a new Map
x1 = x1 + 1: IF x1 > 10 THEN x1 = 10: LOCATE 12, 1: PRINT "Can't Pass! No Map over there!"
' Check for walls or water, both are 3 or greater..
IF map(x1, y1) >= 3 THEN x1 = x1 - 1
ELSEIF press$ = CHR$(0) + "K" THEN
x1 = x1 - 1 ' Move player left
' Check for walls or water, both are 3 or greater..
IF map(x1, y1) >= 3 THEN x1 = x1 + 1
END IF
' Display player on screen. Make sure you do this after you've
' checked for movement and barriers.. Like above ^^ ^^
LOCATE y1, x1: PRINT CHR$(1)
' Video Buffer
WAIT &H3DA, 8
' Helps Video Buffer
FOR I = 1 TO 1000: NEXT
LOOP UNTIL press$ = CHR$(27)' Loop until KeyPress = Esc
'------------Map!-------------
'[[ Notes ]]
'Notice I put the unpassible DATA ander numbers all higher than 2
'This way I can check for barriers in one line of code for each
'way your alowed to move.. Up, Down, Left, & Right.. so four times..
'Compare to about 8 times if they were random... Look up there where
'I checked for barriers to see what I'm on..
' This can be any number, if you have 8 passible objects, then make every
' thing higher than 8 the unpassible ones.. See where I'm at..
' IF map(x, y) >= 9 THEN ... block player for that direction..
'[[ Map ]]
'[[ Key ]]
'-1 = Player's position
'0 = Dirt
'2 = Grass
'3 = Water
'4 = Wall
DATA 4,4,4,4,4,4,4,4,4,4
DATA 4,3,3,3,3,3,2,4,0,4
DATA 4,2,3,3,3,2,2,4,0,4
DATA 4,2,2,2,2,2,2,4,0,4
DATA 4,0,2,2,2,2,0,4,0,0
DATA 4,0,0,0,0,0,0,0,0,0
DATA 4,0,0,0,-1,0,0,4,0,4
DATA 4,0,4,4,4,4,4,4,0,4
DATA 4,0,0,0,0,0,0,4,0,4
DATA 4,4,4,4,4,0,0,4,4,4[/syntax]
Enjoy!!! :wink: