Hallo zusammen,
habe eine Gui, in der ein Objekt ist(in meinem Fall ein Ball) und ein Zweites Objekt(Mauer od. Wand). Den Ball kann man mit den Pfeiltasten steuern.
Jedoch habe ich jetzt das Problem, dass sich der Ball unter die Mauer schiebt und suche nun eine Möglichkeit um das zu verhindern.
Hab schon vieles probiert, hat aber wenig geklappt.
Hier mal mein Quellcode, wobei das nur ein Beispiel ist, um es sich besser vorzustellen :
Spoiler anzeigen
#include <GuiConstants.au3>
#include <Misc.au3>
opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]GUICreate("Beispiel", 400, 400)
$ball = GUICtrlCreateIcon("ball17.ico", -1, 10 ,10)
GUICtrlCreateIcon("wall.ico", -1 ,35, 35)
GUISetBkColor(000000)
GUISetState()
GUISetOnEvent($GUI_EVENT_CLOSE, "Ende")
[/autoit] [autoit][/autoit] [autoit]While 1
[/autoit] [autoit][/autoit] [autoit]If _IsPressed(28) Then
_pfeiltaste_unten()
EndIf
If _IsPressed(26) Then
_pfeiltaste_oben()
EndIf
If _IsPressed(25) Then
_pfeiltaste_links()
EndIf
If _IsPressed(27) Then
_pfeiltaste_rechts()
EndIf
Sleep(10)
WEnd
Func Ende()
Exit
EndFunc
func _pfeiltaste_unten()
$pos = ControlGetPos("Beispiel", "", $ball)
If $pos[1] <> 370 Then
GUICtrlSetPos($ball, $pos[0], $pos[1] + 2)
EndIf
EndFunc
Func _pfeiltaste_oben()
$pos = ControlGetPos("Beispiel", "", $ball)
If $pos[1] <> 0 Then
GUICtrlSetPos($ball, $pos[0], $pos[1] - 2)
EndIf
EndFunc
Func _pfeiltaste_links()
$pos = ControlGetPos("Beispiel", "", $ball)
If $pos[0] <> 0 Then
GUICtrlSetPos($ball, $pos[0] - 2, $pos[1])
EndIf
EndFunc
Func _pfeiltaste_rechts()
$pos = ControlGetPos("Beispiel", "", $ball)
If $pos[0] <> 370 Then
GUICtrlSetPos($ball, $pos[0] + 2, $pos[1])
EndIf
EndFunc
und die Icons:
autoit.de/wcf/attachment/5645/