- 帖子
- 44
- 积分
- 231
- 技术
- 0
- 捐助
- 0
- 注册时间
- 2009-4-16
|
7楼
发表于 2009-4-18 18:10
| 只看该作者
我也写过贪吃蛇,而且是变色贪吃蛇,吃什么色就变什么色,不过是用按键精灵写的
//请先将画板打开并最大化,保持在前台,如果分辨率不是1280*1024全脚本只有cx,cy需要自己修改!
dim a(60),b(60),vvc(1,13)
x1=350:y1=350:x2=369:y2=350
//x1,2 y1,2是起始蛇线,可以自己重新设置,要求x2,y2>x1,y1,且必须是横线或竖线
cx=39:cy=935:ccx=0:ccy=0
//cx,cy是画板下面黑色方块的坐标,必须自己重新输入!!!!!!!!!!我分辨率是1280*1024
//每个颜色cx+(0-13就是ccx)*gg:cy=cy+(0-1就是ccy)*gg gg是颜色间隔
VBSCall pp=GetPixelColor(cx,cy)
If pp<>"000000"
KeyDown 18,1
KeyPress 67,1
KeyUp 18,1
KeyPress 69,1
Delay 50
KeyDown 18,1
KeyPress 68,1
KeyUp 18,1
KeyPress 9,1
KeyPress 9,1
KeyPress 9,1
SayString 0
KeyPress 9,1
SayString 0
KeyPress 9,1
SayString 0
KeyPress 13,1
EndIf
gg=0:gg1=0:gg2=0
While 1
IfColor cx+gg1,cy,000000,0
gg1=gg1+1
Delay 10
Else
Goto 右非黑
EndIf
EndWhile
Rem 右非黑
While 1
IfColor cx-gg2,cy,000000,0
gg2=gg2+1
Delay 10
Else
Goto 左非黑
EndIf
EndWhile
Rem 左非黑
gg=gg1+gg2-2
//gg是颜色间隔,此步算出每个颜色方块的边长-1
gg=gg+4
//gg是颜色间隔,此步把方块中那4格间隙给补上,如果你的不是4格自己修改
mmx=cx:mmy=cy:vvcx=1:vvcy=0
VBSCall GetPixelColor(mmx,mmy)
For 2
For 13
mmx=mmx+gg
vvc(vvcy,vvcx)=GetPixelColor(mmx,mmy)
vvcx=vvcx+1
EndFor
vvcy=vvcy+1
vvcx=1
mmy=mmy+gg
mmx=cx
EndFor
If x1=x2
xx=0:yy=1:ii=ABS(y2-y1)+1
Else
xx=1:yy=0:ii=ABS(x2-x1)+1
EndIf
i=2
a(1)=x1
b(1)=y1
While i<=ii
a(i)=a(i-1)+xx
b(i)=b(i-1)+yy
i=i+1
EndWhile
MoveTo x1,y1
LeftDown 1
MoveTo x2,y2
LeftUp 1
KeyPress 32,1
i=1
x=a(ii):y=b(ii)
Randomize
ccx=int(Rnd*13+1):ccy=int(Rnd+0.5)
MoveTo cx+(ccx*gg),cy+(ccy*gg)
LeftClick 1
MoveTo int(Rnd*120+300),int(Rnd*120+300)
//这里120和300可以自己设置,是在多大范围内出现随即点
LeftClick 1
bs1=cx:bs2=cy+gg
//画板白色点坐标
GetLastKey v
vv=v
csx=cx:csy=cy
While 1
MoveTo bs1,bs2
LeftClick 1
MoveTo a(i),b(i)
LeftClick 1
MoveTo csx,csy
LeftClick 1
GetLastKey v
If v<>vv and v>=37 and v<=40
If v=38
xx=0:yy=-1:vv=v
ElseIf v=40
xx=0:yy=1:vv=v
ElseIf v=37
xx=-1:yy=0:vv=v
ElseIf v=39
xx=1:yy=0:vv=v
EndIf
EndIf
x=x+xx:y=y+yy
t=1
While t<=ii
If x=a(t) and y=b(t)
Goto 重复
Else
t=t+1
EndIf
EndWhile
Gosub 遇点
Rem 重复
MoveTo x,y
LeftClick 1
a(i)=x:b(i)=y
i=i+1
If i>ii
i=1
EndIf
EndWhile
EndScript
Sub 遇点
IfColor x,y,"FFFFFF",1
ss=GetPixelColor(x,y)
If ss=GetPixelColor(cx,cy)
vvcx=0:vvcy=0
Goto 判色完
EndIf
vvcy=0:vvcx=1
For 2
For 13
If ss=vvc(vvcy,vvcx)
Goto 判色完
EndIf
vvcx=vvcx+1
EndFor
vvcx=1
vvcy=vvcy+1
EndFor
BBB=cint("&H"&left(ss,2))
GGG=cint("&H"&mid(ss,3,2))
RRR=cint("&H"&right(ss,2))
KeyDown 18,1
KeyPress 67,1
KeyUp 18,1
KeyPress 69,1
Delay 50
KeyDown 18,1
KeyPress 68,1
KeyUp 18,1
KeyPress 9,1
KeyPress 9,1
KeyPress 9,1
SayString RRR
KeyPress 9,1
SayString GGG
KeyPress 9,1
SayString BBB
KeyPress 13,1
vvcy=0:vvcx=0
Else
Return
EndIf
Rem 判色完
csx=cx+(vvcx*gg):csy=cy+(vvcy*gg)
//当前画板颜色坐标
ccx=int(Rnd*13+1):ccy=int(Rnd+0.5)
While ccx=vvcx and ccy=vvcy
ccx=int(Rnd*13+1):ccy=int(Rnd+0.5)
Delay 20
EndWhile
MoveTo cx+(ccx*gg),cy+(ccy*gg)
LeftClick 1
MoveTo int(Rnd*120+300),int(Rnd*120+300)
LeftClick 1
ii=ii+1
a(i)=x:b(i)=y
x=x+xx:y=y+yy
i=i+1
MoveTo bs1,bs2
LeftClick 1
MoveTo a(i),b(i)
LeftClick 1
MoveTo csx,csy
LeftClick 1
EndIf
Return |
|