hi
ich bin gerade dabei ein spiel zu scripten
jetzt hab ich aber ein problem
also in meinem spiel geht es darum von das eine kugel von eimem ort auf dem destop zu anderen rollt
dabei soll sie auf den fenstern und auf selbst gezeichnetten linien lang rollen können.
hier mein script:
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <Misc.au3>
#include <Array.au3>
HotKeySet("{Esc}", "Ende")
_GDIPlus_Startup()
Global $Speed = 10
[/autoit] [autoit][/autoit] [autoit]Global $BallPos[4], $ZielPos[4], $Ball
[/autoit] [autoit][/autoit] [autoit]$Main = GUICreate("Destop Runner", 0, 0, -2, -2)
WinSetTrans("Destop Runner", "", 0)
GUISetState(@SW_SHOW)
$Background = GUICreate("Background", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_MDICHILD, $WS_EX_LAYERED), $Main)
GUISetBkColor(0xFFFFFF)
$Button1 = GUICtrlCreateButton("Start Punkt setzen", 5, 5, 120, 25)
$Button2 = GUICtrlCreateButton("Ziel Punkt setzen", 5, 35, 120, 25)
$Button3 = GUICtrlCreateButton("Normale Linie", 5, 70, 120, 25)
$Button4 = GUICtrlCreateButton("Fahrstuhl", 5, 100, 120, 25)
$Pic1 = GUICtrlCreatePic("play-button2.jpg", 20, 130, 30, 30)
$Pic2 = GUICtrlCreatePic("stop-button.jpg", 70, 130, 30, 30)
GUISetState(@SW_SHOW)
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($Background)
$hEndCap = _GDIPlus_ArrowCapCreate(1, 2)
$hPenB = _GDIPlus_PenCreate(0xFF000000, 10, 2)
$hPenR = _GDIPlus_PenCreate(0xFFFF0000, 10, 2)
_GDIPlus_PenSetCustomEndCap($hPenR, $hEndCap)
GUIWhile()
[/autoit] [autoit][/autoit] [autoit]Func GUIWhile()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Do
Sleep(100)
Until _IsPressed(01)
$Mouse = MouseGetPos()
$Ball = GUICtrlCreatePic("ball.jpg", $Mouse[0] - 10, $Mouse[1] - 10, 20, 20)
$BallPos[0] = $Mouse[0] - 10
$BallPos[1] = $Mouse[1] - 10
$BallPos[2] = 20
$BallPos[3] = 20
GUICtrlSetState($Button1, $GUI_DISABLE)
Case $Button2
Do
Sleep(100)
Until _IsPressed(01)
$Mouse = MouseGetPos()
$Ziel = GUICtrlCreatePic("ziel.jpg", $Mouse[0] - 20, $Mouse[1] - 20, 40, 40)
$ZielPos[0] = $Mouse[0] - 20
$ZielPos[1] = $Mouse[1] - 20
$ZielPos[2] = 40
$ZielPos[3] = 40
GUICtrlSetState($Button2, $GUI_DISABLE)
Case $Button3
Do
Sleep(100)
Until _IsPressed(01)
$Mouse1 = MouseGetPos()
Do
Sleep(100)
Until _IsPressed(01)
$Mouse2 = MouseGetPos()
_GDIPlus_GraphicsDrawLine($hGraphic, $Mouse1[0], $Mouse1[1], $Mouse2[0], $Mouse2[1], $hPenB)
Case $Button4
Do
Sleep(100)
Until _IsPressed(01)
$Mouse1 = MouseGetPos()
Do
Sleep(100)
Until _IsPressed(01)
$Mouse2 = MouseGetPos()
_GDIPlus_GraphicsDrawLine($hGraphic, $Mouse1[0], $Mouse1[1], $Mouse1[0], $Mouse2[1], $hPenR)
Case $Pic1
If GUICtrlGetState($Button1) = 80 Or GUICtrlGetState($Button2) = 80 Then
MsgBox(0, "Destop Runner", "Sie haben den Start/Ziel Punkt noch nicht gesetzt")
Else
GUICtrlSetState($Button1, $GUI_HIDE)
GUICtrlSetState($Button2, $GUI_HIDE)
GUICtrlSetState($Button3, $GUI_HIDE)
GUICtrlSetState($Button4, $GUI_HIDE)
GUICtrlSetState($Pic1, $GUI_HIDE)
GUICtrlSetState($Pic2, $GUI_HIDE)
HotKeySet("{Space}", "Reset")
Main()
EndIf
Case $Pic2
Exit
EndSwitch
WEnd
EndFunc ;==>GUIWhile
Func Main()
;~ $Windows = CheckWindows()
;~ _ArrayDisplay($BallPos)
;~ _ArrayDisplay($ZielPos)
;~ _ArrayDisplay($Windows)
While 1
Left()
Right()
Switch CheckPos()
Case 0
FallDown()
Case 1
MsgBox(0, "Destop Runner", "Ziel erreicht")
Exit
Case 2
Case 3
Case 4
DriveUp()
EndSwitch
Sleep($Speed)
WEnd
EndFunc ;==>Main
Func Left()
If _IsPressed(25) Then
GUICtrlSetPos($Ball, $BallPos[0] - 1, $BallPos[1])
$BallPos[0] = $BallPos[0] - 1
EndIf
EndFunc ;==>Left
Func Right()
If _IsPressed(27) Then
GUICtrlSetPos($Ball, $BallPos[0] + 1, $BallPos[1])
$BallPos[0] = $BallPos[0] + 1
EndIf
EndFunc ;==>Right
Func DriveUp()
GUICtrlSetPos($Ball, $BallPos[0], $BallPos[1] - 1)
$BallPos[1] = $BallPos[1] - 1
EndFunc ;==>DriveUp
Func FallDown()
GUICtrlSetPos($Ball, $BallPos[0], $BallPos[1] + 1)
$BallPos[1] = $BallPos[1] + 1
EndFunc ;==>FallDown
Func CheckPos()
Local $MatchPos = 0
For $i = $ZielPos[0] To $ZielPos[0] + $ZielPos[2]
If $i = $BallPos[0] And $ZielPos[1] = $BallPos[1] + ($BallPos[3] / 2) Then $MatchPos += 1
Next
For $i = $ZielPos[1] To $ZielPos[1] + $ZielPos[3]
If $i = $BallPos[1] And $ZielPos[0] = $BallPos[0] + ($BallPos[2] / 2) Then $MatchPos += 1
If $i = $BallPos[1] And $ZielPos[0] = $BallPos[0] - ($BallPos[2] * 1.5) Then $MatchPos += 1
Next
If $MatchPos >= 1 Then Return 1
$MatchPos = 0
$Windows = CheckWindows()
For $j = 0 To UBound($Windows) - 1
For $i = $Windows[$j][1] To $Windows[$j][1] + $Windows[$j][3]
If $i = $BallPos[0] And $Windows[$j][2] = $BallPos[1] + $BallPos[3] Then $MatchPos += 1
Next
For $i = $Windows[$j][2] To $Windows[$j][2] + $Windows[$j][4]
If $i = $BallPos[1] And $Windows[$j][1] = $BallPos[0] - $BallPos[2] Then $MatchPos += 1
If $i = $BallPos[1] And $Windows[$j][1] = $BallPos[0] + $BallPos[2] Then $MatchPos += 1
Next
Next
If $MatchPos >= 1 Then Return 2
$MatchPos = 0
If PixelGetColor($BallPos[0] - 1, $BallPos[1] + $BallPos[3] + 1) = 0x000000 Then $MatchPos += 1
If PixelGetColor($BallPos[0] - 1, $BallPos[1] + ($BallPos[3] / 2) + 1) = 0x000000 Then $MatchPos += 1
If PixelGetColor($BallPos[0] + $BallPos[2] + 1, $BallPos[1] + $BallPos[3] + 1) = 0x000000 Then $MatchPos += 1
If PixelGetColor($BallPos[0] + $BallPos[2] + 1, $BallPos[1] + ($BallPos[3] / 2) + 1) = 0x000000 Then $MatchPos += 1
If $MatchPos >= 1 Then Return 3
$MatchPos = 0
If PixelGetColor($BallPos[0] - 1, $BallPos[1] + $BallPos[3] + 1) = 0xFF0000 Then $MatchPos += 1
If PixelGetColor($BallPos[0] - 1, $BallPos[1] + ($BallPos[3] / 2) + 1) = 0xFF0000 Then $MatchPos += 1
If PixelGetColor($BallPos[0] + $BallPos[2] + 1, $BallPos[1] + $BallPos[3] + 1) = 0xFF0000 Then $MatchPos += 1
If PixelGetColor($BallPos[0] + $BallPos[2] + 1, $BallPos[1] + ($BallPos[3] / 2) + 1) = 0xFF0000 Then $MatchPos += 1
If $MatchPos >= 1 Then Return 4
$MatchPos = 0
Return 0
EndFunc ;==>CheckPos
Func CheckWindows()
$var = WinList()
Dim $WindowNames[1]
For $i = 1 To $var[0][0]
If IsOpen($var[$i][0], $var[$i][1]) Then
_ArrayAdd($WindowNames, $var[$i][0])
EndIf
Next
Local $iUBound = UBound($WindowNames)
Dim $Windows[$iUBound - 1][5]
For $i = 1 To $iUBound - 1
$pos = WinGetPos($WindowNames[$i])
$Windows[$i - 1][0] = $WindowNames[$i]
$Windows[$i - 1][1] = $pos[0]
$Windows[$i - 1][2] = $pos[1]
$Windows[$i - 1][3] = $pos[2]
$Windows[$i - 1][4] = $pos[3]
Next
Return $Windows
EndFunc ;==>CheckWindows
Func Reset()
HotKeySet("{Space}")
GUICtrlSetState($Button1, $GUI_SHOW)
GUICtrlSetState($Button2, $GUI_SHOW)
GUICtrlSetState($Button3, $GUI_SHOW)
GUICtrlSetState($Button4, $GUI_SHOW)
GUICtrlSetState($Pic1, $GUI_SHOW)
GUICtrlSetState($Pic2, $GUI_SHOW)
GUIWhile()
EndFunc ;==>Reset
Func IsOpen($Name, $Handle)
If BitAND(WinGetState($Handle), 2) And Not BitAND(WinGetState($Handle), 16) _
And Not BitAND(WinGetState($Handle), 32) And $Name <> "" And $Name <> "Program Manager" _
And $Name <> "AMD:CCC-AEMCapturingWindow" And $Name <> "Background" _
And $Name <> "Start" And $Name <> "Destop Runner" Then Return 1
Return 0
EndFunc ;==>IsOpen
Func Ende()
Exit
EndFunc ;==>Ende
ich hab jetzt das problem das die kugel nicht auf den fenstern hängen bleibt <--Gelöst
und das mit den linien hab ich noch net drinne das kommt aber noch <--Gelöst auch wenns ein bischen anderst ist
die bilder und der script sind dan nochmal im anhag
ich hoffe es kann mir jemand helfen