⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mohuanmigong.txt

📁 步步高的电子词典上的 ZWBasic语言游戏魔幻迷宫2.1.txt 11.3KB 源码
💻 TXT
字号:
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 sub
sub third()
cls
dim where
dim go
x=139
y=78
there=9
do
81 cls
here=there
if here=1 then
bbb=0
baa=0
fill1=1
fill2=1
fill3=0
fill4=0
else if here=2 then
bbb=10
baa=0
fill1=1
fill2=0
fill3=0
fill4=0
else if here=3 then
bbb=20
baa=0
fill1=1
fill2=0
fill3=0
fill4=1
else if here=4 then
bbb=0
baa=6
fill1=0
fill2=1
fill3=0
fill4=0
else if here=5 then
bbb=10
baa=6
fill1=0
fill2=0
fill3=0
fill4=0
else if here=6 then
bbb=20
baa=6
fill1=0
fill2=0
fill3=0
fill4=1
else if here=7 then
bbb=0
baa=12
fill1=0
fill2=1
fill3=1
fill4=0
else if here=8 then
bbb=10
baa=12
fill1=0
fill2=0
fill3=1
fill4=0
else if here=9 then
bbb=20
baa=12
fill1=0
fill2=0
fill3=1
fill4=1
end if
if fill1=1 then fillrect(0,0,158,2)
if fill2=1 then fillrect(0,0,3,95)
if fill3=1 then fillrect(0,93,158,95)
if fill4=1 then fillrect(154,0,158,95)
box(3,2,154,93)
for a=0 to 5
for b=0 to 9
ba=b*15+4
bb=a*15+3
if da(b+bbb,a+baa)=1 then
fillrect(ba,bb,ba+13,bb+13)
else if da(b+bbb,a+baa)=3 then
line(ba+3,bb,ba+3,bb+14)
line(ba+4,bb+1,ba+4,bb+8)
line(ba+5,bb+2,ba+5,bb+8)
line(ba+6,bb+3,ba+6,bb+8)
line(ba+7,bb+4,ba+7,bb+8)
line(ba+8,bb+5,ba+8,bb+8)
line(ba+9,bb+6,ba+9,bb+8)
line(ba+10,bb+7,ba+10,bb+8)
pset(ba+11,bb+8,1)
end if
next b
next a
fillcircle(x+7,y+7,6)
if da((x-4)/15+bbb,(y-3)/15+baa)=3 then
win()
exit do
else if da((x-4)/15+bbb,(y-3)/15+baa)=1 then
there=where
if go=1 then y=3
if go=2 then x=4
if go=3 then y=78
if go=4 then x=139
goto 81
end if
82 go=0
k=getkey()
clspart(x,y,x+14,y+14)
if k=128 then
if y>3 then
y=y-15
else
go=1
end if
else if k=129 then
if y<78 then
y=y+15
else
go=3
end if
else if k=131 then
if x>4 then
x=x-15
else
go=2
end if
else if k=130 then
if x<139 then
x=x+15
else
go=4
end if
else if k=113 then
exit do
else
fillcircle(x+7,y+7,6)
goto 82
end if
if go>0 then goto 83
hx=(x-4)/15
hy=(y-3)/15
if da(hx+bbb,hy+baa)=1 then
if k=128 then y=y+15
if k=129 then y=y-15
if k=131 then x=x+15
if k=130 then x=x-15
else if da(hx+bbb,hy+baa)=3 then
win()
exit do
end if
fillcircle(x+7,y+7,6)
goto 82
83 if go=1 then
if here=4 then
there=1
y=78
else if here=5 then
there=2
y=78
else if here=6 then
there=3
y=78
else if here=7 then
there=4
y=78
else if here=8 then
there=5
y=78
else if here=9 then
there=6
y=78
end if
else if go=2 then
if here=2 then
there=1
x=139
else if here=5 then
there=4
x=139
else if here=8 then
there=7
x=139
else if here=3 then
there=2
x=139
else if here=6 then
there=5
x=139
else if here=9 then
there=8
x=139
end if
else if go=3 then
if here=1 then
there=4
y=3
else if here=2 then
there=5
y=3
else if here=3 then
there=6
y=3
else if here=4 then
there=7
y=3
else if here=5 then
there=8
y=3
else if here=6 then
there=9
y=3
end if
else if go=4 then
if here=1 then
there=2
x=4
else if here=4 then
there=5
x=4
else if here=7 then
there=8
x=4
else if here=2 then
there=3
x=4
else if here=5 then
there=6
x=4
else if here=8 then
there=9
x=4
end if
end if
if here=there then
fillcircle(x+7,y+7,6)
goto 82
end if
where=here
loop
end sub
sub runend()
for yn=0 to 79
clspart(yn,0,yn,95)
clspart(158-yn,0,158-yn,95)
next yn
sysprtstrg(43,16,"谢谢使用!")
locate(4,2):print "版权所有:Cool&Easy"
locate(5,5):print "QQ:350220789"
locate(6,2):print "SoCoolEasy@163.com"
lcdreverse(0,0,158,95)
do
delay(200)
lcdreverse(0,0,158,95)
k=keydetect()
if k=1 then
exit do
end if
loop
end
end sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -