AU3小游戏 - 撸杆过桥
ACN站的超版:afan所作
可能有在手机上玩过类似的
游戏规则很简单,按住鼠标左键不松,杆会撸到一定高度,算好其倒下的距离,
撒手,杆倒下,够不着=摔死;
撸过了=摔死。
看谁撸得久远… 先说好,咱不摔鼠标!
```#include <GDIPlus.au3>
Opt('GUIOnEventMode', 1)
;--------- 必要的变量声明
Local Const $GuiW = 400, $GuiY = 550
Local Const $Color_GUIBK = 0xFFCCCFC4
Local Const $vPos_CsX0 = 60, $vPos_CsY = 350
Local $vPos_CsX = $vPos_CsX0
Local Const $vFTW_Mix = 10
Local Const $vJj_Mix = 40
Local Const $vFT_CsX_Mix = $vPos_CsX + $vJj_Mix
Local Const $vFT_CsX_Max = $GuiW - 50
Local Const $Color_LG = 0xFF6E5EA8
Local Const $vPenW_LG = 10
Local Const $Color_FT = 0xFF3F5133
Local Const $vPenW_FT = $GuiY - $vPos_CsY
Local Const $Color_XF = 0xFFFFFFFF
Local Const $vPenW_XF = 15
Local Const $vFTH = $vPos_CsY + ($vPenW_FT / 2)
Local $vPos_FT_LeftW = $vPos_CsX
Local $vPos_FT_Right_X
Local $vPos_FT_RightW
Local $vJL = 0
;----------- 创建窗口
Local $hGui = GUICreate('撸杆过桥', $GuiW, $GuiY)
GUISetOnEvent(-3, '_Exit')
GUIRegisterMsg(0x0014, '_WM_ERASEBKGND')
;---------- 从窗口创建绘图环境
_GDIPlus_Startup()
Local $hPen_LG = _GDIPlus_PenCreate($Color_LG, $vPenW_LG)
Local $hPen_FT = _GDIPlus_PenCreate($Color_FT, $vPenW_FT)
Local $hPen_XF = _GDIPlus_PenCreate($Color_XF, $vPenW_XF)
Local $hGraphic_GUI = _GDIPlus_GraphicsCreateFromHWND($hGui)
Local $hBMP_GUI = _GDIPlus_BitmapCreateFromGraphics($GuiW, $GuiY, $hGraphic_GUI)
Local $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBMP_GUI)
;----------- 更新绘图数据
__RightData()
_Updata($vPos_CsX, $vPos_CsY - 5)
GUISetState()
;----------- 主循环
Local $aMsPos, $iH
While 1
Sleep(10)
$iH = $vPos_CsY
$aMsPos = GUIGetCursorInfo()
If @Error Then ContinueLoop
If Not $aMsPos[2] Then ContinueLoop
While Not @Error And $aMsPos[2]
Sleep(10)
$iH -= 5
_Updata($vPos_CsX, $iH) ;---- 更新绘图数据
$aMsPos = GUIGetCursorInfo()
Wend
Local $a[46][2], $nRad = $vPos_CsY - $iH, $iL = $vPos_CsX - ($vPos_CsY - $iH), $iT = $iH
Local $vPi = 3.14159265358979 / 180, $i
For $i = 1 To 45
$a[$i][0] = $iL + $nRad + $nRad * Cos(2 * ($i + 270 / 2) * $vPi)
$a[$i][1] = $iT + $nRad + $nRad * Sin(2 * ($i + 270 / 2) * $vPi)
_Updata($a[$i][0], $a[$i][1]) ;---- 更新绘图数据
Sleep(10)
Next
Local $Continue = 0
If $a[$i-1][0] < $vPos_FT_Right_X Then
If Msgbox(48 + 1, '重新开始?', '撸得不够') = 1 Then $Continue = 1
$vJL = 0
ElseIf $a[$i-1][0] > ($vPos_FT_Right_X + $vPos_FT_RightW) Then
If Msgbox(48 + 1, '重新开始?', '撸得太长') = 1 Then $Continue = 1
$vJL = 0
Else
$vJL += 1
_MoveXF($a[$i-1][0], Round($a[$i-1][1]))
EndIf
If $vJL > 0 Or $Continue Then
$vPos_FT_LeftW = $vPos_FT_RightW
__RightData()
_Updata($vPos_CsX, $vPos_CsY - 5)
EndIf
WEnd
Func _Updata($LG_d0, $LG_d1, $XF_d0 = 0, $XF_d1 = 0) ;============ 更新绘图数据
_GDIPlus_GraphicsClear($hGraphic, $Color_GUIBK)
If $vPos_FT_LeftW > $vPos_CsX Then
Local $CsX = 0
Else
Local $CsX = $vPos_CsX - $vPos_FT_LeftW
EndIf
_GDIPlus_GraphicsDrawLine($hGraphic, $CsX, $vFTH, $vPos_CsX, $vFTH, $hPen_FT)
If $LG_d1 <> $vPos_CsY Then
_GDIPlus_GraphicsDrawLine($hGraphic, $vPos_FT_Right_X, $vFTH, $vPos_FT_Right_X + $vPos_FT_RightW, $vFTH, $hPen_FT)
_GDIPlus_GraphicsDrawLine($hGraphic, $vPos_CsX, $vPos_CsY, $LG_d0, $LG_d1, $hPen_LG)
Else
Local $Cj = $vPos_CsX0 - $vPos_CsX
_GDIPlus_GraphicsDrawLine($hGraphic, $vPos_FT_Right_X - $Cj, $vFTH, $vPos_FT_Right_X - $Cj + $vPos_FT_RightW, $vFTH, $hPen_FT)
_GDIPlus_GraphicsDrawLine($hGraphic, $vPos_CsX, $vPos_CsY, $LG_d0 - $Cj, $LG_d1, $hPen_LG)
EndIf
If $XF_d0 = 0 Then $XF_d0 = $vPos_CsX - 20
If $XF_d1 = 0 Then $XF_d1 = $vPos_CsY - $vPenW_XF
_GDIPlus_GraphicsDrawLine($hGraphic, $XF_d0, $XF_d1, $XF_d0 + 12, $XF_d1, $hPen_XF) ;---- 绘制原点小方
_GDIPlus_GraphicsDrawString($hGraphic, $vJL, $GuiW - 80, 10, 'Arial', 30)
_GDIPlus_GraphicsDrawImage($hGraphic_GUI, $hBMP_GUI, 0, 0) ;---- 绘制图像对象 到窗口GUi
EndFunc ;==>_Updata
Func __RightData() ;============== 生成右方随机坐标数据
$vPos_FT_Right_X = Random($vFT_CsX_Mix, $vFT_CsX_Max, 1)
Local $aRaW[5] = [Random($vFTW_Mix, $vFTW_Mix + 30, 1), _
Random($vFTW_Mix, $vFTW_Mix + 10, 1), _
Random($vFTW_Mix, ($GuiW - $vPos_FT_Right_X) * 0.6, 1), _
Random($vFTW_Mix, $vFTW_Mix + 80, 1), _
Random($vFTW_Mix, ($GuiW - $vPos_FT_Right_X) * 0.9, 1)]
Local $vFTW = $aRaW[Random(0, 4, 1)]
$vPos_FT_RightW = $vFTW
EndFunc ;==>__RightData
Func _MoveXF($LG0, $LG1) ;============= 小方移动
Local $x = $vPos_CsX - 20
Do
Sleep(10)
$x += 5
_Updata($LG0, $LG1, $x)
Until $x >= $vPos_FT_Right_X + $vPos_FT_RightW - 10
Sleep(1000)
Local $Bak = $vPos_CsX, $Cj = $vPos_FT_Right_X + $vPos_FT_RightW - $vPos_CsX
Do
Sleep(10)
$x -= 5
$vPos_CsX -= 5
$Cj -= 5
_Updata($LG0, $LG1, $x)
Until $Cj <= 0
$vPos_CsX = $Bak
EndFunc ;==>_MoveXF
Func _WM_ERASEBKGND($hWnd, $msg, $wParam, $lParam) ;=============== 系统刷新
_GDIPlus_GraphicsDrawImage($hGraphic_GUI, $hBMP_GUI, 0, 0)
Return 1
EndFunc ;==>_WM_ERASEBKGND
Func _Exit() ;=========== 退出
_GDIPlus_Shutdown()
GUIDelete($hGui)
Exit
EndFunc ;==>_Exit```
发表评论
木有头像就木JJ啦!还木有头像吗?点这里申请属于你的个性Gravatar头像吧!