REM 全局变量说明
common shared k
common shared a
dim shared da(29,17)
REM 子程序说明
declare sub weapon(wx,wy)
declare sub testkey(kx,ky,max)
declare sub direction()
declare sub win()
declare sub third()
declare sub loaddata()
declare sub runend()
REM 类型:子程序
REM 说明:加载数据
REM 输入:无
REM 输出:无
sub loaddata()
const load(539)={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,0,\
0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,1,0,0,1,3,1,0,0,1,0,0,0,1,1,0,1,0,1,0,1,0,0,1,0,1,0,1,1,1,0,0,0,1,1,0,0,0,0,1,0,1,0,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,0,1,0,1,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,0,1,0,\
0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,1,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
cls
sysprtstrg(32,24,"LOAD DATA...")
sysprtstrg(52,56,"WAIT...")
box(29,42,130,53)
REM 数据赋值,同时显示进度条,就是选择了“内置地图”时出现的画面
c=0
for a=0 to 17
for b=0 to 29
da(b,a)=load(c)
c=c+1
fillrect(28,42,29+c/6,53)
next b
next a
cls
end sub
REM 刚运行程序时的显示
10 cls
b1$="魔幻 迷宫"
for a=1 to 6
b2$=""
strncat(b2$,b1$,2*a)
locate(3,5):print b2$
for b=1 to 30 '这个循环起延时作用
next b
next a
for a=64 to 95
line(a,16,a,23)
line(a,56,a,63)
next a
for a=68 to 75
line(a,16,a,63)
line(a+16,16,a+16,63)
next a
locate(6,4):print "程序:Cool&Easy"
lcdreverse(0,0,158,95)
k=getkey()
20 cls
sysprtstrg(36,32,"开始游戏")
sysprtstrg(36,48,"编辑地图")
sysprtstrg(36,64,"游戏说明")
sysprtstrg(56,11,"主界面")
box(33,8,126,82)
box(31,6,128,84)
box(30,5,129,85)
line(33,30,126,30)
testkey(108,32,3) '进入选择驱动
if k=113 then '按了[Q]键
runend() '显示结束画面
else if k=13 then
if a=1 then goto 30 '选择了[开始游戏]
if a=2 then goto 50 '[编辑地图]
if a=3 then direction() '[游戏说明]
end if
goto 20
REM 地图选择部分
30 cls
sysprtstrg(48,13,"地图选择")
sysprtstrg(36,34,"游戏地图")
sysprtstrg(36,50,"自制地图")
box(33,10,126,68)
box(31,8,128,70)
box(30,7,129,71)
line(33,31,126,31)
testkey(108,34,2) '进入选择驱动
if k=113 then '按了[Q]键
goto 20
else if k=13 then
if a=1 then '选择了[游戏地图]
loaddata()
goto 40
else if a=2 then '[自制地图]
goto 40
end if
end if
goto 30
REM 难度选择部分
40 cls
sysprtstrg(48,13,"难度选择")
sysprtstrg(36,34,"EasyGame")
sysprtstrg(36,50,"HardGame")
box(33,10,126,68)
box(31,8,128,70)
box(30,7,129,71)
line(33,31,126,31)
testkey(108,34,2) '进入选择驱动
if k=113 then '按了[Q]键
goto 30
else if k=13 then
if a=1 then '选择了[EasyGame]
goto 60
else if a=2 then '[HardGame]
third() '进入[HardGame]的驱动
goto 40
end if
end if
goto 40
REM 选择了[编辑地图]出现的画面
50 cls
sysprtstrg(36,24,"正在设置...")
box(29,42,130,53)
sysprtstrg(24,56,"0 %")
sysprtstrg(64,56,"Complete!")
REM 将地图数组的每一个成员都赋0值,并显示进度条
c=0
for a=0 to 29
for b=0 to 17
da(a,b)=0
c=c+1
fillrect(29,42,29+c/6,53)
sysprtstrg(24,56,c/6)
next b
next a
REM 编辑地图时出现的画面
cls
fillrect(0,0,157,2)
fillrect(0,0,3,95)
fillrect(0,93,157,95)
fillrect(154,0,157,95)
x=4
y=3
lcdreverse(x+1,y+1,x+3,y+3)
51 k=getkey()
lcdreverse(x+1,y+1,x+3,y+3)
ha=(x+1)/5-1
hb=(y+2)/5-1
if k=128 then
if y>3 then y=y-5
else if k=129 then
if y<88 then y=y+5
else if k=131 then
if x>4 then x=x-5
else if k=130 then
if x<149 then x=x+5
else if k=106 then
clspart(x,y,x+4,y+4)
fillrect(x,y,x+3,y+3)
da(ha,hb)=1
else if k=107 then
clspart(x,y,x+4,y+4)
line(x+1,y,x+1,y+4)
line(x+2,y+1,x+2,y+2)
pset(x+3,y+2,1)
da(ha,hb)=3
else if k=108 then
clspart(x,y,x+4,y+4)
da(ha,hb)=0
else if k=113 then
da(29,17)=0
goto 20
end if
lcdreverse(x+1,y+1,x+3,y+3)
goto 51
60 cls
sysprtstrg(28,40,"正在画地图...")
box(25,37,135,58)
line(23,39,23,60)
line(23,60,133,60)
pset(24,38,1)
pset(24,59,1)
pset(134,59,1)
fillrect(0,0,157,2)
fillrect(0,93,157,95)
fillrect(0,0,3,95)
fillrect(154,0,157,95)
for b=0 to 5
for c=0 to 29
ba=(c+1)*5-1
bb=(b+1)*5-2
if da(c,b)=1 then
fillrect(ba,bb,ba+3,bb+3)
else if da(c,b)=3 then
line(ba+1,bb,ba+1,bb+4)
line(ba+2,bb+1,ba+2,bb+2)
pset(ba+3,bb+2,1)
end if
next c
next b
clspart(22,36,136,61)
for b=6 to 17
for c=0 to 29
ba=(c+1)*5-1
bb=(b+1)*5-2
if da(c,b)=1 then
fillrect(ba,bb,ba+3,bb+3)
else if da(c,b)=3 then
line(ba+1,bb,ba+1,bb+4)
line(ba+2,bb+1,ba+2,bb+2)
pset(ba+3,bb+2,1)
end if
next c
next b
x=149
y=88
fillcircle(x+2,y+2,2)
61 k=getkey()
clspart(x,y,x+4,y+4)
if k=128 then
if y>3 then y=y-5
else if k=129 then
if y<88 then y=y+5
else if k=131 then
if x>4 then x=x-5
else if k=130 then
if x<149 then x=x+5
else if k=113 then
goto 40
end if
ha=(x+1)/5-1
hb=(y+2)/5-1
if da(ha,hb)=1 then
if k=128 then y=y+5
if k=129 then y=y-5
if k=131 then x=x+5
if k=130 then x=x-5
else if da(ha,hb)=3 then
win()
goto 20
end if
fillcircle(x+2,y+2,2)
goto 61
sub weapon(wx,wy)
line(wx,wy,wx+2,wy+2)
line(wx+2,wy+3,wx+4,wy+5)
line(wx+3,wy+2,wx+5,wy+4)
line(wx+4,wy+6,wx+6,wy+8)
line(wx+6,wy+4,wx+8,wy+6)
line(wx+6,wy+9,wx+8,wy+11)
line(wx+9,wy+6,wx+11,wy+8)
box(wx+8,wy+8,wx+11,wy+11)
pset(wx+7,wy+11,1)
pset(wx+11,wy+7,1)
line(wx+6,wy+6,wx+7,wy+7)
pset(wx+10,wy+10,1)
line(wx+11,wy+12,wx+13,wy+12)
line(wx+12,wy+11,wx+12,wy+13)
box(wx+13,wy+13,wx+15,wy+15)
end sub
sub testkey(kx,ky,max)
a=1
weapon(kx,ky)
do
1 k=getkey()
if k=129 then
a=a+1
if a>max then a=1
else if k=128 then
a=a-1
if a=0 then a=max
else if k=113 then
exit do
else if k=13 then
exit do
else
goto 1
end if
clspart(kx,ky,kx+15,ky+max*16-1)
weapon(kx,ky+16*(a-1))
loop
end sub
sub direction()
cls
dim j$(30)
j$(1)="********************"
j$(2)="******游戏说明******"
j$(3)="********************"
j$(4)=" 迷宫的地图可以是程"
j$(5)="序内含的,也可以是自"
j$(6)="己编辑的。编辑地图时"
j$(7)="J键放障碍物,K键放小"
j$(8)="旗,L键清除小旗或障 "
j$(9)="碍物,编辑完成后按Q "
j$(10)="键可保存并返回主界面"
j$(11)="。要玩程序内含的地图"
j$(12)="选择“开始游戏”->“"
j$(13)="游戏地图”,稍等片刻"
j$(14)="(因为地图数据庞大,"
j$(15)="读取需要一点时间),"
j$(16)="再选择游戏的难度即可"
j$(17)="进入游戏。要玩自己编"
j$(18)="辑的地图选择“开始游"
j$(19)="戏”->“自制地图”,"
j$(20)="再选择游戏的难度即可"
j$(21)="。进入游戏后,上下左"
j$(22)="右四键控制右下方的小"
j$(23)="圆移动,将小圆移到小"
j$(24)="旗的位置即可通关。 "
j$(25)=" Q键返回上一级菜单。"
j$(26)=" <按Q键返回主界面> "
j$(27)=""
j$(28)=""
j$(29)=""
j$(30)=""
cls
print j$(1);j$(2);j$(3);j$(4);j$(5);j$(6)
a=1
do
3 k=getkey()
if k=129 then
a=a+1
if a=6 then a=1
else if k=128 then
a=a-1
if a=0 then a=5
else if k=113 then
exit do
else
goto 3
end if
cls
for b=1 to 6
print j$(b+(a-1)*6)
next b
loop
end sub
sub win()
clspart(11,27,148,68)
box(11,27,148,68)
box(13,29,146,66)
locate(3,3):print "哇...!这么难的迷"
locate(4,3):print "宫都难不倒你!相"
pause
clspart(15,30,145,65)
locate(3,3):print "信你在任何地方都"
locate(4,3):print "不会迷路了!"
pause
clspart(15,30,145,65)
locate(3,4):print "要再玩一次吗?"
locate(4,7):print "(Y or N)"
do
yn=getkey()
if yn=121 then
exit do
else if yn=110 then
runend()
end if
loop
end