load image "Pacman.png",1
load image "bblock.png",2
sync on
sync rate 0
pacx=320
pacy=336
pacd=3
distancex=0
distancey=0
pacmapx=20
pacmapy=21
passable=1
dim map(28,30)
`read map data and store in the map array
restore map
for j = 0 to 28
for i = 0 to 28
read map(i,j)
next i
next j
`draw the map
Sprite 1,pacx,pacy,1
set sprite 1,1,1
for x = 0 to 28
for y = 0 to 29
if map(x,y) = 1 then box x*16,y*16,(x*16)+16,(y*16)+16
if map(x,y) = 2 then circle x*16+8, y*16+8, 3
if map(x,y) = 3 then circle x*16+8, y*16+8, 6
next y
next x
Do
`exit the program
if escapekey()=1 then end
`check directions and collision
if upkey()=1 then pacd=1
if downkey()=1 then pacd=2
if leftkey()=1 then pacd=3
if rightkey()=1 then pacd=4
if map(pacmapx,pacmapy+1)<>1 then passable=1 else passable=0
if map(pacmapx,pacmapy-1)<>1 then passable=1 else passable=0
if map(pacmapx+1,pacmapy)<>1 then passable=1 else passable=0
if map(pacmapx-1,pacmapy)<>1 then passable=1 else passable=0
if pacd=1 and passable=1 then pacy=pacy-4 : distancey=distancey-4
if pacd=2 and passable=1 then pacy=pacy+4 : distancey=distancey+4
if pacd=3 and passable=1 then pacx=pacx-4 : distancex=distancex-4
if pacd=4 and passable=1 then pacx=pacx+4 : distancex=distancex+4
if distancex=16 then inc pacmapx : map(pacmapx,pacmapy)=5 : distancex=0
if distancex=-16 then dec pacmapx : map(pacmapx,pacmapy)=5 : distancex=0
if distancey=16 then inc pacmapy : map(pacmapx,pacmapy)=5 : distancey=0
if distancey=-16 then dec pacmapy : map(pacmapx,pacmapy)=5 : distancey=0
for x = 0 to 28
for y = 0 to 29
if map(x,y) = 5 then paste image 2,x*16,y*16
next y
next x
Sprite 1,pacx,pacy,1
Sync
Loop
`data for the map
map:
data 0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
data 0,0,0,0,0,0,0,0,0,1,2,2,2,2,1,2,2,2,2,2,2,2,2,1,2,2,2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
data 0,0,0,0,0,0,0,0,0,1,2,1,2,1,1,1,1,2,1,1,2,1,1,1,1,2,1,2,1
data 0,0,0,0,0,0,0,0,0,1,2,1,2,1,1,1,1,2,1,1,2,1,1,1,1,2,1,2,1
data 0,0,0,0,0,0,0,0,0,1,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,1
data 0,0,0,0,0,0,0,0,0,1,2,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,2,1
data 0,0,0,0,0,0,0,0,0,1,2,1,1,1,1,2,1,1,1,1,1,1,2,1,1,1,1,2,1
data 0,0,0,0,0,0,0,0,0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
data 0,0,0,0,0,0,0,0,0,1,2,1,1,2,1,2,1,1,1,1,1,1,2,1,2,1,1,2,1
data 0,0,0,0,0,0,0,0,0,1,3,1,1,2,1,2,1,1,1,1,1,1,2,1,2,1,1,3,1
data 0,0,0,0,0,0,0,0,0,1,2,2,2,2,1,2,2,2,2,2,2,2,2,1,2,2,2,2,1
data 0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
Here i have add your tecnique plus a few extra variable to make it work how would it chnage the passable variable back to 1 when i press the up(down,left,right) keys and the block is passable? ive tried a few thing but also when he walks right he goes strait throught the wall but not when he goes left

this bit is confusing. thanx for the help so far.