その他、多少のバグを修正して、完成したものを貼っておきます。
;擬似三次元迷路
;迷路作成
g = 14
ox=200
oy=120
dim m,16,16
;三次元迷路の表示のための配列変数
dim wx,8
dim wy,8
dim dx,4
dim dy,4
dim lx,4
dim ly,4
dim rx,4
dim ry,4
dim dd,4
dim dl,4
dim dr,4
wx(0)=200:wy(0)=120
for n,1,7,1
wx(n)=150/(n*2-1)
wy(n)=90/(n*2-1)
next
dx(0) = 0:dy(0) = -1
dx(1) = 0:dy(1) = 1
dx(2) = -1:dy(2) = 0
dx(3) = 1:dy(3) = 0
lx(0) = -1:ly(0) = 0
lx(1) = 1:ly(1) = 0
lx(2) = 0:ly(2) = 1
lx(3) = 0:ly(3) = -1
rx(0) = 1:ry(0) = 0
rx(1) = -1:ry(1) = 0
rx(2) = 0:ry(2) = -1
rx(3) = 0:ry(3) = 1
dd(0) = 1:dd(1) = 0:dd(2) = 3:dd(3) = 2
dl(0) = 2:dl(1) = 3:dl(2) = 1:dl(3) = 0
dr(0) = 3:dr(1) = 2:dr(2) = 0:dr(3) = 1
;外枠
for i,0,15
m(0,i) = 1
m(i,0) = 1
m(14,i) = 1
m(i,14) = 1
next
;プレイヤーの向きは最初は右
pd = 3
;迷路を作る
for y,2,14,2
for x,2,14,2
m(x,y)=1
*taosu
r=rnd(4)
if r=0 and y=2:x2=x:y2=y-1
if r=1:x2=x:y2=y+1
if r=2:x2=x-1:y2=y
if r=3:x2=x+1:y2=y
if m(x2,y2)=1:goto *taosu
m(x2,y2)=1
next
next
;---プレイヤーを動かす---
px = 1
py = 1
m(px,py)=2
gosub *display1
gosub *display2
repeat
repeat
getkey k0, 27: getkey k1,37 :getkey k2,38 :getkey k3,39 :getkey k4,40
if k0=1:goto *end_
if k2=1:gosub *up:break
if k4=1:gosub *down:break
if k1=1:gosub *left:break
if k3=1:gosub *right:break
await(8)
loop
gosub *display1
gosub *display2
repeat
getkey k1,37 :getkey k2,38 :getkey k3,39 :getkey k4,40
if k1=0 and k2=0 and k3=0 and k4=0:break
await(8)
loop
await(8)
loop
*end_
end
*up
nx = px + dx(pd):ny = py + dy(pd)
if m(nx,ny)>0:return
m(px,py) = 0
px = nx:py = ny
m(px,py) = 2
return
*down
pd = dd(pd)
return
*left
pd = dl(pd)
return
*right
pd = dr(pd)
return
*display1
cls 0
for y,0,16,1
for x,0,16,1
if m(x,y)=1:pos x*g+400,y*g:mes "■"
if m(x,y)=2:pos x*g+400,y*g:mes "@@"
next
next
return
*display2
cx = px:cy = py
for n,0,6,1
color 0,0,0
x1 = cx + lx(pd):y1 = cy + ly(pd)
c1 = m(x1,y1)
if c1=0{
gosub *lmichi
}
else {
gosub *lkabe
}
x2 = cx + rx(pd):y2 = cy + ry(pd)
c2 = m(x2,y2)
if c2=0{
gosub *rmichi
}else{
gosub *rkabe
}
cx = cx + dx(pd):cy = cy + dy(pd)
c3 = m(cx,cy)
if c3>0:gosub *ikidomari:n=6
next
return
*ikidomari
color 0,0,0
if c1=0:color 255,255,255
line ox-wx(n+1), oy-wy(n+1), ox-wx(n+1), oy+wy(n+1)
color 0,0,0
if c2=0:color 255,255,255
line ox+wx(n+1), oy-wy(n+1), ox+wx(n+1), oy+wy(n+1)
color 0,0,0
line ox-wx(n+1), oy-wy(n+1), ox+wx(n+1), oy-wy(n+1)
line ox-wx(n+1), oy+wy(n+1), ox+wx(n+1), oy+wy(n+1)
return
*lmichi
color 0,0,0
line ox-wx(n+1), oy-wy(n+1), ox-wx(n+1), oy+wy(n+1)
line ox-wx(n), oy-wy(n+1), ox-wx(n+1), oy-wy(n+1)
line ox-wx(n), oy+wy(n+1), ox-wx(n+1), oy+wy(n+1)
if n=0:return
line ox-wx(n), oy-wy(n), ox-wx(n), oy+wy(n)
return
*lkabe
color 0,0,0
line ox-wx(n), oy-wy(n), ox-wx(n+1), oy-wy(n+1)
line ox-wx(n), oy+wy(n), ox-wx(n+1), oy+wy(n+1)
return
*rmichi
color 0,0,0
line ox+wx(n+1), oy-wy(n+1), ox+wx(n+1), oy+wy(n+1)
line ox+wx(n), oy-wy(n+1), ox+wx(n+1), oy-wy(n+1)
line ox+wx(n), oy+wy(n+1), ox+wx(n+1), oy+wy(n+1)
if n=0:return
line ox+wx(n), oy-wy(n), ox+wx(n), oy+wy(n)
return
*rkabe
color 0,0,0
line ox+wx(n), oy-wy(n), ox+wx(n+1), oy-wy(n+1)
line ox+wx(n), oy+wy(n), ox+wx(n+1), oy+wy(n+1)
return