Bewegung

  • Hallo, Ich habe das Problem das ich wenn ich gleichzeitig meine beiden Chars bewegen will, das einer blockiert. Wie kann ich das umgehen?

    Spoiler anzeigen
    [autoit]

    ;===============================================Includes
    #include <GuiConstants.au3>
    ;===============================================Includes
    ;===============================================Variables
    $p1x = 10
    $p1y = 80
    $p1direction = "right"
    $p2x = 470
    $p2y = 80
    $p2direction = "left"
    ;===============================================Variables
    ;===============================================HotKeys
    HotKeySet("w", "p1forward")
    HotKeySet("s", "p1backward")
    HotKeySet("d", "p1rightward")
    HotKeySet("a", "p1leftward")
    HotKeySet("{up}", "p2forward")
    HotKeySet("{down}", "p2backward")
    HotKeySet("{right}", "p2rightward")
    HotKeySet("{left}", "p2leftward")
    ;===============================================HotKeys
    ;===============================================GUIs
    $gui1 = GUICreate("League of Ethik", 500, 200)
    $vox = GUICtrlCreatePic("./img/vox.bmp", $p1x, $p1y, 20, 20)
    $cripton = GUICtrlCreatePic("./img/cripton.bmp", $p2x, $p2y, 20, 20)
    GUISetState(@SW_SHOW)
    ;===============================================GUIs
    ;===============================================Whiles
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd
    ;===============================================Whiles
    ;===============================================Funcs
    Func p1forward()
    $p1y = $p1y - 5
    $p1direction = "up"
    If $p1y < 0 Then
    $p1y = 0
    Else
    GUICtrlDelete($vox)
    $vox = GUICtrlCreatePic("./img/vox.bmp", $p1x, $p1y, 20, 20)
    EndIf
    EndFunc
    Func p1backward()
    $p1y = $p1y + 5
    $p1direction = "down"
    If $p1y > 180 Then
    $p1y = 180
    Else
    GUICtrlDelete($vox)
    $vox = GUICtrlCreatePic("./img/vox.bmp", $p1x, $p1y, 20, 20)
    EndIf
    EndFunc
    Func p1rightward()
    $p1x = $p1x + 5
    $p1direction = "right"
    If $p1x > 480 Then
    $p1x = 480
    Else
    GUICtrlDelete($vox)
    $vox = GUICtrlCreatePic("./img/vox.bmp", $p1x, $p1y, 20, 20)
    EndIf
    EndFunc
    Func p1leftward()
    $p1direction = "left"
    $p1x = $p1x - 5
    If $p1x < 0 Then
    $p1x = 0
    Else
    GUICtrlDelete($vox)
    $vox = GUICtrlCreatePic("./img/vox.bmp", $p1x, $p1y, 20, 20)
    EndIf
    EndFunc
    ;p2
    Func p2forward()
    $p2y = $p2y - 5
    $p2direction = "up"
    If $p2y < 0 Then
    $p2y = 0
    Else
    GUICtrlDelete($cripton)
    $cripton = GUICtrlCreatePic("./img/cripton.bmp", $p2x, $p2y, 20, 20)
    EndIf
    EndFunc
    Func p2backward()
    $p2y = $p2y + 5
    $p2direction = "down"
    If $p2y > 180 Then
    $p2y = 180
    Else
    GUICtrlDelete($cripton)
    $cripton = GUICtrlCreatePic("./img/cripton.bmp", $p2x, $p2y, 20, 20)
    EndIf
    EndFunc
    Func p2rightward()
    $p2x = $p2x + 5
    $p2direction = "right"
    If $p2x > 480 Then
    $p2x = 480
    Else
    GUICtrlDelete($cripton)
    $cripton = GUICtrlCreatePic("./img/cripton.bmp", $p2x, $p2y, 20, 20)
    EndIf
    EndFunc
    Func p2leftward()
    $p2x = $p2x - 5
    $p2direction = "left"
    If $p2x < 0 Then
    $p2x = 0
    Else
    GUICtrlDelete($cripton)
    $cripton = GUICtrlCreatePic("./img/cripton.bmp", $p2x, $p2y, 20, 20)
    EndIf
    EndFunc
    ;===============================================Funcs

    [/autoit]