Guten Abend
Ich versuche verzweifelt es zu schaffen das die figuren (bis jetzt labels) nicht die mauern berühren wie kann ich das machen
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
$Form = GUICreate("Bomberman", 600, 600)
Global $01 = 0
Global $02 = 0
Global $03 = 0
Global $Blau_Richtung = "rechts"
Global $Rot_Richtung = "rechts"
Global $Rot_Y = 100
Global $Rot_X = 100
Global $Blau_Y = 100
Global $Blau_X = 100
$File = FileOpen("map.txt", 0)
$Read = FileRead($File)
FileClose($File)
$String = StringSplit($Read, ",")
For $i = 1 To 225
If $String[$i] = "1" Then
GUICtrlCreatePic("weg.jpg", $01, $02, 40, 40, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
ElseIf $String[$i] = "0" Then
GUICtrlCreatePic("mauer.jpg", $01, $02, 40, 40, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
EndIf
$01 = $01 + 40
$03 = $03 + 1
If $03 = 15 Then
$02 = $02 + 40
$01 = 0
$03 = 0
EndIf
Next
$Rot = GUICtrlCreateLabel("", $Rot_Y, $Rot_X, 40, 40)
$Blau = GUICtrlCreateLabel("", $Blau_Y, $Blau_X, 40, 40)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
If _IsPressed(27) = 1 Then
Global $Rot_Richtung = "rechts"
EndIf
If _IsPressed(25) = 1 Then
Global $Rot_Richtung = "links"
EndIf
If _IsPressed(26) = 1 Then
Global $Rot_Richtung = "oben"
EndIf
If _IsPressed(28) = 1 Then
Global $Rot_Richtung = "unten"
EndIf
If _IsPressed(44) = 1 Then
Global $Blau_Richtung = "rechts"
EndIf
If _IsPressed(41) = 1 Then
Global $Blau_Richtung = "links"
EndIf
If _IsPressed(57) = 1 Then
Global $Blau_Richtung = "oben"
EndIf
If _IsPressed(53) = 1 Then
Global $Blau_Richtung = "unten"
EndIf
Rot()
Blau()
Sleep(100)
WEnd
Func Rot()
If $Rot_Y <> 0 Then
If $Rot_Richtung = "links" Then $Rot_Y = $Rot_Y - 10
EndIf
If $Rot_Y <> 560 Then
If $Rot_Richtung = "rechts" Then $Rot_Y = $Rot_Y + 10
EndIf
If $Rot_X <> 0 Then
If $Rot_Richtung = "oben" Then $Rot_X = $Rot_X - 10
EndIf
If $Rot_X <> 560 Then
If $Rot_Richtung = "unten" Then $Rot_X = $Rot_X + 10
EndIf
GUICtrlSetPos($Rot, $Rot_Y, $Rot_X)
EndFunc ;==>Rot
Func Blau()
If $Blau_Y <> 560 Then
If $Blau_Richtung = "rechts" Then $Blau_Y = $Blau_Y + 10
EndIf
If $Blau_Y <> 0 Then
If $Blau_Richtung = "links" Then $Blau_Y = $Blau_Y - 10
EndIf
If $Blau_X <> 0 Then
If $Blau_Richtung = "oben" Then $Blau_X = $Blau_X - 10
EndIf
If $Blau_X <> 560 Then
If $Blau_Richtung = "unten" Then $Blau_X = $Blau_X + 10
EndIf
GUICtrlSetPos($Blau, $Blau_Y, $Blau_X)
EndFunc ;==>Blau