snake mit button weiter zusammenbinden

  • Hallo frohe weihnachten !!!! :thumbup: :thumbup:
    habe snake im internet gefunden aber das fester habe ich selber gemacht
    so meine frage ist: wie bekomme ich snake(game) in button1= weiter rein?? ?( ich will nur ein skript machen!

    ich bin gespannt was ihr für forschläge habt ;) :D

    Spoiler anzeigen
    [autoit]


    ;Fenster:
    _______________________________________________________________________________________________

    [/autoit]

    #include <GUIConstants.au3>

    #Region ### START Koda GUI section ### Form=c:\dokumente und einstellungen\salvatore monachello\eigene dateien\snake.kxf
    $Form1_1 = GUICreate("Snake", 633, 447, 190, 119)
    $Button1 = GUICtrlCreateButton("Weiter", 488, 400, 113, 33, 0)
    $Button2 = GUICtrlCreateButton("Abbrechen", 343, 400, 113, 33, 0)
    $Label1 = GUICtrlCreateLabel("Spiele Snake auf Computer", 160, 32, 323, 33)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("Die Steuerung:", 256, 104, 111, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Die Steuerung erfolgt durch das Drücken der Pfeiltaste ", 152, 160, 300, 17)
    $Label4 = GUICtrlCreateLabel("Vorsicht das Spiel startet sofort!!!", 152, 176, 158, 17)
    $Label5 = GUICtrlCreateLabel("Viel Glück!!!!!!!!!", 160, 312, 79, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###


    While 1
    $msg=GuiGetMsg()
    If $msg=-3 Then Exit
    If $msg=$Button1 Then button1()
    If $msg=$Button2 Then button2()
    WEnd

    Func button1 () ;button=weiter
    sleep (100)

    Exit (1)
    EndFunc


    Func button2 () ;button=abbrechen
    Sleep (100)
    Exit (1)
    EndFunc

    ___________________________________________________________________________________________

    ;Fenster ende:

    ___________________________________________________________________________________________

    ;snake:

    ___________________________________________________________________________________________


    #include <GUIConstants.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>
    #include <ScreenCapture.au3>
    #include <Sound.au3>

    FileInstall("Snake2.png", @TempDir & "\Snake2.png", 1)
    FileInstall("Snake.wav", @TempDir & "\Snake.wav", 1)
    FileInstall("Snake1.wav", @TempDir & "\Snake1.wav", 1)
    FileInstall("Snake2.wav", @TempDir & "\Snake2.wav", 1)

    Global $sCatch = "123456789"
    Global $iCatch = StringLen($sCatch)

    Global $SND1 = _SoundOpen(@TempDir & "\Snake.wav")
    Global $SND2 = _SoundOpen(@TempDir & "\Snake1.wav")
    Global $SND3 = _SoundOpen(@TempDir & "\Snake2.wav")

    Global $hBitmap, $hScreen, $hGraphic, $hBrush, $hGUI, $hCursor, $hGraphic1
    Global $LeftID, $RightID, $DownID, $UpID
    Global $iDirection = 0, $iDirectionOld = 0, $iPosX, $iPosY, $iCount = 0, $iCPosX, $iCPosY
    Global $aPos[1000][3], $iSnakeLen = 0

    Global $DesktopWidth = @DesktopWidth, $DesktopHeight = @DesktopHeight
    $DesktopHeight -= Mod($DesktopHeight, 20)
    $DesktopWidth -= Mod($DesktopWidth, 20)
    Global $iRound = 1, $iCatchX = -50, $iCatchY = -50, $iLevel = 0, $iLevelMax = 6
    Global $aWall[2][2]
    $aWall[0][0] = 0

    _GDIPlus_Startup()

    $hBitmap = _ScreenCapture_Capture("", 0, 0, -1, -1, 0)
    $hScreen = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

    $hBrushSnake = _GDIPlus_BrushCreateSolid(0xFF00FF00)
    $hPenSnake = _GDIPlus_PenCreate(0xFF003300, 2)
    $hBrushWall = _GDIPlus_BrushCreateSolid(0xBBFF0000)
    $hBrushOutLine = _GDIPlus_BrushCreateSolid(0xBBFF0000)
    $hPenWall = _GDIPlus_PenCreate(0xFF330000, 2)

    $hBrushBlack = _GDIPlus_BrushCreateSolid(0xFF000000)

    $hBrushBk = _GDIPlus_BrushCreateSolid(0x110000FF)
    $hBrushCurShad = _GDIPlus_BrushCreateSolid(0x55000000)
    $hBrushCursor = _GDIPlus_BrushCreateSolid(0x66FF7700)

    $hGraphic1 = _GDIPlus_ImageGetGraphicsContext($hScreen)
    _GDIPlus_GraphicsFillRect($hGraphic1, 0, 0, $DesktopWidth, $DesktopHeight, $hBrushBk)
    $hCursor = _GDIPlus_BitmapCreateFromFile(@TempDir & "\Snake2.png")
    $iCPosX = $DesktopWidth - 125
    $iCPosY = $DesktopHeight - 100
    _GDIPlus_GraphicsFillRect($hGraphic1, $iCPosX + 32, $iCPosY, 28, 34, $hBrushCurShad)
    _GDIPlus_GraphicsFillRect($hGraphic1, $iCPosX, $iCPosY + 38, 28, 34, $hBrushCurShad)
    _GDIPlus_GraphicsFillRect($hGraphic1, $iCPosX + 32, $iCPosY + 38, 28, 34, $hBrushCurShad)
    _GDIPlus_GraphicsFillRect($hGraphic1, $iCPosX + 64, $iCPosY + 38, 28, 34, $hBrushCurShad)
    _GDIPlus_GraphicsFillRect($hGraphic1, 0, 0, $DesktopWidth, 20, $hBrushOutLine)
    _GDIPlus_GraphicsFillRect($hGraphic1, 0, $DesktopHeight - 20, $DesktopWidth, 20, $hBrushOutLine)
    _GDIPlus_GraphicsFillRect($hGraphic1, 0, 20, 20, $DesktopHeight - 40, $hBrushOutLine)
    _GDIPlus_GraphicsFillRect($hGraphic1, $DesktopWidth - 20, 20, $DesktopWidth, $DesktopHeight - 40, $hBrushOutLine)
    _GDIPlus_GraphicsDrawRect($hGraphic1, 19, 19, $DesktopWidth - 39, $DesktopHeight - 39, $hPenWall)
    $iCPosX += 5
    $iCPosY -= 5

    Opt("GuiOnEventMode", 1)
    Opt("PixelCoordMode", 2)

    $hGUI = GUICreate("Eukalyptus Snake", $DesktopWidth, $DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetBkColor(0x000000)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    $LeftID = GUICtrlCreateButton("", 0, -90)
    GUICtrlSetOnEvent(-1, "_Left")
    GUICtrlSetState(-1, $GUI_HIDE)
    $RightID = GUICtrlCreateButton("", 0, -70)
    GUICtrlSetOnEvent(-1, "_Right")
    GUICtrlSetState(-1, $GUI_HIDE)
    $DownID = GUICtrlCreateButton("", 0, -50)
    GUICtrlSetOnEvent(-1, "_Down")
    GUICtrlSetState(-1, $GUI_HIDE)
    $UpID = GUICtrlCreateButton("", 0, -30)
    GUICtrlSetOnEvent(-1, "_Up")
    GUICtrlSetState(-1, $GUI_HIDE)
    Dim $AccelKeys[4][2] = [["{Left}", $LeftID],["{Right}", $RightID],["{Down}", $DownID],["{Up}", $UpID]]
    GUISetAccelerators($AccelKeys)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_PAINT, '_Redraw')
    _GDIPlus_GraphicsDrawImage($hGraphic, $hScreen, 0, 0)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hCursor, $iCPosX, $iCPosY, 93, 73)

    _Success()

    While 1
    If $iCount >= 4 Then
    _NewDir()
    $iCount = 0
    EndIf
    $iCount += 1
    _Move()
    Sleep(20)
    If PixelGetColor(10, 10, $hGUI) = 0 Then
    _ReDraw(0, 0, 0, 0)
    EndIf
    WEnd

    Func _Round1()
    Return
    EndFunc ;==>_Round1

    Func _Round2()
    Local $iCnt = 0, $iX = 100
    While $iX < $DesktopWidth - 100
    $iCnt += 1
    ReDim $aWall[$iCnt + 1][2]
    $aWall[$iCnt][0] = $iX
    $aWall[$iCnt][1] = $DesktopHeight / 2
    $aWall[$iCnt][0] -= Mod($aWall[$iCnt][0], 20)
    $aWall[$iCnt][1] -= Mod($aWall[$iCnt][1], 20)
    $iX += 20
    WEnd
    $aWall[0][0] = $iCnt
    _DrawWall()
    EndFunc ;==>_Round2

    Func _Round5()
    Local $iCnt = 0, $iX = 40
    While $iX < $DesktopWidth - 30
    $iCnt += 1
    ReDim $aWall[$iCnt + 1][2]
    $aWall[$iCnt][0] = $iX
    $aWall[$iCnt][1] = $DesktopHeight / 2
    $aWall[$iCnt][0] -= Mod($aWall[$iCnt][0], 20)
    $aWall[$iCnt][1] -= Mod($aWall[$iCnt][1], 20)
    $iX += 40
    WEnd
    $aWall[0][0] = $iCnt
    _DrawWall()
    EndFunc ;==>_Round5

    Func _Round4()
    Local $iCnt = 0, $iX = 100
    For $i = 100 To $DesktopHeight - 100 Step 160
    $iX = 100
    While $iX < $DesktopWidth - 100
    $iCnt += 1
    ReDim $aWall[$iCnt + 1][2]
    $aWall[$iCnt][0] = $iX
    $aWall[$iCnt][1] = $i
    $aWall[$iCnt][0] -= Mod($aWall[$iCnt][0], 20)
    $aWall[$iCnt][1] -= Mod($aWall[$iCnt][1], 20)
    $iX += 20
    WEnd
    Next
    $aWall[0][0] = $iCnt
    _DrawWall()
    EndFunc ;==>_Round4

    Func _Round3()
    Local $iCnt = 0, $iX = 100
    While $iX < $DesktopWidth - 100
    $iCnt += 1
    ReDim $aWall[$iCnt + 1][2]
    $aWall[$iCnt][0] = $iX
    $aWall[$iCnt][1] = $DesktopHeight / 2
    $aWall[$iCnt][0] -= Mod($aWall[$iCnt][0], 20)
    $aWall[$iCnt][1] -= Mod($aWall[$iCnt][1], 20)
    $iX += 20
    WEnd
    $iX = 100
    While $iX < $DesktopHeight - 100
    $iCnt += 1
    ReDim $aWall[$iCnt + 1][2]
    $aWall[$iCnt][0] = $DesktopWidth / 2
    $aWall[$iCnt][1] = $iX
    $aWall[$iCnt][0] -= Mod($aWall[$iCnt][0], 20)
    $aWall[$iCnt][1] -= Mod($aWall[$iCnt][1], 20)
    $iX += 20
    WEnd
    $aWall[0][0] = $iCnt
    _DrawWall()
    EndFunc ;==>_Round3

    Func _DrawWall()
    Local $iX = $aWall[1][0], $iY = $aWall[1][1], $iDir = 0
    For $i = 1 To $aWall[0][0]
    _GDIPlus_GraphicsFillRect($hGraphic, $aWall[$i][0], $aWall[$i][1], 20, 20, $hBrushWall)
    If $i = 1 Then ContinueLoop
    If (($aWall[$i][0] - 20 = $aWall[$i - 1][0]) And ($aWall[$i - 1][1] = $aWall[$i][1])) Then
    $iDir = 0
    If $i < $aWall[0][0] Then ContinueLoop
    ElseIf (($aWall[$i][0] = $aWall[$i - 1][0]) And ($aWall[$i - 1][1] = $aWall[$i][1] - 20)) Then
    $iDir = 1
    If $i < $aWall[0][0] Then ContinueLoop
    Else
    If $iDir = 0 Then _GDIPlus_GraphicsDrawRect($hGraphic, $iX + 1, $aWall[$i - 1][1] + 1, $aWall[$i - 1][0] - $iX + 18, 18, $hPenWall)
    If $iDir = 1 Then _GDIPlus_GraphicsDrawRect($hGraphic, $aWall[$i - 1][0] + 1, $iY + 1, 18, $aWall[$i - 1][1] + 18, $hPenWall)
    $iX = $aWall[$i][0]
    $iY = $aWall[$i][1]
    EndIf
    If $i = $aWall[0][0] Then
    If $iDir = 0 Then _GDIPlus_GraphicsDrawRect($hGraphic, $iX + 1, $aWall[$i - 1][1] + 1, $aWall[$i][0] - $iX + 18, 18, $hPenWall)
    If $iDir = 1 Then _GDIPlus_GraphicsDrawRect($hGraphic, $aWall[$i - 1][0] + 1, $iY + 1, 18, $aWall[$i][1] - $iY + 18, $hPenWall)
    EndIf
    Next
    EndFunc ;==>_DrawWall

    Func _NewDir()
    Local $bCursor = False
    If $iDirectionOld <> $iDirection Then $bCursor = True
    _CheckCrash()
    If $bCursor = True Then
    Switch $iDirectionOld
    Case 0
    _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hCursor, 0, 38, 28, 34, $iCPosX, $iCPosY + 38, 28, 34)
    Case 1
    _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hCursor, 64, 38, 28, 34, $iCPosX + 64, $iCPosY + 38, 28, 34)
    Case 2
    _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hCursor, 32, 38, 28, 34, $iCPosX + 32, $iCPosY + 38, 28, 34)
    Case 3
    _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hCursor, 32, 0, 28, 34, $iCPosX + 32, $iCPosY, 28, 34)
    EndSwitch
    EndIf
    $iDirectionOld = $iDirection
    _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hScreen, $aPos[$iSnakeLen][0], $aPos[$iSnakeLen][1], 20, 20, $aPos[$iSnakeLen][0], $aPos[$iSnakeLen][1], 20, 20)
    If $aPos[$iSnakeLen][0] >= $iCPosX - 20 And $aPos[$iSnakeLen][1] >= $iCPosY - 20 Then _GDIPlus_GraphicsDrawImageRect($hGraphic, $hCursor, $iCPosX, $iCPosY, 93, 73)
    If $bCursor = True Or ($aPos[$iSnakeLen][0] >= $iCPosX - 20 And $aPos[$iSnakeLen][1] >= $iCPosY - 20) Then
    Switch $iDirectionOld
    Case 0
    _GDIPlus_GraphicsFillRect($hGraphic, $iCPosX, $iCPosY + 38, 28, 34, $hBrushCursor)
    Case 1
    _GDIPlus_GraphicsFillRect($hGraphic, $iCPosX + 64, $iCPosY + 38, 28, 34, $hBrushCursor)
    Case 2
    _GDIPlus_GraphicsFillRect($hGraphic, $iCPosX + 32, $iCPosY + 38, 28, 34, $hBrushCursor)
    Case 3
    _GDIPlus_GraphicsFillRect($hGraphic, $iCPosX + 32, $iCPosY, 28, 34, $hBrushCursor)
    EndSwitch
    EndIf
    For $i = $iSnakeLen To 1 Step -1
    $aPos[$i][0] = $aPos[$i - 1][0]
    $aPos[$i][1] = $aPos[$i - 1][1]
    $aPos[$i][2] = $aPos[$i - 1][2]
    Next
    $aPos[0][0] = $iPosX
    $aPos[0][1] = $iPosY
    $aPos[0][2] = $iDirectionOld
    EndFunc ;==>_NewDir

    Func _CheckCrash()
    If $iPosX <= 0 Or $iPosX >= $DesktopWidth - 20 Or $iPosY <= 0 Or $iPosY >= $DesktopHeight - 20 Then _Fail()
    For $i = 0 To $iSnakeLen
    If $iPosX = $aPos[$i][0] And $iPosY = $aPos[$i][1] Then _Fail()
    If $iPosX > $iCatchX - 10 And $iPosY > $iCatchY - 10 And $iPosX <= $iCatchX + 40 And $iPosY <= $iCatchY + 40 Then _NewRound()
    Next
    For $i = 0 To $aWall[0][0]
    If $iPosX = $aWall[$i][0] And $iPosY = $aWall[$i][1] Then _Fail()
    Next
    EndFunc ;==>_CheckCrash

    Func _NewRound()
    If StringMid($sCatch, $iRound, 1) = " " Then
    $iRound += 1
    Return
    EndIf
    Local $bSuc = False
    _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hScreen, $iCatchX, $iCatchY, 40, 40, $iCatchX, $iCatchY, 40, 40)
    Do
    $iCatchX = Random(50, $DesktopWidth - 90, 1)
    $iCatchY = Random(50, $DesktopHeight - 150, 1)
    $iCatchX -= Mod($iCatchX, 20)
    $iCatchY -= Mod($iCatchY, 20)
    For $i = 0 To $iSnakeLen
    If $iCatchX >= $aPos[$i][0] - 50 And $iCatchY >= $aPos[$i][1] - 50 And $iCatchX <= $aPos[$i][0] + 10 And $iCatchY <= $aPos[$i][1] + 10 Then
    $bSuc = False
    ExitLoop
    Else
    $bSuc = True
    EndIf
    Next
    If $bSuc = False Then ContinueLoop
    For $i = 0 To $aWall[0][0]
    If $iCatchX >= $aWall[$i][0] - 50 And $iCatchY >= $aWall[$i][1] - 50 And $iCatchX <= $aWall[$i][0] + 10 And $iCatchY <= $aWall[$i][1] + 10 Then
    $bSuc = False
    ExitLoop
    Else
    $bSuc = True
    EndIf
    Next
    Until $bSuc = True
    _SoundPlay($SND1, 0)
    _Write(StringMid($sCatch, $iRound, 1))
    _DrawPosRefresh(1, 0)
    $iRound += 1
    $iSnakeLen += 15
    If $iSnakeLen > 999 Then $iSnakeLen = 999
    If $iRound > $iCatch + 1 Then _Success()
    $iBlinkTimer = TimerInit()
    $bBlinkColor = True
    EndFunc ;==>_NewRound

    Func _Write($sString, $iX = $iCatchX, $iY = $iCatchY, $iC = 0)
    Local $iXL = StringLen($sString) * 40
    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 30, 1)
    Local $hBrush1 = $hBrushBlack
    Local $tLayout
    Local $aInfo
    For $i = -1 To 1
    For $j = -1 To 1
    $tLayout = _GDIPlus_RectFCreate($iX + $i * 2, $iY + $j * 2, $iXL, 40)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush1)
    Next
    Next
    $tLayout = _GDIPlus_RectFCreate($iX, $iY, $iXL, 40)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 30, 1)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    $hBrush1 = $hBrushSnake
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush1)
    EndFunc ;==>_Write

    Func _DrawPosRefresh($iS, $iE)
    For $i = $iS To $iE Step -1
    For $j = 1 To 4
    Switch $aPos[$i][2]
    Case 0
    _DrawPos($aPos[$i][0] - 5 * $j, $aPos[$i][1], $aPos[$i][2])
    Case 1
    _DrawPos($aPos[$i][0] + 5 * $j, $aPos[$i][1], $aPos[$i][2])
    Case 2
    _DrawPos($aPos[$i][0], $aPos[$i][1] + 5 * $j, $aPos[$i][2])
    Case 3
    _DrawPos($aPos[$i][0], $aPos[$i][1] - 5 * $j, $aPos[$i][2])
    EndSwitch
    Next
    Next
    EndFunc ;==>_DrawPosRefresh

    Func _DrawPos($iX, $iY, $iD)
    _GDIPlus_GraphicsFillRect($hGraphic, $iX + 2, $iY + 2, 16, 16, $hBrushSnake)
    Switch $iD
    Case 0
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 6, $iY + 1, $iX + 1, $iY + 1, $hPenSnake)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 1, $iY + 1, $iX + 1, $iY + 19, $hPenSnake)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 1, $iY + 19, $iX + 6, $iY + 19, $hPenSnake)
    Case 1
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 13, $iY + 1, $iX + 19, $iY + 1, $hPenSnake)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 19, $iY + 1, $iX + 19, $iY + 19, $hPenSnake)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 19, $iY + 19, $iX + 13, $iY + 19, $hPenSnake)
    Case 2
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 1, $iY + 13, $iX + 1, $iY + 19, $hPenSnake)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 1, $iY + 19, $iX + 19, $iY + 19, $hPenSnake)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 19, $iY + 19, $iX + 19, $iY + 13, $hPenSnake)
    Case 3
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 1, $iY + 6, $iX + 1, $iY + 1, $hPenSnake)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 1, $iY + 1, $iX + 19, $iY + 1, $hPenSnake)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 19, $iY + 1, $iX + 19, $iY + 6, $hPenSnake)
    EndSwitch
    If $iX >= $iCPosX - 20 And $iY >= $iCPosY - 20 Then
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hCursor, $iCPosX, $iCPosY, 93, 73)
    Switch $iDirectionOld
    Case 0
    _GDIPlus_GraphicsFillRect($hGraphic, $iCPosX, $iCPosY + 38, 28, 34, $hBrushCursor)
    Case 1
    _GDIPlus_GraphicsFillRect($hGraphic, $iCPosX + 64, $iCPosY + 38, 28, 34, $hBrushCursor)
    Case 2
    _GDIPlus_GraphicsFillRect($hGraphic, $iCPosX + 32, $iCPosY + 38, 28, 34, $hBrushCursor)
    Case 3
    _GDIPlus_GraphicsFillRect($hGraphic, $iCPosX + 32, $iCPosY, 28, 34, $hBrushCursor)
    EndSwitch
    EndIf
    EndFunc ;==>_DrawPos

    Func _Move()
    Switch $iDirectionOld
    Case 0
    $iPosX -= 5
    Case 1
    $iPosX += 5
    Case 2
    $iPosY += 5
    Case 3
    $iPosY -= 5
    EndSwitch
    _DrawPos($iPosX, $iPosY, $iDirectionOld)
    EndFunc ;==>_Move

    Func _Left()
    If $iDirectionOld <> 1 Then $iDirection = 0
    EndFunc ;==>_Left

    Func _Right()
    If $iDirectionOld <> 0 Then $iDirection = 1
    EndFunc ;==>_Right

    Func _Down()
    If $iDirectionOld <> 3 Then $iDirection = 2
    EndFunc ;==>_Down

    Func _Up()
    If $iDirectionOld <> 2 Then $iDirection = 3
    EndFunc ;==>_Up

    Func _ReDraw($hwnd, $msg, $wparam, $lparam)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hScreen, 0, 0)
    _DrawPosRefresh($iSnakeLen, 1)
    _Write(StringMid($sCatch, $iRound - 1, 1))
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hCursor, $iCPosX, $iCPosY, 93, 73)
    _DrawWall()
    Return $GUI_RUNDEFMSG
    EndFunc ;==>_ReDraw

    Func _Success()
    If $iLevel > 0 Then _SoundPlay($SND2, 1)
    For $i = 0 To 999
    $aPos[$i][0] = -50
    $aPos[$i][1] = -50
    $aPos[$i][2] = 5
    Next
    $iLevel += 1
    If $iLevel >= $iLevelMax Then _Exit()
    Call("_Round" & $iLevel)
    $iPosX = 20
    $iPosY = 20
    $aPos[0][0] = $iPosX
    $aPos[0][1] = $iPosY
    $iDirection = 1
    $iDirectionOld = 1
    $iSnakeLen = 0
    $iRound = 1
    $iCount = 0
    _NewRound()
    _ReDraw(0, 0, 0, 0)
    EndFunc ;==>_Success

    Func _Fail()
    _SoundPlay($SND3, 1)
    _Exit()
    EndFunc ;==>_Fail

    Func _Exit()
    _GDIPlus_Shutdown()
    FileDelete(@TempDir & "\Snake2.png")
    FileDelete(@TempDir & "\Snake.wav")
    FileDelete(@TempDir & "\Snake1.wav")
    FileDelete(@TempDir & "\Snake2.wav")
    Exit
    sleep(100)
    run("setup start.exe")

    EndFunc ;==>_Exit

    _____________________________________________________________________________________________
    ;snake ende:

    [autoit][/autoit]


    mfg
    und frohe weihnachten nochmals!!!!!

    2 Mal editiert, zuletzt von salvatore.luca (25. Dezember 2008 um 10:48)

  • Schönes Spiel, hierdurch läufts:

    Spoiler anzeigen
    [autoit]

    ;Fenster:

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

    #include

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

    #Region ### START Koda GUI section ### Form=c:\dokumente und einstellungen\salvatore monachello\eigene dateien\snake.kxf
    $Form1_1 = GUICreate("Snake", 633, 447, 190, 119)
    $Button1 = GUICtrlCreateButton("Weiter", 488, 400, 113, 33, 0)
    $Button2 = GUICtrlCreateButton("Abbrechen", 343, 400, 113, 33, 0)
    $Label1 = GUICtrlCreateLabel("Spiele Snake auf Computer", 160, 32, 323, 33)
    GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
    $Label2 = GUICtrlCreateLabel("Die Steuerung:", 256, 104, 111, 24)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $Label3 = GUICtrlCreateLabel("Die Steuerung erfolgt durch das Drücken der Pfeiltaste ", 152, 160, 300, 17)
    $Label4 = GUICtrlCreateLabel("Vorsicht das Spiel startet sofort!!!", 152, 176, 158, 17)
    $Label5 = GUICtrlCreateLabel("Viel Glück!!!!!!!!!", 160, 312, 79, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $msg=GuiGetMsg()
    If $msg=-3 Then Exit
    If $msg=$Button1 Then ExitLoop
    If $msg=$Button2 Then button2()
    WEnd

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

    ;~ Func button1 () ;button=weiter
    ;~ sleep (100)

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

    ;~ Exit(1) ;WÜRDE HEIßEN, DASS DAS SCRIPT BEENDET WIRD!!!
    ;~ EndFunc

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

    Func button2 () ;button=abbrechen
    Sleep (100)
    Exit (1)
    EndFunc
    ;Fenster ende:
    ;snake:
    #include
    #include
    #include
    #include
    #include

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

    FileInstall("Snake2.png", @TempDir & "\Snake2.png", 1)
    FileInstall("Snake.wav", @TempDir & "\Snake.wav", 1)
    FileInstall("Snake1.wav", @TempDir & "\Snake1.wav", 1)
    FileInstall("Snake2.wav", @TempDir & "\Snake2.wav", 1)

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

    Global $sCatch = "123456789"
    Global $iCatch = StringLen($sCatch)

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

    Global $SND1 = _SoundOpen(@TempDir & "\Snake.wav")
    Global $SND2 = _SoundOpen(@TempDir & "\Snake1.wav")
    Global $SND3 = _SoundOpen(@TempDir & "\Snake2.wav")

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

    Global $hBitmap, $hScreen, $hGraphic, $hBrush, $hGUI, $hCursor, $hGraphic1
    Global $LeftID, $RightID, $DownID, $UpID
    Global $iDirection = 0, $iDirectionOld = 0, $iPosX, $iPosY, $iCount = 0, $iCPosX, $iCPosY
    Global $aPos[1000][3], $iSnakeLen = 0

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

    Global $DesktopWidth = @DesktopWidth, $DesktopHeight = @DesktopHeight
    $DesktopHeight -= Mod($DesktopHeight, 20)
    $DesktopWidth -= Mod($DesktopWidth, 20)
    Global $iRound = 1, $iCatchX = -50, $iCatchY = -50, $iLevel = 0, $iLevelMax = 6
    Global $aWall[2][2]
    $aWall[0][0] = 0

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

    _GDIPlus_Startup()

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

    $hBitmap = _ScreenCapture_Capture("", 0, 0, -1, -1, 0)
    $hScreen = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)

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

    $hBrushSnake = _GDIPlus_BrushCreateSolid(0xFF00FF00)
    $hPenSnake = _GDIPlus_PenCreate(0xFF003300, 2)
    $hBrushWall = _GDIPlus_BrushCreateSolid(0xBBFF0000)
    $hBrushOutLine = _GDIPlus_BrushCreateSolid(0xBBFF0000)
    $hPenWall = _GDIPlus_PenCreate(0xFF330000, 2)

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

    $hBrushBlack = _GDIPlus_BrushCreateSolid(0xFF000000)

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

    $hBrushBk = _GDIPlus_BrushCreateSolid(0x110000FF)
    $hBrushCurShad = _GDIPlus_BrushCreateSolid(0x55000000)
    $hBrushCursor = _GDIPlus_BrushCreateSolid(0x66FF7700)

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

    $hGraphic1 = _GDIPlus_ImageGetGraphicsContext($hScreen)
    _GDIPlus_GraphicsFillRect($hGraphic1, 0, 0, $DesktopWidth, $DesktopHeight, $hBrushBk)
    $hCursor = _GDIPlus_BitmapCreateFromFile(@TempDir & "\Snake2.png")
    $iCPosX = $DesktopWidth - 125
    $iCPosY = $DesktopHeight - 100
    _GDIPlus_GraphicsFillRect($hGraphic1, $iCPosX + 32, $iCPosY, 28, 34, $hBrushCurShad)
    _GDIPlus_GraphicsFillRect($hGraphic1, $iCPosX, $iCPosY + 38, 28, 34, $hBrushCurShad)
    _GDIPlus_GraphicsFillRect($hGraphic1, $iCPosX + 32, $iCPosY + 38, 28, 34, $hBrushCurShad)
    _GDIPlus_GraphicsFillRect($hGraphic1, $iCPosX + 64, $iCPosY + 38, 28, 34, $hBrushCurShad)
    _GDIPlus_GraphicsFillRect($hGraphic1, 0, 0, $DesktopWidth, 20, $hBrushOutLine)
    _GDIPlus_GraphicsFillRect($hGraphic1, 0, $DesktopHeight - 20, $DesktopWidth, 20, $hBrushOutLine)
    _GDIPlus_GraphicsFillRect($hGraphic1, 0, 20, 20, $DesktopHeight - 40, $hBrushOutLine)
    _GDIPlus_GraphicsFillRect($hGraphic1, $DesktopWidth - 20, 20, $DesktopWidth, $DesktopHeight - 40, $hBrushOutLine)
    _GDIPlus_GraphicsDrawRect($hGraphic1, 19, 19, $DesktopWidth - 39, $DesktopHeight - 39, $hPenWall)
    $iCPosX += 5
    $iCPosY -= 5

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

    Opt("GuiOnEventMode", 1)
    Opt("PixelCoordMode", 2)

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

    $hGUI = GUICreate("Eukalyptus Snake", $DesktopWidth, $DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetBkColor(0x000000)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    $LeftID = GUICtrlCreateButton("", 0, -90)
    GUICtrlSetOnEvent(-1, "_Left")
    GUICtrlSetState(-1, $GUI_HIDE)
    $RightID = GUICtrlCreateButton("", 0, -70)
    GUICtrlSetOnEvent(-1, "_Right")
    GUICtrlSetState(-1, $GUI_HIDE)
    $DownID = GUICtrlCreateButton("", 0, -50)
    GUICtrlSetOnEvent(-1, "_Down")
    GUICtrlSetState(-1, $GUI_HIDE)
    $UpID = GUICtrlCreateButton("", 0, -30)
    GUICtrlSetOnEvent(-1, "_Up")
    GUICtrlSetState(-1, $GUI_HIDE)
    Dim $AccelKeys[4][2] = [["{Left}", $LeftID],["{Right}", $RightID],["{Down}", $DownID],["{Up}", $UpID]]
    GUISetAccelerators($AccelKeys)
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    GUISetState(@SW_SHOW)

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

    GUIRegisterMsg($WM_PAINT, '_Redraw')
    _GDIPlus_GraphicsDrawImage($hGraphic, $hScreen, 0, 0)
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hCursor, $iCPosX, $iCPosY, 93, 73)

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

    _Success()

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

    While 1
    If $iCount >= 4 Then
    _NewDir()
    $iCount = 0
    EndIf
    $iCount += 1
    _Move()
    Sleep(20)
    If PixelGetColor(10, 10, $hGUI) = 0 Then
    _ReDraw(0, 0, 0, 0)
    EndIf
    WEnd

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

    Func _Round1()
    Return
    EndFunc ;==>_Round1

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

    Func _Round2()
    Local $iCnt = 0, $iX = 100
    While $iX < $DesktopWidth - 100
    $iCnt += 1
    ReDim $aWall[$iCnt + 1][2]
    $aWall[$iCnt][0] = $iX
    $aWall[$iCnt][1] = $DesktopHeight / 2
    $aWall[$iCnt][0] -= Mod($aWall[$iCnt][0], 20)
    $aWall[$iCnt][1] -= Mod($aWall[$iCnt][1], 20)
    $iX += 20
    WEnd
    $aWall[0][0] = $iCnt
    _DrawWall()
    EndFunc ;==>_Round2

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

    Func _Round5()
    Local $iCnt = 0, $iX = 40
    While $iX < $DesktopWidth - 30
    $iCnt += 1
    ReDim $aWall[$iCnt + 1][2]
    $aWall[$iCnt][0] = $iX
    $aWall[$iCnt][1] = $DesktopHeight / 2
    $aWall[$iCnt][0] -= Mod($aWall[$iCnt][0], 20)
    $aWall[$iCnt][1] -= Mod($aWall[$iCnt][1], 20)
    $iX += 40
    WEnd
    $aWall[0][0] = $iCnt
    _DrawWall()
    EndFunc ;==>_Round5

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

    Func _Round4()
    Local $iCnt = 0, $iX = 100
    For $i = 100 To $DesktopHeight - 100 Step 160
    $iX = 100
    While $iX < $DesktopWidth - 100
    $iCnt += 1
    ReDim $aWall[$iCnt + 1][2]
    $aWall[$iCnt][0] = $iX
    $aWall[$iCnt][1] = $i
    $aWall[$iCnt][0] -= Mod($aWall[$iCnt][0], 20)
    $aWall[$iCnt][1] -= Mod($aWall[$iCnt][1], 20)
    $iX += 20
    WEnd
    Next
    $aWall[0][0] = $iCnt
    _DrawWall()
    EndFunc ;==>_Round4

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

    Func _Round3()
    Local $iCnt = 0, $iX = 100
    While $iX < $DesktopWidth - 100
    $iCnt += 1
    ReDim $aWall[$iCnt + 1][2]
    $aWall[$iCnt][0] = $iX
    $aWall[$iCnt][1] = $DesktopHeight / 2
    $aWall[$iCnt][0] -= Mod($aWall[$iCnt][0], 20)
    $aWall[$iCnt][1] -= Mod($aWall[$iCnt][1], 20)
    $iX += 20
    WEnd
    $iX = 100
    While $iX < $DesktopHeight - 100
    $iCnt += 1
    ReDim $aWall[$iCnt + 1][2]
    $aWall[$iCnt][0] = $DesktopWidth / 2
    $aWall[$iCnt][1] = $iX
    $aWall[$iCnt][0] -= Mod($aWall[$iCnt][0], 20)
    $aWall[$iCnt][1] -= Mod($aWall[$iCnt][1], 20)
    $iX += 20
    WEnd
    $aWall[0][0] = $iCnt
    _DrawWall()
    EndFunc ;==>_Round3

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

    Func _DrawWall()
    Local $iX = $aWall[1][0], $iY = $aWall[1][1], $iDir = 0
    For $i = 1 To $aWall[0][0]
    _GDIPlus_GraphicsFillRect($hGraphic, $aWall[$i][0], $aWall[$i][1], 20, 20, $hBrushWall)
    If $i = 1 Then ContinueLoop
    If (($aWall[$i][0] - 20 = $aWall[$i - 1][0]) And ($aWall[$i - 1][1] = $aWall[$i][1])) Then
    $iDir = 0
    If $i < $aWall[0][0] Then ContinueLoop
    ElseIf (($aWall[$i][0] = $aWall[$i - 1][0]) And ($aWall[$i - 1][1] = $aWall[$i][1] - 20)) Then
    $iDir = 1
    If $i < $aWall[0][0] Then ContinueLoop
    Else
    If $iDir = 0 Then _GDIPlus_GraphicsDrawRect($hGraphic, $iX + 1, $aWall[$i - 1][1] + 1, $aWall[$i - 1][0] - $iX + 18, 18, $hPenWall)
    If $iDir = 1 Then _GDIPlus_GraphicsDrawRect($hGraphic, $aWall[$i - 1][0] + 1, $iY + 1, 18, $aWall[$i - 1][1] + 18, $hPenWall)
    $iX = $aWall[$i][0]
    $iY = $aWall[$i][1]
    EndIf
    If $i = $aWall[0][0] Then
    If $iDir = 0 Then _GDIPlus_GraphicsDrawRect($hGraphic, $iX + 1, $aWall[$i - 1][1] + 1, $aWall[$i][0] - $iX + 18, 18, $hPenWall)
    If $iDir = 1 Then _GDIPlus_GraphicsDrawRect($hGraphic, $aWall[$i - 1][0] + 1, $iY + 1, 18, $aWall[$i][1] - $iY + 18, $hPenWall)
    EndIf
    Next
    EndFunc ;==>_DrawWall

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

    Func _NewDir()
    Local $bCursor = False
    If $iDirectionOld <> $iDirection Then $bCursor = True
    _CheckCrash()
    If $bCursor = True Then
    Switch $iDirectionOld
    Case 0
    _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hCursor, 0, 38, 28, 34, $iCPosX, $iCPosY + 38, 28, 34)
    Case 1
    _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hCursor, 64, 38, 28, 34, $iCPosX + 64, $iCPosY + 38, 28, 34)
    Case 2
    _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hCursor, 32, 38, 28, 34, $iCPosX + 32, $iCPosY + 38, 28, 34)
    Case 3
    _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hCursor, 32, 0, 28, 34, $iCPosX + 32, $iCPosY, 28, 34)
    EndSwitch
    EndIf
    $iDirectionOld = $iDirection
    _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hScreen, $aPos[$iSnakeLen][0], $aPos[$iSnakeLen][1], 20, 20, $aPos[$iSnakeLen][0], $aPos[$iSnakeLen][1], 20, 20)
    If $aPos[$iSnakeLen][0] >= $iCPosX - 20 And $aPos[$iSnakeLen][1] >= $iCPosY - 20 Then _GDIPlus_GraphicsDrawImageRect($hGraphic, $hCursor, $iCPosX, $iCPosY, 93, 73)
    If $bCursor = True Or ($aPos[$iSnakeLen][0] >= $iCPosX - 20 And $aPos[$iSnakeLen][1] >= $iCPosY - 20) Then
    Switch $iDirectionOld
    Case 0
    _GDIPlus_GraphicsFillRect($hGraphic, $iCPosX, $iCPosY + 38, 28, 34, $hBrushCursor)
    Case 1
    _GDIPlus_GraphicsFillRect($hGraphic, $iCPosX + 64, $iCPosY + 38, 28, 34, $hBrushCursor)
    Case 2
    _GDIPlus_GraphicsFillRect($hGraphic, $iCPosX + 32, $iCPosY + 38, 28, 34, $hBrushCursor)
    Case 3
    _GDIPlus_GraphicsFillRect($hGraphic, $iCPosX + 32, $iCPosY, 28, 34, $hBrushCursor)
    EndSwitch
    EndIf
    For $i = $iSnakeLen To 1 Step -1
    $aPos[$i][0] = $aPos[$i - 1][0]
    $aPos[$i][1] = $aPos[$i - 1][1]
    $aPos[$i][2] = $aPos[$i - 1][2]
    Next
    $aPos[0][0] = $iPosX
    $aPos[0][1] = $iPosY
    $aPos[0][2] = $iDirectionOld
    EndFunc ;==>_NewDir

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

    Func _CheckCrash()
    If $iPosX <= 0 Or $iPosX >= $DesktopWidth - 20 Or $iPosY <= 0 Or $iPosY >= $DesktopHeight - 20 Then _Fail()
    For $i = 0 To $iSnakeLen
    If $iPosX = $aPos[$i][0] And $iPosY = $aPos[$i][1] Then _Fail()
    If $iPosX > $iCatchX - 10 And $iPosY > $iCatchY - 10 And $iPosX <= $iCatchX + 40 And $iPosY <= $iCatchY + 40 Then _NewRound()
    Next
    For $i = 0 To $aWall[0][0]
    If $iPosX = $aWall[$i][0] And $iPosY = $aWall[$i][1] Then _Fail()
    Next
    EndFunc ;==>_CheckCrash

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

    Func _NewRound()
    If StringMid($sCatch, $iRound, 1) = " " Then
    $iRound += 1
    Return
    EndIf
    Local $bSuc = False
    _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hScreen, $iCatchX, $iCatchY, 40, 40, $iCatchX, $iCatchY, 40, 40)
    Do
    $iCatchX = Random(50, $DesktopWidth - 90, 1)
    $iCatchY = Random(50, $DesktopHeight - 150, 1)
    $iCatchX -= Mod($iCatchX, 20)
    $iCatchY -= Mod($iCatchY, 20)
    For $i = 0 To $iSnakeLen
    If $iCatchX >= $aPos[$i][0] - 50 And $iCatchY >= $aPos[$i][1] - 50 And $iCatchX <= $aPos[$i][0] + 10 And $iCatchY <= $aPos[$i][1] + 10 Then
    $bSuc = False
    ExitLoop
    Else
    $bSuc = True
    EndIf
    Next
    If $bSuc = False Then ContinueLoop
    For $i = 0 To $aWall[0][0]
    If $iCatchX >= $aWall[$i][0] - 50 And $iCatchY >= $aWall[$i][1] - 50 And $iCatchX <= $aWall[$i][0] + 10 And $iCatchY <= $aWall[$i][1] + 10 Then
    $bSuc = False
    ExitLoop
    Else
    $bSuc = True
    EndIf
    Next
    Until $bSuc = True
    _SoundPlay($SND1, 0)
    _Write(StringMid($sCatch, $iRound, 1))
    _DrawPosRefresh(1, 0)
    $iRound += 1
    $iSnakeLen += 15
    If $iSnakeLen > 999 Then $iSnakeLen = 999
    If $iRound > $iCatch + 1 Then _Success()
    $iBlinkTimer = TimerInit()
    $bBlinkColor = True
    EndFunc ;==>_NewRound

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

    Func _Write($sString, $iX = $iCatchX, $iY = $iCatchY, $iC = 0)
    Local $iXL = StringLen($sString) * 40
    Local $hFormat = _GDIPlus_StringFormatCreate()
    Local $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local $hFont = _GDIPlus_FontCreate($hFamily, 30, 1)
    Local $hBrush1 = $hBrushBlack
    Local $tLayout
    Local $aInfo
    For $i = -1 To 1
    For $j = -1 To 1
    $tLayout = _GDIPlus_RectFCreate($iX + $i * 2, $iY + $j * 2, $iXL, 40)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush1)
    Next
    Next
    $tLayout = _GDIPlus_RectFCreate($iX, $iY, $iXL, 40)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 30, 1)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat)
    $hBrush1 = $hBrushSnake
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $hFormat, $hBrush1)
    EndFunc ;==>_Write

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

    Func _DrawPosRefresh($iS, $iE)
    For $i = $iS To $iE Step -1
    For $j = 1 To 4
    Switch $aPos[$i][2]
    Case 0
    _DrawPos($aPos[$i][0] - 5 * $j, $aPos[$i][1], $aPos[$i][2])
    Case 1
    _DrawPos($aPos[$i][0] + 5 * $j, $aPos[$i][1], $aPos[$i][2])
    Case 2
    _DrawPos($aPos[$i][0], $aPos[$i][1] + 5 * $j, $aPos[$i][2])
    Case 3
    _DrawPos($aPos[$i][0], $aPos[$i][1] - 5 * $j, $aPos[$i][2])
    EndSwitch
    Next
    Next
    EndFunc ;==>_DrawPosRefresh

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

    Func _DrawPos($iX, $iY, $iD)
    _GDIPlus_GraphicsFillRect($hGraphic, $iX + 2, $iY + 2, 16, 16, $hBrushSnake)
    Switch $iD
    Case 0
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 6, $iY + 1, $iX + 1, $iY + 1, $hPenSnake)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 1, $iY + 1, $iX + 1, $iY + 19, $hPenSnake)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 1, $iY + 19, $iX + 6, $iY + 19, $hPenSnake)
    Case 1
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 13, $iY + 1, $iX + 19, $iY + 1, $hPenSnake)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 19, $iY + 1, $iX + 19, $iY + 19, $hPenSnake)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 19, $iY + 19, $iX + 13, $iY + 19, $hPenSnake)
    Case 2
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 1, $iY + 13, $iX + 1, $iY + 19, $hPenSnake)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 1, $iY + 19, $iX + 19, $iY + 19, $hPenSnake)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 19, $iY + 19, $iX + 19, $iY + 13, $hPenSnake)
    Case 3
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 1, $iY + 6, $iX + 1, $iY + 1, $hPenSnake)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 1, $iY + 1, $iX + 19, $iY + 1, $hPenSnake)
    _GDIPlus_GraphicsDrawLine($hGraphic, $iX + 19, $iY + 1, $iX + 19, $iY + 6, $hPenSnake)
    EndSwitch
    If $iX >= $iCPosX - 20 And $iY >= $iCPosY - 20 Then
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hCursor, $iCPosX, $iCPosY, 93, 73)
    Switch $iDirectionOld
    Case 0
    _GDIPlus_GraphicsFillRect($hGraphic, $iCPosX, $iCPosY + 38, 28, 34, $hBrushCursor)
    Case 1
    _GDIPlus_GraphicsFillRect($hGraphic, $iCPosX + 64, $iCPosY + 38, 28, 34, $hBrushCursor)
    Case 2
    _GDIPlus_GraphicsFillRect($hGraphic, $iCPosX + 32, $iCPosY + 38, 28, 34, $hBrushCursor)
    Case 3
    _GDIPlus_GraphicsFillRect($hGraphic, $iCPosX + 32, $iCPosY, 28, 34, $hBrushCursor)
    EndSwitch
    EndIf
    EndFunc ;==>_DrawPos

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

    Func _Move()
    Switch $iDirectionOld
    Case 0
    $iPosX -= 5
    Case 1
    $iPosX += 5
    Case 2
    $iPosY += 5
    Case 3
    $iPosY -= 5
    EndSwitch
    _DrawPos($iPosX, $iPosY, $iDirectionOld)
    EndFunc ;==>_Move

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

    Func _Left()
    If $iDirectionOld <> 1 Then $iDirection = 0
    EndFunc ;==>_Left

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

    Func _Right()
    If $iDirectionOld <> 0 Then $iDirection = 1
    EndFunc ;==>_Right

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

    Func _Down()
    If $iDirectionOld <> 3 Then $iDirection = 2
    EndFunc ;==>_Down

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

    Func _Up()
    If $iDirectionOld <> 2 Then $iDirection = 3
    EndFunc ;==>_Up

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

    Func _ReDraw($hwnd, $msg, $wparam, $lparam)
    _GDIPlus_GraphicsDrawImage($hGraphic, $hScreen, 0, 0)
    _DrawPosRefresh($iSnakeLen, 1)
    _Write(StringMid($sCatch, $iRound - 1, 1))
    _GDIPlus_GraphicsDrawImageRect($hGraphic, $hCursor, $iCPosX, $iCPosY, 93, 73)
    _DrawWall()
    Return $GUI_RUNDEFMSG
    EndFunc ;==>_ReDraw

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

    Func _Success()
    If $iLevel > 0 Then _SoundPlay($SND2, 1)
    For $i = 0 To 999
    $aPos[$i][0] = -50
    $aPos[$i][1] = -50
    $aPos[$i][2] = 5
    Next
    $iLevel += 1
    If $iLevel >= $iLevelMax Then _Exit()
    Call("_Round" & $iLevel)
    $iPosX = 20
    $iPosY = 20
    $aPos[0][0] = $iPosX
    $aPos[0][1] = $iPosY
    $iDirection = 1
    $iDirectionOld = 1
    $iSnakeLen = 0
    $iRound = 1
    $iCount = 0
    _NewRound()
    _ReDraw(0, 0, 0, 0)
    EndFunc ;==>_Success

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

    Func _Fail()
    _SoundPlay($SND3, 1)
    _Exit()
    EndFunc ;==>_Fail

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

    Func _Exit()
    _GDIPlus_Shutdown()
    FileDelete(@TempDir & "\Snake2.png")
    FileDelete(@TempDir & "\Snake.wav")
    FileDelete(@TempDir & "\Snake1.wav")
    FileDelete(@TempDir & "\Snake2.wav")
    Exit
    sleep(100)
    run("setup start.exe")

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

    EndFunc ;==>_Exit

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

    ;snake ende:

    [/autoit]


    An deiner Stelle würd ich noch eine Meldung machen, wenn man verliert, nicht einfach beenden.P.S.: Ach, und Forschlag schreibt man mit "V".

    Twitter: @L3viathan2142
    Benutze AutoIt persönlich nicht mehr, da ich keinen Windows-Rechner mehr besitze.

  • ok danke ;) aber ich wollte das ich durch den button weiter auf das spiel zugreife mit nur ein skript
    bitte um weitere hilfe

  • sry :( ich kann mich vielleicht schlecht ausdrücken also ich meine siehste oben das ist ein fenster mit zwei buttons(zeile 28=button1)(zeile35=button2) unten ist das spiel ,wenn ich auf button abbrechen gehe dann geht das fenster zu aber wenn ich auf weiter gehe ,soll das spel starten jetzt ist meine frage wie kann ich das spiel bei der funktion (zeile 28 ) in zeile 3 soll die funktion des spiel rein damit das skript das spiel öffnet

    [autoit]

    Func button1 () ;button=weiter
    sleep (100)

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

    Exit (1)
    EndFunc

    [/autoit]

    einfügen??
    Sodass ich auf weiter gehe das spiel auf geht und das fenster sich automatisch sich wieder schließt??
    am ende soll das spiel und das fenster nur in einem skript zusammen sein hoffe du hast es verstanden wenn nicht frag mich bitte vielen dank :)

    2 Mal editiert, zuletzt von salvatore.luca (25. Dezember 2008 um 16:17)

  • hi bei mir kommt immer eine fehlermeldung wenn ich auf weiter drücke kommt error und mehr nichts :(
    bei dir hat es funktioniert?

  • @L3viathan2142: Bei dir fehlen die includes. es steht nur #include ohne daruffolgende Datei da ;)
    @salvatore.luca: du musst einfach deine Inlcude wieder einfügen und die leeren #include-Zeilen löschen.
    //Edit: v3 gibt es schon lange :) aber die unterversionen sind interessant. Die neuesete ist v3.3.0.0 ;)

  • sry wie meist du das?? ich bin leider nur ein dummer anfänger könntest du es mir bitte zeigen ?(

  • Bei leviathan steht z.B.
    in Zeile 4: #include
    da fehlt die Datei, die eingebunden werden soll. In deinem Skript steht ans dieser Stelle
    #include <GUIConstants.au3>
    das musst du ändern und das Skript sollte starten...

    oder meinst du die Version? -> Rechtsklick auf AutoIt.exe -> Eigenschaften -> Version -> Dateiversion
    oder in Skript mit fogendem Inhalt:

    [autoit]

    MsgBox(0,"Verision",@AutoItVersion)

    [/autoit]
  • ok verstanden aber in was soll ich das ändern könntest du vielleicht es mir einfügen das wie du es meinst als autoitcode??? bitte ;)

  • also, du musst:
    -Zeile 4 von dir in Zeie 4 von leviathan einsetzen
    -Zeile 63 bis 67 in Zeile 41 bis 45 einsetzen ...
    und den ganzen Code werde ich nicht posten, da das nicht so schwer ist ...

  • ich bin euch sehr sehr dankbar echt sry so ein aufstand gemacht zu haben (peinlich) ich habe es nicht verstanden was bei mir nur geändert werden sollte :rock::thumbup::thumbup: ihr seid die besten :thumbup::thumbup::thumbup::thumbup: