7.设置窗体main中timer1的timer事件,该事件控制蛇不断移动
local tmp1,tmp2,ft,fl,kk,fv,bb,cc,flag2,fb
bb=thisform.cmd1.left
cc=thisform.cmd1.top
flag2=.F.
for i=1 to num
kk=num-i+1
tmp1='cmd'+alltrim(str(kk,3))
if kk=1
do case
case sebeg='1'
fl=""thisform.""+tmp1+"".left=""+""thisform.""+tmp1+"".left-10""
case sebeg='2'
fl=""thisform.""+tmp1+"".top=""+""thisform.""+tmp1+"".top-10""
case sebeg='3'
fl=""thisform.""+tmp1+"".left=""+""thisform.""+tmp1+"".left+10""
case sebeg='4'
fl=""thisform.""+tmp1+"".top=""+""thisform.""+tmp1+"".top+10""
endcase
&fl
else
tmp2='cmd'+alltrim(str(kk-1,3))
ft=""thisform.""+tmp1+"".top=""+""thisform.""+tmp2+"".top""
fl=""thisform.""+tmp1+"".left=""+""thisform.""+tmp2+"".left""
&ft
&fl
endif
**判断是否蛇撞墙或蛇头接触蛇尾**
if thisform.cmd1.left>=sewidth .or.thisform.cmd1.left<=0.or.thisform.cmd1.top>=seheight.or.
thisform.cmd1.top<=0
flag2=.T.
endif
if kk>2
fcmp=""thisform.""+tmp1+"".left=bb .and.""+""thisform.""+tmp1+"".top=cc""
if &fcmp
flag2=.T.
endif
endif
endfor
if flag2
ThisForm.Timer1.interval=0
ThisForm.jb.enabled=.T.
wait windows ""你输了!重新玩请按开始!""
thisform.timer1.interval=0
ThisForm.jb.enabled=.T.
ThisForm.command1.setfocus
return
else
if ThisForm.doin.left=thisform.cmd1.left .and.thisform.doin.top=thisform.cmd1.top
fensu=(num-numbeg+1)*ss
ThisForm.fs.caption=alltrim(str(fensu))
ThisForm.gs.caption=alltrim(str(num-numbeg+1))
thisform.addone &&增加蛇的长度
thisform.adddian &&增加青蛙
endif
endif