Bild bewegen

  • Ich zitiere mal aus meinem angefangenen GDI+ Tut

    Sprich: Kugel bewegen, Gegner bewegen, Positionen vergleichen.
    Wenn die Kugel den Gegner berührt (Wenn die Positionen sich überschneiden), dann hast du getroffen.

  • Kann es sein, dass das ganze im OnEvent Mode besser ist? ?(

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <GUIConstants.au3>
    #include <Misc.au3>

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

    Opt("GUIOnEventMode", 1)

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

    $iGUIWidth = 400
    $iGUIHeight = 400
    $GUIColorBG = 0xFF000000

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

    $iShots = 0
    $iMaxShots = 5 + 1
    $iShotSpeed = 3
    $iCoolDownTime = 500
    $iTimerShot = $iCoolDownTime * - 1

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

    $hU32DLL = DllOpen("User32.dll")

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

    $hWnd = GUICreate("Space Invaders", $iGUIWidth, $iGUIHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetState()

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

    _GDIPlus_Startup()

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

    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iGUIWidth, $iGUIHeight, $hGraphic)
    $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
    _GDIPlus_GraphicsClear($hGraphic, $GUIColorBG)

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

    $hImage_Ship = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Raumschiff.jpg")
    $hBrush_Shot = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)

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

    Dim $aShot[2][2]

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

    $iX_Ship = $iGUIWidth / 2 - 25
    $iY_Ship = $iGUIHeight - 30

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

    While 1
    If _IsPressed("27", $hU32DLL) And $iX_Ship < $iGUIWidth - 50 Then $iX_Ship += 2
    If _IsPressed("25", $hU32DLL) And $iX_Ship > 0 Then $iX_Ship -= 2
    If _IsPressed("20", $hU32DLL) And TimerDiff($iTimerShot) >= $iCoolDownTime And UBound($aShot) < $iMaxShots Then
    _Array2DAdd($aShot, $iX_Ship + 23 & "|" & $iY_Ship - 10)
    $iTimerShot = TimerInit()
    EndIf

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

    _GDIPlus_GraphicsClear($hBuffer, $GUIColorBG)
    For $i = 1 To UBound($aShot) - 1
    If $aShot[$i][1] <> "" Then
    _GDIPlus_GraphicsFillRect($hBuffer, $aShot[$i][0], $aShot[$i][1], 5, 10, $hBrush_Shot)
    $aShot[$i][1] -= $iShotSpeed
    EndIf
    Next
    For $i = 1 To UBound($aShot) - 1
    If $aShot[$i][1] <= 0 Then
    _Array2DDelete($aShot, $i)
    ExitLoop
    EndIf
    Next
    _GDIPlus_GraphicsDrawImageRect($hBuffer, $hImage_Ship, $iX_Ship, $iY_Ship, 50, 30)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iGUIWidth, $iGUIHeight)
    Sleep(20)
    WEnd

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

    Func _Exit()
    DllClose($hU32DLL)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_GraphicsDispose($hBuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_ImageDispose($hImage_Ship)
    _GDIPlus_BrushDispose($hBrush_Shot)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

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

    ;------------------------------------------------------------------------------------------------------------
    ;
    ; Function _Array2DAdd(ByRef $avArray, $sValue='')
    ;
    ; Description Redim Array Size and add an Array element at last position
    ; Works with any occurences in 2nd Dimension
    ; Works also with 1D-Array
    ;
    ; Parameter $avArray Given Array
    ; optional $sValue Value of new Element, parts must be seperate with '|'
    ;
    ; Return Succes -1
    ; Failure 0 and set @error
    ; @error = 1 given array is not array
    ; @error = 2 given parts of Element too less/much
    ;
    ; Author BugFix ([email='bugfix@autoit.de'][/email])
    ;------------------------------------------------------------------------------------------------------------
    Func _Array2DAdd(ByRef $avArray, $sValue = '')
    If (Not IsArray($avArray)) Then
    SetError(1)
    Return 0
    EndIf
    Local $i
    Local $UBound2nd = UBound($avArray, 2)
    If @error = 2 Then
    ReDim $avArray[UBound($avArray) + 1]
    $avArray[UBound($avArray) - 1] = $sValue
    Else
    Local $arValue
    ReDim $avArray[UBound($avArray) + 1][$UBound2nd]
    If $sValue = '' Then
    For $i = 0 To $UBound2nd - 2
    $sValue &= '|'
    Next
    EndIf
    $arValue = StringSplit($sValue, '|')
    If $arValue[0] <> $UBound2nd Then
    SetError(2)
    Return 0
    EndIf
    For $i = 0 To $UBound2nd - 1
    $avArray[UBound($avArray) - 1][$i] = $arValue[$i + 1]
    Next
    EndIf
    Return -1
    EndFunc ;==>_Array2DAdd

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

    ;----------------------------------------------------------------------------------------------------------------------
    ; Fuction _Array2DDelete(ByRef $ARRAY, $iDEL)
    ;
    ; Description Delete one row on a given index in an 1D/2D -Array
    ;
    ; Parameter $ARRAY the array, where one row will deleted
    ; $iDEL Row-Index to delete
    ;
    ; Return Succes -1 ByRef $ARRAY
    ; Failure 0 set @error = 1; given array are not array
    ; set @error = 2; index is out of range
    ;
    ; Author BugFix ([email='bugfix@autoit.de'][/email])
    ;----------------------------------------------------------------------------------------------------------------------
    Func _Array2DDelete(ByRef $ARRAY, $iDEL)
    If (Not IsArray($ARRAY)) Then
    SetError(1)
    Return 0
    EndIf
    If ($iDEL < 0) Or ($iDEL > UBound($ARRAY) - 1) Then
    SetError(2)
    Return 0
    EndIf
    Local $i, $k, $l
    Local $UBound2nd = UBound($ARRAY, 2)
    If @error = 2 Then
    Local $arTmp[UBound($ARRAY) - 1]
    $k = 0
    For $i = 0 To UBound($ARRAY) - 1
    If $i <> $iDEL Then
    $arTmp[$k] = $ARRAY[$i]
    $k += 1
    EndIf
    Next
    Else
    Local $arTmp[UBound($ARRAY) - 1][$UBound2nd]
    $k = 0
    For $i = 0 To UBound($ARRAY) - 1
    If $i <> $iDEL Then
    For $l = 0 To $UBound2nd - 1
    $arTmp[$k][$l] = $ARRAY[$i][$l]
    Next
    $k += 1
    EndIf
    Next
    EndIf
    $ARRAY = $arTmp
    Return -1
    EndFunc ;==>_Array2DDelete

    [/autoit]
  • So habe jetzt etwas gemacht was fast geht :D
    Also:
    Ich habe Gegner reingemacht die sich bewegen. Aber die flakern immer :(
    Und wenn eine Kugel den Gegner trifft, stribt das Script, aber ich weiß nicht warum :(

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <Misc.au3>
    #include <Array.au3>
    #include <GUIConstantsEx.au3>

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

    Opt("GUIOnEventMode", 1)

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

    $iGUIWidth = 400
    $iGUIHeight = 400
    $GUIColorBG = 0xFF000000

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

    $iShots = 0
    $iMaxShots = 5 + 1
    $iShotSpeed = 3
    $iCoolDownTime = 500
    $iTimerShot = $iCoolDownTime * - 1
    $iTimerGegner = TimerInit()

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

    $hU32DLL = DllOpen("User32.dll")

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

    $hWnd = GUICreate("Space Invaders", $iGUIWidth, $iGUIHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetState()

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

    _GDIPlus_Startup()

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

    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iGUIWidth, $iGUIHeight, $hGraphic)
    $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
    _GDIPlus_GraphicsClear($hGraphic, $GUIColorBG)

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

    Dim $hImage_Gegner[2]
    Dim $iGegner[2][2]

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

    For $i = 1 To 5
    _Array2DAdd($hImage_Gegner, _GDIPlus_ImageLoadFromFile(@ScriptDir & "\img\gegner.jpg"))
    _Array2DAdd($iGegner, 0 + (($i - 1) * 45) & "|" & 0)
    Next

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

    $hImage_Ship = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\img\Raumschiff.jpg")
    $hBrush_Shot = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)

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

    Dim $aShot[2][2]

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

    $iX_Ship = $iGUIWidth / 2 - 25
    $iY_Ship = $iGUIHeight - 30

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

    While 1
    If _IsPressed("27", $hU32DLL) And $iX_Ship < $iGUIWidth - 50 Then $iX_Ship += 2
    If _IsPressed("25", $hU32DLL) And $iX_Ship > 0 Then $iX_Ship -= 2
    If _IsPressed("20", $hU32DLL) And TimerDiff($iTimerShot) >= $iCoolDownTime And UBound($aShot) < $iMaxShots Then
    _Array2DAdd($aShot, $iX_Ship + 21 & "|" & $iY_Ship - 10)
    $iTimerShot = TimerInit()
    EndIf

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

    _GDIPlus_GraphicsClear($hBuffer, $GUIColorBG)
    For $i = 1 To UBound($aShot) - 1
    If $aShot[$i][1] <> "" Then
    _GDIPlus_GraphicsFillRect($hBuffer, $aShot[$i][0], $aShot[$i][1], 5, 10, $hBrush_Shot)
    For $j = 2 To UBound ($iGegner)-1
    If $aShot[$i][1] <= $iGegner[$j][1] Then _Array2DDelete ($iGegner,$j)
    Next
    $aShot[$i][1] -= $iShotSpeed
    EndIf
    Next
    For $i = 1 To UBound($aShot) - 1
    If $aShot[$i][1] <= 0 Then
    _Array2DDelete($aShot, $i)
    ExitLoop
    EndIf
    Next
    If TimerDiff($iTimerGegner) >= 500 Then
    For $i = 2 To UBound($iGegner) - 1
    If $iGegner[$i][0] + 40 >= $iGUIWidth Then
    $iGegner[$i][1] += 25
    $iGegner[$i][0] = 0
    _GDIPlus_GraphicsDrawImageRect($hBuffer, $hImage_Gegner[$i], $iGegner[$i][0], $iGegner[$i][1], 40, 23)
    Else
    $iGegner[$i][0] += 45
    _GDIPlus_GraphicsDrawImageRect($hBuffer, $hImage_Gegner[$i], $iGegner[$i][0], $iGegner[$i][1], 40, 23)
    EndIf
    Next
    $iTimerGegner = TimerInit()
    EndIf
    _GDIPlus_GraphicsDrawImageRect($hBuffer, $hImage_Ship, $iX_Ship, $iY_Ship, 50, 30)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iGUIWidth, $iGUIHeight)
    Sleep(20)
    WEnd

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

    Func _Exit()
    DllClose($hU32DLL)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_GraphicsDispose($hBuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_ImageDispose($hImage_Ship)
    _GDIPlus_BrushDispose($hBrush_Shot)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

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

    ;------------------------------------------------------------------------------------------------------------
    ;
    ; Function _Array2DAdd(ByRef $avArray, $sValue='')
    ;
    ; Description Redim Array Size and add an Array element at last position
    ; Works with any occurences in 2nd Dimension
    ; Works also with 1D-Array
    ;
    ; Parameter $avArray Given Array
    ; optional $sValue Value of new Element, parts must be seperate with '|'
    ;
    ; Return Succes -1
    ; Failure 0 and set @error
    ; @error = 1 given array is not array
    ; @error = 2 given parts of Element too less/much
    ;
    ; Author BugFix ([email='bugfix@autoit.de'][/email])
    ;------------------------------------------------------------------------------------------------------------
    Func _Array2DAdd(ByRef $avArray, $sValue = '')
    If (Not IsArray($avArray)) Then
    SetError(1)
    Return 0
    EndIf
    Local $i
    Local $UBound2nd = UBound($avArray, 2)
    If @error = 2 Then
    ReDim $avArray[UBound($avArray) + 1]
    $avArray[UBound($avArray) - 1] = $sValue
    Else
    Local $arValue
    ReDim $avArray[UBound($avArray) + 1][$UBound2nd]
    If $sValue = '' Then
    For $i = 0 To $UBound2nd - 2
    $sValue &= '|'
    Next
    EndIf
    $arValue = StringSplit($sValue, '|')
    If $arValue[0] <> $UBound2nd Then
    SetError(2)
    Return 0
    EndIf
    For $i = 0 To $UBound2nd - 1
    $avArray[UBound($avArray) - 1][$i] = $arValue[$i + 1]
    Next
    EndIf
    Return -1
    EndFunc ;==>_Array2DAdd

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

    ;----------------------------------------------------------------------------------------------------------------------
    ; Fuction _Array2DDelete(ByRef $ARRAY, $iDEL)
    ;
    ; Description Delete one row on a given index in an 1D/2D -Array
    ;
    ; Parameter $ARRAY the array, where one row will deleted
    ; $iDEL Row-Index to delete
    ;
    ; Return Succes -1 ByRef $ARRAY
    ; Failure 0 set @error = 1; given array are not array
    ; set @error = 2; index is out of range
    ;
    ; Author BugFix ([email='bugfix@autoit.de'][/email])
    ;----------------------------------------------------------------------------------------------------------------------
    Func _Array2DDelete(ByRef $ARRAY, $iDEL)
    If (Not IsArray($ARRAY)) Then
    SetError(1)
    Return 0
    EndIf
    If ($iDEL < 0) Or ($iDEL > UBound($ARRAY) - 1) Then
    SetError(2)
    Return 0
    EndIf
    Local $i, $k, $l
    Local $UBound2nd = UBound($ARRAY, 2)
    If @error = 2 Then
    Local $arTmp[UBound($ARRAY) - 1]
    $k = 0
    For $i = 0 To UBound($ARRAY) - 1
    If $i <> $iDEL Then
    $arTmp[$k] = $ARRAY[$i]
    $k += 1
    EndIf
    Next
    Else
    Local $arTmp[UBound($ARRAY) - 1][$UBound2nd]
    $k = 0
    For $i = 0 To UBound($ARRAY) - 1
    If $i <> $iDEL Then
    For $l = 0 To $UBound2nd - 1
    $arTmp[$k][$l] = $ARRAY[$i][$l]
    Next
    $k += 1
    EndIf
    Next
    EndIf
    $ARRAY = $arTmp
    Return -1
    EndFunc ;==>_Array2DDelete

    [/autoit]

    ps: die bilder müssen in den img ordner :P

  • Du könntest dir wenigstens ein bisschen mehr Mühe geben. :(
    Ich kann nicht ALLES für dich machen, es ist ja schließlich DEIN Projekt. :D

    Spoiler anzeigen
    [autoit]

    #include <GDIPlus.au3>
    #include <Misc.au3>
    #include <Array.au3>
    #include <GUIConstantsEx.au3>

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

    Opt("GUIOnEventMode", 1)

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

    $iGUIWidth = 400
    $iGUIHeight = 400
    $GUIColorBG = 0xFF000000

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

    $iShots = 0
    $iMaxShots = 5 + 1
    $iShotSpeed = 3
    $iCoolDownTime = 500
    $iTimerShot = $iCoolDownTime * - 1
    $iTimerGegner = TimerInit()

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

    $hU32DLL = DllOpen("User32.dll")

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

    $hWnd = GUICreate("Space Invaders", $iGUIWidth, $iGUIHeight)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetState()

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

    _GDIPlus_Startup()

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

    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iGUIWidth, $iGUIHeight, $hGraphic)
    $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
    _GDIPlus_GraphicsClear($hGraphic, $GUIColorBG)

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

    $hImage_Enemy = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\gegner.jpg")
    $hImage_Ship = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Raumschiff.jpg")
    $hBrush_Shot = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)

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

    Dim $aGegner[2][2]
    For $i = 1 To 5
    _Array2DAdd($aGegner, 0 + (($i - 1) * 45) & "|" & 0)
    Next

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

    Dim $aShot[2][2]

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

    $iX_Ship = $iGUIWidth / 2 - 25
    $iY_Ship = $iGUIHeight - 30

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

    While 1
    If _IsPressed("27", $hU32DLL) And $iX_Ship < $iGUIWidth - 50 Then $iX_Ship += 2
    If _IsPressed("25", $hU32DLL) And $iX_Ship > 0 Then $iX_Ship -= 2
    If _IsPressed("20", $hU32DLL) And TimerDiff($iTimerShot) >= $iCoolDownTime And UBound($aShot) < $iMaxShots Then
    _Array2DAdd($aShot, $iX_Ship + 21 & "|" & $iY_Ship - 10)
    $iTimerShot = TimerInit()
    EndIf

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

    _GDIPlus_GraphicsClear($hBuffer, $GUIColorBG)
    For $i = 1 To UBound($aShot) - 1
    If $aShot[$i][1] <> "" Then
    _GDIPlus_GraphicsFillRect($hBuffer, $aShot[$i][0], $aShot[$i][1], 5, 10, $hBrush_Shot)
    $aShot[$i][1] -= $iShotSpeed
    EndIf
    Next
    For $i = 1 To UBound($aShot) - 1
    If $aShot[$i][1] <= 0 Then
    _Array2DDelete($aShot, $i)
    ExitLoop
    EndIf
    For $j = 2 To UBound($aGegner) - 1
    If $aShot[$i][1] <= $aGegner[$j][1] + 23 And $aShot[$i][0] >= $aGegner[$i][0] And $aShot[$i][0] <= $aGegner[$i][0] + 40 Then
    _Array2DDelete($aGegner, $j)
    ExitLoop
    EndIf
    Next
    Next
    If TimerDiff($iTimerGegner) >= 1000 Then
    For $i = 1 To UBound($aGegner) - 1
    If $aGegner[$i][0] + 40 >= $iGUIWidth Then
    $aGegner[$i][1] += 25
    $aGegner[$i][0] = 0
    Else
    $aGegner[$i][0] += 45
    EndIf
    Next
    $iTimerGegner = TimerInit()
    EndIf
    For $i = 1 To UBound($aGegner) - 1
    _GDIPlus_GraphicsDrawImageRect($hBuffer, $hImage_Enemy, $aGegner[$i][0], $aGegner[$i][1], 40, 23)
    Next
    _GDIPlus_GraphicsDrawImageRect($hBuffer, $hImage_Ship, $iX_Ship, $iY_Ship, 50, 30)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iGUIWidth, $iGUIHeight)
    Sleep(20)
    WEnd

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

    Func _Exit()
    DllClose($hU32DLL)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_GraphicsDispose($hBuffer)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_ImageDispose($hImage_Ship)
    _GDIPlus_BrushDispose($hBrush_Shot)
    _GDIPlus_Shutdown()
    Exit
    EndFunc ;==>_Exit

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

    ;------------------------------------------------------------------------------------------------------------
    ;
    ; Function _Array2DAdd(ByRef $avArray, $sValue='')
    ;
    ; Description Redim Array Size and add an Array element at last position
    ; Works with any occurences in 2nd Dimension
    ; Works also with 1D-Array
    ;
    ; Parameter $avArray Given Array
    ; optional $sValue Value of new Element, parts must be seperate with '|'
    ;
    ; Return Succes -1
    ; Failure 0 and set @error
    ; @error = 1 given array is not array
    ; @error = 2 given parts of Element too less/much
    ;
    ; Author BugFix ([email='bugfix@autoit.de'][/email])
    ;------------------------------------------------------------------------------------------------------------
    Func _Array2DAdd(ByRef $avArray, $sValue = '')
    If (Not IsArray($avArray)) Then
    SetError(1)
    Return 0
    EndIf
    Local $i
    Local $UBound2nd = UBound($avArray, 2)
    If @error = 2 Then
    ReDim $avArray[UBound($avArray) + 1]
    $avArray[UBound($avArray) - 1] = $sValue
    Else
    Local $arValue
    ReDim $avArray[UBound($avArray) + 1][$UBound2nd]
    If $sValue = '' Then
    For $i = 0 To $UBound2nd - 2
    $sValue &= '|'
    Next
    EndIf
    $arValue = StringSplit($sValue, '|')
    If $arValue[0] <> $UBound2nd Then
    SetError(2)
    Return 0
    EndIf
    For $i = 0 To $UBound2nd - 1
    $avArray[UBound($avArray) - 1][$i] = $arValue[$i + 1]
    Next
    EndIf
    Return -1
    EndFunc ;==>_Array2DAdd

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

    ;----------------------------------------------------------------------------------------------------------------------
    ; Fuction _Array2DDelete(ByRef $ARRAY, $iDEL)
    ;
    ; Description Delete one row on a given index in an 1D/2D -Array
    ;
    ; Parameter $ARRAY the array, where one row will deleted
    ; $iDEL Row-Index to delete
    ;
    ; Return Succes -1 ByRef $ARRAY
    ; Failure 0 set @error = 1; given array are not array
    ; set @error = 2; index is out of range
    ;
    ; Author BugFix ([email='bugfix@autoit.de'][/email])
    ;----------------------------------------------------------------------------------------------------------------------
    Func _Array2DDelete(ByRef $ARRAY, $iDEL)
    If (Not IsArray($ARRAY)) Then
    SetError(1)
    Return 0
    EndIf
    If ($iDEL < 0) Or ($iDEL > UBound($ARRAY) - 1) Then
    SetError(2)
    Return 0
    EndIf
    Local $i, $k, $l
    Local $UBound2nd = UBound($ARRAY, 2)
    If @error = 2 Then
    Local $arTmp[UBound($ARRAY) - 1]
    $k = 0
    For $i = 0 To UBound($ARRAY) - 1
    If $i <> $iDEL Then
    $arTmp[$k] = $ARRAY[$i]
    $k += 1
    EndIf
    Next
    Else
    Local $arTmp[UBound($ARRAY) - 1][$UBound2nd]
    $k = 0
    For $i = 0 To UBound($ARRAY) - 1
    If $i <> $iDEL Then
    For $l = 0 To $UBound2nd - 1
    $arTmp[$k][$l] = $ARRAY[$i][$l]
    Next
    $k += 1
    EndIf
    Next
    EndIf
    $ARRAY = $arTmp
    Return -1
    EndFunc ;==>_Array2DDelete

    [/autoit]


    Müsste so funktionieren, ich hab's noch nicht wirklich getestet. :rolleyes:

  • Zitat

    Danke, das funktioniert, nur wenn ich 1 töte, dann töte ich alle ausser 1 ^^


    Das hängt mit deinem Array zusammen ich hab im Moment leider keine Zeit mich damit zubeschäftigen. :(
    Schau dir mal an wie das 2 dimensionale Array von den Schüssen verwendet wird. ;)

  • Ok, habs gefunden damit er nicht alle tötet :D
    Aber jetzt ist das voll komisch, wenn ich den ersten töte, dann stirtb der 2te und wenn ich nicht den ersten töte passiert nichts.
    wenn ich den dritten danach töte stirbt der dritte, und wenn ich den ersten töte passiert nichts :D