Bug beim Bewegen der Maus ?

  • Hi,
    das folgende Script sollte eig. nur eine erste Grundlage für ein kleines Game sein. Doch komischer Weise bewegt sich der Icon viel schneller, wenn man die Maus bewegt.
    Hier das Script:

    Spoiler anzeigen
    [autoit]


    #include <GuiConstantsEx.au3>
    Local $b_left = Random ( 1, 500 ), $b_top = Random ( 1, 500 )
    Local $gx = Random ( 1, 9 ), $gy = Random ( 1, 9 )

    [/autoit] [autoit][/autoit] [autoit]

    #Region
    $Gui = GUICreate( "Reaction", 500, 500 )
    GUISetBkColor( 0x000000 )
    $ball = GUICtrlCreateIcon( @ScriptDir & "\cursor.ico", 0, $b_left, $b_top, 20, 20)
    GUISetState ( @SW_SHOW )
    #EndRegion

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg ()
    If $nMsg = $GUI_EVENT_CLOSE Then
    Exit
    EndIf

    _move()
    GUICtrlSetPos($ball, $b_left + $gx, $b_top + $gy )
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _move()
    if $b_top > 500 - 25 Then
    $gy = $gy * -1
    EndIf
    if $b_top < 1 then
    $gy = $gy * -1
    EndIf
    if $b_left < 1 Then
    $gx = $gx * -1
    EndIf
    if $b_left > 500 - 25 Then
    $gx = $gx * -1
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $b_left = $b_left + $gx
    $b_top = $b_top + $gy
    EndFunc

    [/autoit]


    Vielen Dank für jegliche Hilfe.

    mfG

  • so gehts:

    Spoiler anzeigen
    [autoit]

    #include <GuiConstantsEx.au3>
    Local $b_left = Random ( 1, 500 ), $b_top = Random ( 1, 500 )
    Local $gx= Random ( 1, 9 ), $gy = Random ( 1, 9 )

    [/autoit] [autoit][/autoit] [autoit]

    #Region
    $Gui = GUICreate( "Reaction", 500, 500 )
    GUISetBkColor( 0x000000 )
    $ball = GUICtrlCreateIcon( @ScriptDir & "\cursor.ico", 0, $b_left, $b_top, 20, 20)
    GUISetState ( @SW_SHOW )
    #EndRegion

    [/autoit] [autoit][/autoit] [autoit]

    AdlibRegister("_move",20)
    While 1
    $nMsg = GUIGetMsg ()
    If $nMsg = $GUI_EVENT_CLOSE Then
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetPos($ball, $b_left + $gx, $b_top + $gy )
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _move()
    if $b_top > 500 - 25 Then
    $gy = $gy * -1
    EndIf
    if $b_top < 1 then
    $gy = $gy * -1
    EndIf
    if $b_left < 1 Then
    $gx = $gx * -1
    EndIf
    if $b_left > 500 - 25 Then
    $gx = $gx * -1
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $b_left = $b_left + $gx
    $b_top = $b_top + $gy
    EndFunc

    [/autoit]
    [autoit]


    Func Ulam($n)
    Return 1
    EndFunc

    [/autoit]


    Rekursion FTW :D

  • hmm, hab mich bis jetzt noch nicht so viel mit GDI+ beschäftigt. Ich werd mirs mal angucken. Danke für den Tip

    mfG