天天爱消除辅助-按键精灵手机安卓版-天天爱消除辅助Android源码-按键精灵脚本

无意中看到按键精灵出Android版了,想了解一下,所以加入了内测,

由于脚本语法和VB差不多,所以上手很快,写了个天天爱消除的脚本来练习一下,

很早就知道按键精灵了,但一直没写过其脚本,这个算是我的第一个按键精灵脚本吧!



/****
测试手机 小米1S
分辨率   480*854
游戏方格 68*68
起始点   3,223
**/

Dim baseX,baseY,boxW,boxH
Dim I,X,Y,maxX,maxY,ret,Box(8, 8)

baseX = 3
baseY = 223
boxW  = 68
boxH  = 67.5
maxX  = 7
maxY  = 7
ret = 0

KeepScreen(true)
TracePrint "开始消除。。。"

‘还没加入判断开始与结束的条件,使用时手工点停止
For I = 1 To 200
	‘TracePrint I
	Call ReadBox()

	For Y = 1 To maxY
	For X = 1 To maxX
		ret = CheckMove(X, Y, maxX, maxY)
		Select Case ret
		Case 1 ‘上移
			Tap baseX+(X-1)*boxW+30,baseY+(Y-1)*boxH+30
			Tap baseX+(X-1)*boxW+30,baseY+(Y-2)*boxH+30
		Case 2 ‘右移
			Tap baseX+(X-1)*boxW+30,baseY+(Y-1)*boxH+30
			Tap baseX+X*boxW+30,baseY+(Y-1)*boxH+30
		Case 3 ‘下移
			Tap baseX+(X-1)*boxW+30,baseY+(Y-1)*boxH+30
			Tap baseX+(X-1)*boxW+30,baseY+(Y)*boxH+30
		Case 4 ‘左移
			Tap baseX+(X-1)*boxW+30,baseY+(Y-1)*boxH+30
			Tap baseX+(X-2)*boxW+30,baseY+(Y-1)*boxH+30
		End Select
	Next
	Next

Next

TracePrint "消除结束!!!"
KeepScreen(false)
EndScript


‘确定方块往哪个方向移动(返回:0-无,1-上,2-右,3-下,4-左)
Function CheckMove(x, y, maxX, maxY)
	Dim ret
	ret = 0
	‘往上移
	If ret=0 And y>1 Then
		If x>2 And BoxMatch(x-2,y-1, x-1,y-1, x,y) Then
			ret = 1
		End If
		If x>1 And x<maxX And BoxMatch(x-1,y-1, x,y, x+1,y-1) Then
			ret = 1
		End If
		If x<maxX-1 And BoxMatch(x,y, x+1,y-1, x+2,y-1) Then
			ret = 1
		End If
		If y>3 And BoxMatch(x,y-3, x,y-2, x,y) Then
			ret = 1
		End If
	End If
	‘往右移
	If ret=0 And x<maxX Then
		If y>2 And BoxMatch(x+1,y-2, x+1,y-1, x,y) Then
			ret = 2
		End If
		If y>1 And y<maxY And BoxMatch(x+1,y-1, x,y, x+1,y+1) Then
			ret = 2
		End If
		If y<maxY-1 And BoxMatch(x,y, x+1,y+1, x+1,y+2) Then
			ret = 2
		End If
		If x<maxX-2 And BoxMatch(x,y, x+2,y, x+3,y) Then
			ret = 2
		End If
	End If
	‘往下移
	If ret=0 And y<maxY Then
		If x>2 And BoxMatch(x-2,y+1, x-1,y+1, x,y) Then
			ret = 3
		End If
		If x>1 And x<maxX And BoxMatch(x-1,y+1, x,y, x+1,y+1) Then
			ret = 3
		End If
		If x<maxX-1 And BoxMatch(x,y, x+1,y+1, x+2,y+1) Then
			ret = 3
		End If
		If y<maxY-2 And BoxMatch(x,y, x,y+2, x,y+3) Then
			ret = 3
		End If
	End If
	‘往左移
	If ret=0 And x>1 Then
		If y>2 And BoxMatch(x-1,y-2, x-1,y-1, x,y) Then
			ret = 4
		End If
		If y>1 And y<maxY And BoxMatch(x-1,y-1, x,y, x-1,y+1) Then
			ret = 4
		End If
		If y<maxY-1 And BoxMatch(x,y, x-1,y+1, x-1,y+2) Then
			ret = 4
		End If
		If x>3 And BoxMatch(x-3,y, x-1,y, x,y) Then
			ret = 4
		End If
	End If
	CheckMove = ret
End Function

‘判断三个方块能否连线
Function BoxMatch(x1, y1, x2, y2, x3, y3)
	Dim b1, b2, b3
	b1 = Box(x1, y1)
	b2 = Box(x2, y2)
	b3 = Box(x3, y3)
	If BoxEquals(b1, b2) And BoxEquals(b1, b3) Then
		BoxMatch = True
	Else
		BoxMatch = False
	End If
End Function

‘判断两个方块是否一样
Function BoxEquals(box1, box2)
	If ColorDiff(box1,box2)<50 Then
		BoxEquals = True
	Else
		BoxEquals = False
	End If
End Function

‘读入方块布局
Sub ReadBox()
	KeepCapture
	Dim X,Y
	For Y = 1 To maxY
	For X = 1 To maxX
		Box(X,Y)=GetPixelColor(baseX+(X-1)*boxW+30, baseY+(Y-1)*boxH+30)
	Next
	Next
	ReleaseCapture
End Sub








天天爱消除辅助-按键精灵手机安卓版-天天爱消除辅助Android源码-按键精灵脚本,布布扣,bubuko.com

天天爱消除辅助-按键精灵手机安卓版-天天爱消除辅助Android源码-按键精灵脚本

上一篇:使用PolarDB和ECS搭建门户网站


下一篇:TalkingDataGame SDK在android Lua上的使用