1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. bollen

Beiträge von bollen

  • AutoIt Gartenplanungs-Projekt

    • bollen
    • 13. März 2017 um 17:58

    die funktion die du warscheinlich suchst lautet

    AutoIt
    $hGraphics=_GDIPlus_GraphicsCreateFromHWND ( $hWnd )
    _GDIPlus_GraphicsDrawRect($hGraphics, $iX, $iY, $iWidth, $iHeight , $hPen )

    in der Hilfe ist zu den meisten GDI Funktionen jeweils ein beispiel dabei in dem gezeigt wird was erstellt werden muss um erfolgreich in ein GUI zu zeichnen

    deine Funktion erstellt nur eine Struktur die ein Rechteck über die Eckpunkte beschreibt.

  • Labyrinth-Generator

    • bollen
    • 9. März 2017 um 23:50

    das muss morgen noch ausgebessert werden :whistling: wo ist den der zweite buffer ?(
    hab eine Armselige C Version fertig bitte über die Console mit 2 Argumenten starten und nicht größer als 11500 das macht das BMP komischerweise nicht mit ?( Source Code folgt wie gewohnt :whistling:

  • Labyrinth-Generator

    • bollen
    • 9. März 2017 um 20:45

    Hallo AutoIt Gemeinde,
    seit kurzem hat mich das schlechte Wetter wider zu AutoIt gebracht und da ich nichts zu tun wusste hab ich aus Spaß ein Labyrinth Generator erstellt
    wärend die c Version des scriptes langsam ein funktionalen zustand erreicht würde mich eure Meinung zu diesem Erguss interessieren :D:D

    AutoIt: Maze
    ; ===============================================================================================================================
    ; Title .........: Maze_generator
    ; AutoIt Version : 3.3.12.0
    ; Description ...: Script zum erzeugen beliebig großer Labyrinthe Rechteckigem uhrsprungs
    ; Author ........: Matthias
    ; Modified ......:
    ; ===============================================================================================================================
    #include <Gdiplus.au3>
    #include <Misc.au3>
    Global $swapcolour = 0
    Global $maze, $xBlocks, $yBlocks, $backup, $cpx, $cpy, $Solution_GUI, $kasten = 0, $dir, $error, $startx, $starty, $endex, $endey, $loesung, $timer, $splitter, $zeitcounter, $zeit, $hGraphics, $ES_NUMBER = 8192, $solvex, $solvey
    HotKeySet("{ESC}", "_exit")
    _GDIPlus_Startup()
    $Main_GUI = GUICreate("Maze", 289, 342, 192, 124)
    $Input_X_Blocks = GUICtrlCreateInput(150, 40, 20, 121, 21, $ES_NUMBER)
    $Input_Y_Blocks = GUICtrlCreateInput(150, 40, 60, 121, 21, $ES_NUMBER)
    $Input_startx = GUICtrlCreateInput(1, 40, 140, 121, 21, $ES_NUMBER)
    $Input_starty = GUICtrlCreateInput(1, 40, 180, 121, 21, $ES_NUMBER)
    $Input_endex = GUICtrlCreateInput(150, 40, 220, 121, 21, $ES_NUMBER)
    $Input_endey = GUICtrlCreateInput(150, 40, 260, 121, 21, $ES_NUMBER)
    GUICtrlCreateLabel("X Blocks", 176, 20, 236, 17)
    GUICtrlCreateLabel("Y Blocks", 176, 60, 236, 17)
    $id_LABEL_AnzahlBlocks = GUICtrlCreateLabel("Anzahl an Feldern " & GUICtrlRead($Input_X_Blocks) * GUICtrlRead($Input_Y_Blocks), 40, 100, 236, 17)
    GUICtrlCreateLabel("START X", 176, 140, 236, 17)
    GUICtrlCreateLabel("START Y", 176, 180, 236, 17)
    GUICtrlCreateLabel("ENDE X", 176, 220, 236, 17)
    GUICtrlCreateLabel("ENDE Y", 176, 260, 236, 17)
    $Button_Create = GUICtrlCreateButton("Create", 40, 296, 75, 25)
    $Progress1 = GUICtrlCreateProgress(4, 320, 280, 20)
    GUISetState(@SW_SHOW)
    While 1
    	$nMsg = GUIGetMsg()
    	Switch $nMsg
    		Case -3
    			_exit()
    		Case $Input_X_Blocks
    			GUICtrlSetData($Input_endex, GUICtrlRead($Input_X_Blocks))
    			GUICtrlSetData($id_LABEL_AnzahlBlocks, "Anzahl an Feldern " & GUICtrlRead($Input_X_Blocks) * GUICtrlRead($Input_Y_Blocks))
    		Case $Input_Y_Blocks
    			GUICtrlSetData($Input_endey, GUICtrlRead($Input_Y_Blocks))
    			GUICtrlSetData($id_LABEL_AnzahlBlocks, "Anzahl an Feldern " & GUICtrlRead($Input_X_Blocks) * GUICtrlRead($Input_Y_Blocks))
    		Case $Button_Create
    			$xBlocks = GUICtrlRead($Input_X_Blocks) + 2
    			$yBlocks = GUICtrlRead($Input_Y_Blocks) + 2
    			$startx = GUICtrlRead($Input_startx)
    			$starty = GUICtrlRead($Input_starty)
    			$endex = GUICtrlRead($Input_endex)
    			$endey = GUICtrlRead($Input_endey)
    			Select;falscheingaben abfangen
    				Case $xBlocks < 4
    					MsgBox(0, "", "Wert in X Blocks zu klein, mindestens 2")
    				Case $yBlocks < 4
    					MsgBox(0, "", "Wert in Y Blocks zu klein, mindestens 2")
    				Case $startx < 1 Or $startx > $xBlocks - 2
    					MsgBox(0, "", "Startwert x liegt außerhalb")
    				Case $starty < 1 Or $starty > $yBlocks - 2
    					MsgBox(0, "", "Startwert y liegt außerhalb")
    				Case $endex > $xBlocks - 2 Or $endex < 1
    					MsgBox(0, "", "Ziel x liegt außerhalb")
    				Case $endey > $yBlocks - 2 Or $endey < 1
    					MsgBox(0, "", "Ziel y liegt außerhalb")
    				Case Else;wenn alle falscheingaben gefiltert sind (start/ziel identisch ist kein fehler nur Dumm)
    					$cpx = $startx;$cpx=current position x
    					$cpy = $starty;$cpx=current position y
    					$anzahlblocks = (($xBlocks - 2) * ($yBlocks - 2) - 1)
    					Dim $maze[$xBlocks][$yBlocks];2D Feld Array
    					$wi = (@DesktopHeight - 40) / (($xBlocks < $yBlocks) ? $yBlocks : $xBlocks) * 0.98;Breite/Höhe der Kästchen, abhängig von der Anzahl
    					_setwalls();ränder erstellen
    ;~ 					SRandom(255);												Setseed für tests (geschwindigkeit) immer die gleichen zahlenfolgen ergeben immer das selbe Ergebnis
    					$timer = TimerInit()
    					_createMaze();erzeugen des feldes
    					$timer1Diff = Round((TimerDiff($timer) / 1000), 2)
    					_drawmaze();zeichnen
    			EndSelect
    	EndSwitch
    WEnd
    Func _setwalls();Randbegrenzungen als solche festlegen
    	For $i1 = 0 To $xBlocks - 1
    		$maze[$i1][0] = 16;16 als rand da beim zeichnen die ersten 4 bits die 4 wände darstellen, sind alle 0 werden alle gezeichnet
    		$maze[$i1][$yBlocks - 1] = 16
    	Next
    	For $i1 = 0 To $yBlocks - 1
    		$maze[0][$i1] = 16
    		$maze[$xBlocks - 1][$i1] = 16
    	Next
    EndFunc   ;==>_setwalls
    Func _createMaze()
    	AdlibRegister("update_progress")
    	Do
    		$dir = Random(1, 4, 1);bewegungsrichtung
    		If $cpx = $endex And $cpy = $endey Then $loesung = $backup;ziel erreicht
    		If ($maze[$cpx][$cpy - 0x1] And $maze[$cpx][$cpy + 0x1] And $maze[$cpx + 0x1][$cpy] And $maze[$cpx - 0x1][$cpy]) Then;alle felder belegt(backstep) oder noch eins frei(math)
    			_backstep()
    		Else
    			_math()
    		EndIf
    	Until $anzahlblocks = $kasten ;bis alle blöcke betreten wurden(außer rand)
    	AdlibUnRegister("update_progress")
    EndFunc   ;==>_createMaze
    
    
    Func _math()
    	Switch $dir
    		Case 1
    			If Not $maze[$cpx][$cpy - 0x1] Then;N
    				$maze[$cpx][$cpy] += 0x1;aktuelle position updaten +1 nach oben offen
    				$cpy -= 0x1 ;positionsupdate
    				$maze[$cpx][$cpy] = 0x4 ;zielposition updaten +4 nach unten offen
    				$backup &= $dir ;Um zurückzufinden richtung speichern
    				$kasten += 0x1 ;anzahl der betretenen kästchen erhöhen
    			EndIf
    		Case 2
    			If Not $maze[$cpx + 0x1][$cpy] Then;O
    				$maze[$cpx][$cpy] += 0x2
    				$cpx += 0x1
    				$maze[$cpx][$cpy] = 0x8
    				$backup &= $dir
    				$kasten += 0x1
    			EndIf
    		Case 3
    			If Not $maze[$cpx][$cpy + 0x1] Then;S
    				$maze[$cpx][$cpy] += 0x4
    				$cpy += 0x1
    				$maze[$cpx][$cpy] = 0x1
    				$backup &= $dir
    				$kasten += 0x1
    			EndIf
    		Case 4
    			If Not $maze[$cpx - 0x1][$cpy] Then;W
    				$maze[$cpx][$cpy] += 0x8
    				$cpx -= 0x1
    				$maze[$cpx][$cpy] = 0x2
    				$backup &= $dir
    				$kasten += 0x1
    			EndIf
    	EndSwitch
    EndFunc   ;==>_math
    Func _backstep()
    	$backupteil = StringRight($backup, 1);letzte ziffer holen
    	$backup = StringTrimRight($backup, 1);letzte ziffer abschneiden
    	Switch $backupteil
    		Case 1
    			$cpy += 0x1
    		Case 2
    			$cpx -= 0x1
    		Case 3
    			$cpy -= 0x1
    		Case 4
    			$cpx += 0x1
    	EndSwitch
    EndFunc   ;==>_backstep
    Func _exit()
    	_GDIPlus_Shutdown()
    	Exit
    EndFunc   ;==>_exit
    Func _drawmaze()
    	$Solution_GUI = GUICreate("", @DesktopHeight - 40, @DesktopHeight - 40, -1, -1, 0x80000000);gui mit $WS_POPUP style
    	GUISetBkColor(($swapcolour ? 0xFF000000 : 0xFFFFFFFF), $Solution_GUI)
    	GUISetState(@SW_SHOW, $Solution_GUI)
    	GUISetState(@SW_HIDE, $Main_GUI)
    	$hGraphics = _GDIPlus_GraphicsCreateFromHWND($Solution_GUI)
    	_GDIPlus_GraphicsClear($hGraphics, ($swapcolour ? 0xFFFFFFFF : 0xFF000000))
    	_GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)
    	$bitmap = _GDIPlus_BitmapCreateFromGraphics(@DesktopHeight - 40, @DesktopHeight - 40, $hGraphics)
    	$buffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
    	Global $black = $swapcolour ? _GDIPlus_PenCreate(0xFF000000) : _GDIPlus_PenCreate(0xFFFFFFFF)
    	$red = _GDIPlus_PenCreate(0xFFFF0000)
    	$red2 = _GDIPlus_PenCreate(0xFFFF0000, $wi * 0.8);Stift für läufer
    	$start = _GDIPlus_PenCreate(0xFF00FF00, $wi);Stift für start
    	$Temp_01 = 10 + ($wi / 2)
    	$solvex = $startx
    	$solvey = $starty
    	GDIPlus_GraphicsDrawLine($buffer, 10, ($yBlocks - 1) * $wi + 10 + $wi, $xBlocks * $wi + 10, ($yBlocks - 1) * $wi + 10 + $wi);fehlende Südwand
    	GDIPlus_GraphicsDrawLine($buffer, 10, 10, 10, ($yBlocks - 1) * $wi + $wi + 10);fehlende Westwand
    	For $i1 = 0 To $xBlocks - 1
    		$wi2 = $i1 * $wi + 10
    		For $i2 = 0 To $yBlocks - 1
    			If (BitAND($maze[$i1][$i2], 0x1) = 0) Then GDIPlus_GraphicsDrawLine($buffer, $wi2, $i2 * $wi + 10, $wi2 + $wi, $i2 * $wi + 10) ;Norden und
    			If (BitAND($maze[$i1][$i2], 0x2) = 0) Then GDIPlus_GraphicsDrawLine($buffer, $wi2 + $wi, $i2 * $wi + 10 + $wi, $wi2 + $wi, $i2 * $wi + 10);Osten reichen wenn man sie bei jedem Feld zeichnet (Fehlender Rand im Westen und Süden wurde oben behoben)
    		Next
    	Next
    	GDIPlus_GraphicsDrawLine($buffer, ($startx * $wi - ($wi / 2)) + $wi + 10, ($starty * $wi) + 10, ($startx * $wi - ($wi / 2)) + $wi + 10, ($starty * $wi + $wi) + 10, $start);start
    	GDIPlus_GraphicsDrawLine($buffer, ($endex * $wi - ($wi / 2)) + $wi + 10, ($endey * $wi) + 10, ($endex * $wi - ($wi / 2)) + $wi + 10, ($endey * $wi + $wi) + 10, $red2);ende
    	_GDIPlus_GraphicsDrawImage($buffer, $bitmap, 0, 0)
    	_GDIPlus_GraphicsDrawImage($hGraphics, $bitmap, 0, 0)
    	If MsgBox(4, "LÖSEN?", "es hat " & $timer1Diff & " Sekunden gedauert " & $anzahlblocks + 1 & "  felder zu erstellen" & @CRLF & "Soll das Labyrint gelöst werden?") = 6 Then
    		$splitter = StringSplit($loesung, "")
    		For $1a = 1 To (UBound($splitter) - 1);lösungsweg zeichnen
    			Switch $splitter[$1a]
    				Case 1;N
    					GDIPlus_GraphicsDrawLine($buffer, $solvex * $wi + $Temp_01, $solvey * $wi + $Temp_01, $solvex * $wi + $Temp_01, $solvey * $wi + $Temp_01 - $wi, $red)
    					$solvey -= 1
    				Case 2;O
    					GDIPlus_GraphicsDrawLine($buffer, $solvex * $wi + $Temp_01, $solvey * $wi + $Temp_01, $solvex * $wi + $Temp_01 + $wi, $solvey * $wi + $Temp_01, $red)
    					$solvex += 1
    				Case 3;S
    					GDIPlus_GraphicsDrawLine($buffer, $solvex * $wi + $Temp_01, $solvey * $wi + $Temp_01, $solvex * $wi + $Temp_01, $solvey * $wi + $Temp_01 + $wi, $red)
    					$solvey += 1
    				Case 4;W
    					GDIPlus_GraphicsDrawLine($buffer, $solvex * $wi + $Temp_01, $solvey * $wi + $Temp_01, $solvex * $wi + $Temp_01 - $wi, $solvey * $wi + $Temp_01, $red)
    					$solvex -= 1
    			EndSwitch
    		Next
    		_GDIPlus_GraphicsDrawImage($hGraphics, $bitmap, 0, 0)
    		$solvex = 0;keine fertig meldung beim automatisch lösen
    	EndIf
    	_GDIPlus_GraphicsDrawImage($buffer, $bitmap, 0, 0)
    	$hGraphics = _GDIPlus_GraphicsCreateFromHWND($Solution_GUI)
    	_GDIPlus_GraphicsClear($hGraphics, ($swapcolour ? 0xFFFFFFFF : 0xFF000000))
    	_GDIPlus_GraphicsDrawImage($hGraphics, $bitmap, 0, 0)
    	GDIPlus_GraphicsDrawLine($hGraphics, ($solvex * $wi - ($wi / 2)) + $wi + 10, 2 + (($solvey * $wi) + 10), ($solvex * $wi - ($wi / 2)) + $wi + 10, (($solvey * $wi + $wi) + 10) - 2, $red2)
    	Do
    		Sleep(100)
    		If _IsPressed(57) And BitAND($maze[$solvex][$solvey], 1) = 1 Then;bewegung und wandtest		N
    			$solvey -= 1;w
    			$Temp_01 = 1
    		EndIf
    		If _IsPressed(41) And BitAND($maze[$solvex][$solvey], 8) = 8 Then;bewegung und wandtest		W
    			$solvex -= 1;a
    			$Temp_01 = 1
    		EndIf
    		If _IsPressed(53) And BitAND($maze[$solvex][$solvey], 4) = 4 Then;bewegung und wandtest		S
    			$solvey += 1;s
    			$Temp_01 = 1
    		EndIf
    		If _IsPressed(44) And BitAND($maze[$solvex][$solvey], 2) = 2 Then;bewegung und wandtest		O
    			$solvex += 1;d
    			$Temp_01 = 1
    		EndIf
    		If $Temp_01 Then;Anzeige updaten
    			_GDIPlus_GraphicsClear($hGraphics, ($swapcolour ? 0xFFFFFFFF : 0xFF000000))
    			_GDIPlus_GraphicsDrawImage($hGraphics, $bitmap, 0, 0)
    			GDIPlus_GraphicsDrawLine($hGraphics, ($solvex * $wi - ($wi / 2)) + $wi + 10, 2 + (($solvey * $wi) + 10), ($solvex * $wi - ($wi / 2)) + $wi + 10, (($solvey * $wi + $wi) + 10) - 2, $red2)
    			$Temp_01 = 0
    		EndIf
    		If $solvex = $endex And $solvey = $endey Then;am Ende angekommen
    			MsgBox(0, "", "Sie haben gewonnen!!")
    			_GDIPlus_BitmapDispose($bitmap);Aufräumen
    			_GDIPlus_PenDispose($red)
    			_GDIPlus_PenDispose($red2)
    			_GDIPlus_PenDispose($start)
    			_GDIPlus_GraphicsDispose($hGraphics)
    			_exit();beenden
    		EndIf
    	Until GUIGetMsg() = -3
    EndFunc   ;==>_drawmaze
    Func update_progress()
    	GUICtrlSetData($Progress1, 100 / ($xBlocks * $yBlocks - $xBlocks - $yBlocks) * $kasten, "")
    EndFunc   ;==>update_progress
    Func GDIPlus_GraphicsDrawLine($hGraphics, $iX1, $iY1, $iX2, $iY2, $hPen = $black);kein errorhandling kein zeitverlust :D
    	DllCall($__g_hGDIPDll, "int", "GdipDrawLineI", "handle", $hGraphics, "handle", $hPen, "int", $iX1, "int", $iY1, "int", $iX2, "int", $iY2)
    EndFunc   ;==>GDIPlus_GraphicsDrawLine
    Alles anzeigen

    €: C Version im Anhang mit Visual Studio 2015 erstellt Maze in C++.zip

  • Makierter/ausgewählter Text (ohne Clipboard) kopieren/importieren

    • bollen
    • 9. Februar 2016 um 18:45

    Aktuelle Win10 version hat die Dll standartmäßig dabei, selten das bei Windows was in richtung Abwertskompatibilität flöten geht mit fällt spontan nichts ein :/

  • Space Invader

    • bollen
    • 9. Februar 2016 um 18:27

    Das nicht sterben Problem ist bereits gelöst ^^

  • Mit _GDIPlus_TextureCreate2 gefülltem Brush mit der Maus zeichnen

    • bollen
    • 8. Februar 2016 um 23:48

    Die form des gezeichneten objects hat nichts mit dem Brush zu tun sondern mit dem Object welches du füllst

    AutoIt
    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <GDIPlus.au3>
    ;~ #include <GDIP.au3>
    #include <Misc.au3>
    
    
    Opt('MouseCoordMode', 2)
    
    
    Global $dll = DllOpen('user32.dll')
    Global $msg
    Global $img
    Global $width = 600, $height = 600
    Global $hBrush,$iX,$iY
    Global $hWnd = GUICreate("", 600, 647)
    Global $brush = GUICtrlCreateButton("Brush", 100, 616, 57, 25, $WS_GROUP)
    Global $pen = GUICtrlCreateButton("Pen", 200, 616, 65, 25, $WS_GROUP)
    Global $quit = GUICtrlCreateButton("Beenden", 500, 616, 57, 25, $WS_GROUP)
    
    
    GUISetState(@SW_SHOW)
    
    
    _GDIPlus_Startup()
    
    
    
    
    
    
    Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    Global $hBitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphics)
    Global $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    Global $hPen = _GDIPlus_PenCreate(0xFFFFFFF, 3)
    
    
    AdlibRegister("_newCoords", 100)
    
    
    While 1
    	$msg = GUIGetMsg()
    
    
    
    
    	Switch $msg
    		Case $GUI_EVENT_CLOSE
    			_Exit()
    		Case $quit
    			_Exit()
    		Case $brush
    			_SetBrush()
    		Case $pen
    			;_SetPen()
    	EndSwitch
    WEnd
    
    
    
    
    
    
    Func _SetBrush()
    	Local $img1 = FileOpenDialog("Bild auswählen", "", "Bilder (*.jpg;*.png;*.bmp;*.tif)")
    		$img = _GDIPlus_ImageLoadFromFile($img1)
    	 $iX = _GDIPlus_ImageGetWidth ($img)
    	 $iY = _GDIPlus_ImageGetHeight ($img)
    	$hBrush = _GDIPlus_TextureCreate2($img, 0, 0, $iX, $iY, 0)
    EndFunc
    
    
    
    
    
    
    Func _newCoords()
    	Local $mpos = GUIGetCursorInfo()
    	If IsArray($mpos) Then
    		If $mpos[2] = 1 Then
    Sleep(50)
    _GDIPlus_GraphicsFillEllipse($hBackbuffer, $mpos[0], $mpos[1], $iX, $iY, $hBrush)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $width, $height)
    		EndIf
    	EndIf
    EndFunc
    
    
    
    
    
    
    Func _Exit()
    	AdlibUnRegister("_newCoords")
    	_GDIPlus_PenDispose($hPen)
    	_GDIPlus_BitmapDispose($hBitmap)
    	_GDIPlus_ImageDispose($hBackbuffer)
    	_GDIPlus_GraphicsDispose($hGraphics)
    	_GDIPlus_BrushDispose($hBrush)
    	_GDIPlus_ImageDispose($img)
    	_GDIPlus_Shutdown()
    	Exit
    EndFunc
    Exit
    Alles anzeigen
  • Makierter/ausgewählter Text (ohne Clipboard) kopieren/importieren

    • bollen
    • 8. Februar 2016 um 19:31

    Die Funktionen sind mir wohlbekannt ich dachte das es eventuell eine schnuckelige AutoIt Lösung gibt ohne frische DLL calls erstellen zu müssen

    wenn wir doch was erstellen wollen geht es einfacher
    so schickt man ein Prozess schlafen !Passt auf was ihr Suspendet!

    AutoIt
    #RequireAdmin
    #include<Winapi.au3>
    $pid=XXXX
    $handle=_WinAPI_OpenProcess(0x0800,False ,$pid)
    DllCall("ntdll.dll","long","NtSuspendProcess","handle",$handle)


    und so kann man ihn wider aufwecken

    AutoIt
    #RequireAdmin
    #include<Winapi.au3>
    $pid=XXXX
    $handle=_WinAPI_OpenProcess(0x0800,False ,$pid)
    DllCall("ntdll.dll","long","NtResumeProcess","handle",$handle)
  • Makierter/ausgewählter Text (ohne Clipboard) kopieren/importieren

    • bollen
    • 8. Februar 2016 um 18:38

    Man könnte auch den Prozess des Clipboard History Programmes anhalten den Inhalt des Clipboards kopieren und zwischenspeichern. Jetzt nur noch den markierten Text in die Zwischenablage verfrachten auslesen und den Ausgangszustand wider herstellen. Wenn nun der Prozess wider fortgesetzt wird sollte er nichts bemerkt haben. :part:
    Nur scheitert der plan an meinem unvollständigen wissen wie man einen Prozess mit AutoIt Bordmitteln anhält :Face:
    evntuell mit _WinAPI_SetProcessAffinityMask

  • Space Invader

    • bollen
    • 7. Februar 2016 um 19:56

    Gerade entdeckt das man nicht verlieren kann...... :whistling:
    ich setz mich nacher nochmal schnell drann und bastel den rest dazu

    €: nach einer guten Stunde hartem Kampf :thumbup: den rest zum laufen gebracht nur die hit detektion der Deckung muss noch gemacht werden der Rest sollte zufriedenstellend funktionieren

    AutoIt
    #include <GUIConstantsEx.au3>
    #include <Gdiplus.au3>
    #include <Misc.au3>
    #include <Array.au3>
    #include <Timers.au3>
    Global $breite = 600 ;fenstergröße, mindestens:400
    Global $hoehe = $breite;fenstergröße
    Global $groese = 10; höhe/(breite) des feldes
    Global $difficulti = 2;0=Profi 1=Schwer 2=Normal 3=Leicht
    Global $movespace = Floor($groese / 2)
    Global $scale = $breite / 16 / ($groese + $movespace);größe der objekte
    Global $shipspeed = $scale * 4, $shippos_x = 0, $shippos_y = $hoehe - 24 * $scale - 30
    Global $firespeed = $scale * 6;6
    Global $firedelay = 333;3 Geschosse pro sek.
    Global $lifes=3
    Global $wave = 0, $score = 0, $speed = 400, $posx = 0, $posy = 0, $counter, $killcounter = 0, $dir = 1;startposition
    Global $enemy[5][11] = [[384, 2016, 16380, 32766, 32766, 29646, 16380, 1632, 3504, 6168, 12300],[4104, 2064, 8184, 15324, 32766, 24570, 20490, 20082, 0, 0, 0],[384, 960, 2016, 3504, 8184, 8184, 576, 1440, 2640, 0, 0],[960, 4080, 8184, 16380, 28086, 65535, 14748, 4104, 0, 0, 0],[448, 8188, 16382, 15518, 16382, 864, 1712, 6156, 0, 0, 0]];gegnerform 16x11 pixel
    Global $hide[11] = [65535, 65535, 65535, 65535, 63519, 61455, 57351, 57351, 57351, 57351, 0]
    Global $ship[11] = [384, 384, 960, 960, 8184, 16380, 16380, 16380, 0, 0, 0]
    Global $life[11]= [30750,64575,65151,65535,32766,16380,8184,4080,2016,960,384]
    Global $Field[$groese][Ceiling($groese/$difficulti)];gegnerflotte
    Global $EnemyPaths[5], $HidePath[Floor($groese / 4) + 1], $bullets[2][3] = [[1, 0, 0]];[x][Y]=X=laufende NR Y=0=Xpos Y=1=Ypos Y=2=Dir/Speed
    For $ie = 0 To $groese - 1
    	For $ie2 = 0 To Ceiling($groese/$difficulti) - 1
    			$killcounter += 1
    			$Field[$ie][$ie2] = Random(0, 4, 1)
    	Next
    Next
    _GDIPlus_Startup()
    $Form1 = GUICreate("Invader", $breite, $hoehe)
    GUISetState(@SW_SHOW)
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($Form1)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($breite, $hoehe, $hGraphics)
    $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    $brush_grau = _GDIPlus_BrushCreateSolid(0xFF888888)
    $brush_blau = _GDIPlus_BrushCreateSolid(0xFF0000FF)
    $brush_gruen = _GDIPlus_BrushCreateSolid(0xFF00FF00)
    $brush_rot = _GDIPlus_BrushCreateSolid(0xFFFF0000)
    $brush_white = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
    $pen_white = _GDIPlus_PenCreate(0xFFFFFFFF, $scale, 2)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
    $hFont_big = _GDIPlus_FontCreate($hFamily, $hoehe/8, 2)
    $tWaverect = _GDIPlus_RectFCreate(10, $hoehe - 20, 100, 20)
    $tScorerect = _GDIPlus_RectFCreate(110, $hoehe - 20, 150, 20)
    $tSpeedrect = _GDIPlus_RectFCreate(260, $hoehe - 20, 160, 20)
    $tWin_loose_rect = _GDIPlus_RectFCreate($breite / 4, $hoehe /4, $breite / 2, $hoehe/2)
    For $i0 = 0 To 4
    	$__Temp = _GDIPlus_PathCreate()
    	For $i1 = 0 To 10
    		For $i2 = 0 To 15
    			if BitAND(BitShift(1, $i2 * -1), $enemy[$i0][$i1]) Then _GDIPlus_PathAddRectangle($__Temp, $i2 * $scale, $i1 * $scale, $scale, $scale)
    		Next
    	Next
    	$EnemyPaths[$i0] = _GDIPlus_RegionCreateFromPath($__Temp);kostengünstig ein Gegner erstellt
    Next
    $__Temp = _GDIPlus_PathCreate()
    For $i1 = 0 To 10
    	For $i2 = 0 To 15
    		if (BitAND(BitShift(1, $i2 * -1), $ship[$i1])) then _GDIPlus_PathAddRectangle($__Temp, $i2 * $scale, $i1 * $scale + $shippos_y, $scale, $scale)
    	Next
    Next
    $shipPath = _GDIPlus_RegionCreateFromPath($__Temp)
    $__Temp = _GDIPlus_PathCreate()
    For $i1 = 0 To 10
    	For $i2 = 0 To 15
    		if (BitAND(BitShift(1, $i2 * -1), $hide[$i1])) then _GDIPlus_PathAddRectangle($__Temp, $i2 * $scale, $i1 * $scale + $hoehe - 40 * $scale - 30, $scale, $scale)
    	Next
    Next
    For $i1 = 0 To Floor($groese / 4)
    	$HidePath[$i1] = _GDIPlus_RegionCreateFromPath($__Temp)
    	_GDIPlus_RegionTranslate($HidePath[$i1], $i1 * ($breite / ($groese / 4)), 0)
    Next
    $__Temp = _GDIPlus_PathCreate()
    For $i1 = 0 To 10
    	For $i2 = 0 To 15
    		if (BitAND(BitShift(1, $i2 * -1), $life[$i1])) then _GDIPlus_PathAddRectangle($__Temp, $i2 * $scale, $i1 * $scale+(11*$scale) + $shippos_y, $scale, $scale)
    	Next
    Next
    $lifePath = _GDIPlus_RegionCreateFromPath($__Temp)
    $movetimer = _Timer_Init()
    $shoottimer = _Timer_Init()
    $firetimer = _Timer_SetTimer($Form1, 50,"movebullets")
    $firetimer_enemy = _Timer_SetTimer($Form1,1000,"enemyfire")
    $Drawtimer = _Timer_SetTimer($Form1,33,"_draw");30 Fps
    While 1
    	If $killcounter = 0 Then _win()
    	$nMsg = GUIGetMsg()
    	Switch $nMsg
    		Case $GUI_EVENT_CLOSE
    			Exit
    	EndSwitch
    	If _IsPressed("27") And $shippos_x < $breite - 16 * $scale Then
    		$shippos_x += $shipspeed
    		_GDIPlus_RegionTranslate($shipPath, +$shipspeed, 0)
    	EndIf
    	If _IsPressed("25") And $shippos_x > 0 Then
    		$shippos_x -= $shipspeed
    		_GDIPlus_RegionTranslate($shipPath, -$shipspeed, 0)
    	EndIf
    	If _IsPressed("20") And _Timer_Diff($shoottimer) > $firedelay Then _fire(-1)
    	If _Timer_Diff($movetimer) > $speed Then move()
    WEnd
    Func _draw($hWnd, $iMsg, $iIDTimer, $iTime)
    	For $i1 = 0 To $groese - 1
    		For $i2 = 0 To Ceiling($groese/$difficulti) - 1;feld enthällt immer den index des zu zeichnenden objekts
    			Switch $Field[$i1][$i2];object wird in position translatet und gezeichnet danch wider zurück
    				Case 0
    					_GDIPlus_RegionTranslate($EnemyPaths[0], ($i1 * 16 * $scale) + $posx, ($i2 * 16 * $scale) + $posy)
    					_GDIPlus_GraphicsFillRegion($hBuffer, $EnemyPaths[0], $brush_grau)
    					_GDIPlus_RegionTranslate($EnemyPaths[0], -($i1 * 16 * $scale) - $posx, -($i2 * 16 * $scale) - $posy)
    				Case 1
    					_GDIPlus_RegionTranslate($EnemyPaths[1], ($i1 * 16 * $scale) + $posx, ($i2 * 16 * $scale) + $posy)
    					_GDIPlus_GraphicsFillRegion($hBuffer, $EnemyPaths[1], $brush_blau)
    					_GDIPlus_RegionTranslate($EnemyPaths[1], -($i1 * 16 * $scale) - $posx, -($i2 * 16 * $scale) - $posy)
    				Case 2
    					_GDIPlus_RegionTranslate($EnemyPaths[2], ($i1 * 16 * $scale) + $posx, ($i2 * 16 * $scale) + $posy)
    					_GDIPlus_GraphicsFillRegion($hBuffer, $EnemyPaths[2], $brush_gruen)
    					_GDIPlus_RegionTranslate($EnemyPaths[2], -($i1 * 16 * $scale) - $posx, -($i2 * 16 * $scale) - $posy)
    				Case 3
    					_GDIPlus_RegionTranslate($EnemyPaths[3], ($i1 * 16 * $scale) + $posx, ($i2 * 16 * $scale) + $posy)
    					_GDIPlus_GraphicsFillRegion($hBuffer, $EnemyPaths[3], $brush_rot)
    					_GDIPlus_RegionTranslate($EnemyPaths[3], -($i1 * 16 * $scale) - $posx, -($i2 * 16 * $scale) - $posy)
    				Case 4
    					_GDIPlus_RegionTranslate($EnemyPaths[4], ($i1 * 16 * $scale) + $posx, ($i2 * 16 * $scale) + $posy)
    					_GDIPlus_GraphicsFillRegion($hBuffer, $EnemyPaths[4], $brush_white)
    					_GDIPlus_RegionTranslate($EnemyPaths[4], -($i1 * 16 * $scale) - $posx, -($i2 * 16 * $scale) - $posy)
    			EndSwitch
    		Next
    	Next
    	For $i1 = 0 To Floor($groese / 4);erstellen der Deckung
    		_GDIPlus_GraphicsFillRegion($hBuffer, $HidePath[$i1], $brush_gruen)
    	Next
    	For $i1 = 1 To $bullets[0][0];geschosse einzeichnen
    		_GDIPlus_GraphicsDrawLine($hBuffer, $bullets[$i1][0], $bullets[$i1][1], $bullets[$i1][0], $bullets[$i1][1] - $scale * 2, $pen_white)
    	Next
    	For $1=0 to $lifes-1;leben zeichnen
    	_GDIPlus_RegionTranslate($lifePath ,20*$scale*$1 ,0)
    	_GDIPlus_GraphicsFillRegion($hBuffer, $lifePath,$brush_rot)
    	_GDIPlus_RegionTranslate($lifePath ,-20*$scale*$1 ,0)
    	Next
    	_GDIPlus_GraphicsFillRegion($hBuffer, $shipPath, $brush_white);schiff zeichnen region wird translatet um die pos zu erreichen
    	_GDIPlus_GraphicsDrawStringEx($hBuffer, "Speed: " & Round(400 / $speed, 3), $hFont, $tSpeedrect, $hFormat, $brush_white)
    	_GDIPlus_GraphicsDrawStringEx($hBuffer, "Wave: " & $wave, $hFont, $tWaverect, $hFormat, $brush_white)
    	_GDIPlus_GraphicsDrawStringEx($hBuffer, "Score: " & $score, $hFont, $tScorerect, $hFormat, $brush_white)
    	_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0);Buffer zeichnen
    	_GDIPlus_GraphicsFillRect($hBuffer, 0, 0, $breite, $hoehe);buffer leeren
    EndFunc
    Func movebullets($hWnd, $iMsg, $iIDTimer, $iTime);bewegt/zerstört geschosse, hit detection, Score
    	For $i1 = 1 To $bullets[0][0]
    		$bullets[$i1][1] += $bullets[$i1][2]
    		If $bullets[$i1][1] < 0 Or $bullets[$i1][1] > $hoehe Then
    			_ArrayDelete($bullets, $i1)
    			$bullets[0][0] -= 1
    			movebullets(0,0,0,0);rekursiver aufruf da sonst  for to nicht mehr stimmt
    			Return;ruft sich solange selber auf bis alle kugeln weg sind die außerhalb des feldes liegen
    		EndIf
    	Next
    	For $i1 = 1 To $bullets[0][0];hit detection
    		If $bullets[$i1][1] > $shippos_y Then;;wenn das schiff getroffen wird
    			If $bullets[$i1][0] >$shippos_x and $bullets[$i1][0]<$shippos_x+$scale*16 Then
    			_loose()
    			_ArrayDelete($bullets, $i1);kugel löschen
    			$bullets[0][0] -= 1;anzahl der kugeln anpassen
    			movebullets(0,0,0,0)
    			Return
    			EndIf
    		EndIf
    		$__Temp01 = ($bullets[$i1][0] - $posx) / ($scale * 16);kugel pos X im feld
    		$__Temp02 = ($bullets[$i1][1] - $posy) / ($scale * 16);kugel pos Y im feld
    		If $__Temp01 < $groese And $__Temp01 > 0 Then;X pos im gegnerfeld
    			If $__Temp02 < Ceiling($groese/$difficulti) And $__Temp02 > 0 Then;Y pos im gegnerfeld
    				If $Field[Floor($__Temp01)][Floor($__Temp02)] <> -1 Then;und gegner vorhanden
    					Switch $Field[Floor($__Temp01)][Floor($__Temp02)];score je nach gegner erhöhen
    						Case 0
    							$score += 10
    						Case 1
    							$score += 20
    						Case 2
    							$score += 25
    						Case 3
    							$score += 35
    						Case 4
    							$score += 50
    					EndSwitch
    					$Field[Floor($__Temp01)][Floor($__Temp02)] = -1;gegner löschen
    					_ArrayDelete($bullets, $i1);kugel löschen
    					$killcounter -= 1
    					$bullets[0][0] -= 1;anzahl der kugeln anpassen
    					movebullets(0,0,0,0);rekursiver aufruf da sonst  for to nicht mehr stimmt wenn ein array element gelöscht wird (do until alternative)
    					Return;ruft sich solange selber auf bis alle kugeln weg sind die außerhalb des feldes liegen
    				EndIf
    			EndIf
    		EndIf
    	Next
    EndFunc   ;==>movebullets
    Func _fire($obj);-1=ship 0-$groese=gegner ,erstellt Geschosse
    	ReDim $bullets[$bullets[0][0] + 2][3]
    	$bullets[0][0] += 1
    	If $obj = -1 Then
    		$shoottimer = _Timer_Init()
    		$bullets[$bullets[0][0]][0] = $shippos_x + $scale * 8;schiffposition X
    		$bullets[$bullets[0][0]][1] = $shippos_y;schiffposition Y
    		$bullets[$bullets[0][0]][2] = -$firespeed; Geschwindigkeit der Geschosse in Pixel pro 50ms
    	Else
    		For $1=Ceiling($groese/$difficulti)-1 to 0 step -1;der vorderste gegner muss schießen
    			If $Field[$obj][$1]<>-1 Then
    				$shoottimer = _Timer_Init()
    				$bullets[$bullets[0][0]][1] = $posy+5 + ($1+1) * $scale * 16
    				$bullets[$bullets[0][0]][0] = $posx + ($obj-.5+Random(0,1))* $scale * 16 + $scale * 8;random.. sorgt für dezent abweichende schusspfade so das keine sichere stellen entstehen
    				$bullets[$bullets[0][0]][2] = +$firespeed
    				ExitLoop
    		EndIf
    			Next
    	EndIf
    EndFunc   ;==>_fire
    Func move();bewegt Schiffflotte
    	$counter += 1
    	If $counter = $movespace + 1 Then
    		If $dir = 1 Then
    			$dir = 0
    		Else
    			$dir = 1
    			$posy += $scale * 12
    			$speed -= $scale * 6
    		EndIf
    		$counter = 1
    	EndIf
    	If $dir = 1 Then
    		$posx += $scale * 16
    	Else
    		$posx -= $scale * 16
    	EndIf
    	$movetimer = _Timer_Init();timer zurücksetzen
    EndFunc   ;==>move
    Func _win()
    	_GDIPlus_GraphicsDrawStringEx($hBuffer, "WIN", $hFont_big, $tWin_loose_rect, $hFormat, $brush_gruen)
    	_draw(0,0,0,0)
    
    
    	For $ie = 0 To $groese - 1;;neues level erstellen
    	For $ie2 = 0 To Ceiling($groese/$difficulti) - 1
    			$killcounter += 1
    			$Field[$ie][$ie2] = Random(0, 4, 1)
    	Next
    Next
    $posx=0;;pos zurücksetzen
    $posy=0;;dito
    $lifes+=1;;leben um 1 erhöhen pro level
    $bullets[0][0]=0; schüsse löschen
    $speed=400-(($speed-400)/100);erhöt die geschwindigkeit um 1% der geschwindigkeitsdifferez zwischen start und ende der runde
    EndFunc   ;==>_win
    Func _loose()
    	$lifes-=1
    	If $lifes >0 Then
    
    
    	Else
    	_GDIPlus_GraphicsDrawStringEx($hBuffer, "RIP", $hFont_big, $tWin_loose_rect, $hFormat, $brush_gruen)
    	_Timer_KillAllTimers ( $Form1);killt die mit _Timer_SetTimer erstellten timer
    	_Timer_KillTimer ( $Form1, $movetimer );killt den rest
    	_Timer_KillTimer ( $Form1, $shoottimer )
    _draw(0,0,0,0)
    EndIf
    EndFunc   ;==>_win
    Func enemyfire($hWnd, $iMsg, $iIDTimer, $iTime)
    	For $1=0 to 9;die reihe die über einem ist sollte feuern
    	If $shippos_x> $posx+($1-.6)*$scale*16+$scale*8 And $shippos_x< $posx+($1+.6)*$scale*16+$scale*8 Then;der gegner der am nähsten ist feuert
    _fire($1)
    EndIf
    Next
    	EndFunc
    Alles anzeigen
  • Space Invader

    • bollen
    • 7. Februar 2016 um 19:51

    Kindheit ist gut da war ich noch nichtmal in planung als das veröffentlicht wurde :D

  • Space Invader

    • bollen
    • 7. Februar 2016 um 18:36

    Schönen Abend liebe AutoIt gemeinde,
    nach längerem c++ exkurs bin ich wider zu meinem heißgeliebten AutoIt zurückgekommen und habe bei meinen alten Scripts noch ein kleines halbfertiges Spiel gefunden welches ich natürlich niemand vorenthalten will.
    ich würde mich natürlich über kommentare und anregungen dazu sehr freuen :)
    getestet und geschrieben wurde unter AutoIt V 3.3.12.0
    €: neue Version

    AutoIt
    #include <GUIConstantsEx.au3>
    #include <Gdiplus.au3>
    #include <Misc.au3>
    #include <Array.au3>
    #include <Timers.au3>
    Global $breite = 600 ;fenstergröße, mindestens:400
    Global $hoehe = $breite;fenstergröße
    Global $groese = 10; höhe/(breite) des feldes
    Global $difficulti = 2;0=Profi 1=Schwer 2=Normal 3=Leicht
    Global $movespace = Floor($groese / 2)
    Global $scale = $breite / 16 / ($groese + $movespace);größe der objekte
    Global $shipspeed = $scale * 4, $shippos_x = 0, $shippos_y = $hoehe - 24 * $scale - 30
    Global $firespeed = $scale * 6;6
    Global $firedelay = 333;3 Geschosse pro sek.
    Global $lifes=3
    Global $wave = 0, $score = 0, $speed = 400, $posx = 0, $posy = 0, $counter, $killcounter = 0, $dir = 1;startposition
    Global $enemy[5][11] = [[384, 2016, 16380, 32766, 32766, 29646, 16380, 1632, 3504, 6168, 12300],[4104, 2064, 8184, 15324, 32766, 24570, 20490, 20082, 0, 0, 0],[384, 960, 2016, 3504, 8184, 8184, 576, 1440, 2640, 0, 0],[960, 4080, 8184, 16380, 28086, 65535, 14748, 4104, 0, 0, 0],[448, 8188, 16382, 15518, 16382, 864, 1712, 6156, 0, 0, 0]];gegnerform 16x11 pixel
    Global $hide[11] = [65535, 65535, 65535, 65535, 63519, 61455, 57351, 57351, 57351, 57351, 0]
    Global $ship[11] = [384, 384, 960, 960, 8184, 16380, 16380, 16380, 0, 0, 0]
    Global $life[11]= [30750,64575,65151,65535,32766,16380,8184,4080,2016,960,384]
    Global $Field[$groese][Ceiling($groese/$difficulti)];gegnerflotte
    Global $EnemyPaths[5], $HidePath[Floor($groese / 4) + 1], $bullets[2][3] = [[1, 0, 0]];[x][Y]=X=laufende NR Y=0=Xpos Y=1=Ypos Y=2=Dir/Speed
    For $ie = 0 To $groese - 1
    	For $ie2 = 0 To Ceiling($groese/$difficulti) - 1
    			$killcounter += 1
    			$Field[$ie][$ie2] = Random(0, 4, 1)
    	Next
    Next
    _GDIPlus_Startup()
    $Form1 = GUICreate("Invader", $breite, $hoehe)
    GUISetState(@SW_SHOW)
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($Form1)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($breite, $hoehe, $hGraphics)
    $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    $brush_grau = _GDIPlus_BrushCreateSolid(0xFF888888)
    $brush_blau = _GDIPlus_BrushCreateSolid(0xFF0000FF)
    $brush_gruen = _GDIPlus_BrushCreateSolid(0xFF00FF00)
    $brush_rot = _GDIPlus_BrushCreateSolid(0xFFFF0000)
    $brush_white = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
    $pen_white = _GDIPlus_PenCreate(0xFFFFFFFF, $scale, 2)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
    $hFont_big = _GDIPlus_FontCreate($hFamily, $hoehe/8, 2)
    $tWaverect = _GDIPlus_RectFCreate(10, $hoehe - 20, 100, 20)
    $tScorerect = _GDIPlus_RectFCreate(110, $hoehe - 20, 150, 20)
    $tSpeedrect = _GDIPlus_RectFCreate(260, $hoehe - 20, 160, 20)
    $tWin_loose_rect = _GDIPlus_RectFCreate($breite / 4, $hoehe /4, $breite / 2, $hoehe/2)
    For $i0 = 0 To 4
    	$__Temp = _GDIPlus_PathCreate()
    	For $i1 = 0 To 10
    		For $i2 = 0 To 15
    			if BitAND(BitShift(1, $i2 * -1), $enemy[$i0][$i1]) Then _GDIPlus_PathAddRectangle($__Temp, $i2 * $scale, $i1 * $scale, $scale, $scale)
    		Next
    	Next
    	$EnemyPaths[$i0] = _GDIPlus_RegionCreateFromPath($__Temp);kostengünstig ein Gegner erstellt
    Next
    $__Temp = _GDIPlus_PathCreate()
    For $i1 = 0 To 10
    	For $i2 = 0 To 15
    		if (BitAND(BitShift(1, $i2 * -1), $ship[$i1])) then _GDIPlus_PathAddRectangle($__Temp, $i2 * $scale, $i1 * $scale + $shippos_y, $scale, $scale)
    	Next
    Next
    $shipPath = _GDIPlus_RegionCreateFromPath($__Temp)
    $__Temp = _GDIPlus_PathCreate()
    For $i1 = 0 To 10
    	For $i2 = 0 To 15
    		if (BitAND(BitShift(1, $i2 * -1), $hide[$i1])) then _GDIPlus_PathAddRectangle($__Temp, $i2 * $scale, $i1 * $scale + $hoehe - 40 * $scale - 30, $scale, $scale)
    	Next
    Next
    For $i1 = 0 To Floor($groese / 4)
    	$HidePath[$i1] = _GDIPlus_RegionCreateFromPath($__Temp)
    	_GDIPlus_RegionTranslate($HidePath[$i1], $i1 * ($breite / ($groese / 4)), 0)
    Next
    $__Temp = _GDIPlus_PathCreate()
    For $i1 = 0 To 10
    	For $i2 = 0 To 15
    		if (BitAND(BitShift(1, $i2 * -1), $life[$i1])) then _GDIPlus_PathAddRectangle($__Temp, $i2 * $scale, $i1 * $scale+(11*$scale) + $shippos_y, $scale, $scale)
    	Next
    Next
    $lifePath = _GDIPlus_RegionCreateFromPath($__Temp)
    $movetimer = _Timer_Init()
    $shoottimer = _Timer_Init()
    $firetimer = _Timer_SetTimer($Form1, 50,"movebullets")
    $firetimer_enemy = _Timer_SetTimer($Form1,1000,"enemyfire")
    $Drawtimer = _Timer_SetTimer($Form1,33,"_draw");30 Fps
    While 1
    	If $killcounter = 0 Then _win()
    	$nMsg = GUIGetMsg()
    	Switch $nMsg
    		Case $GUI_EVENT_CLOSE
    			Exit
    	EndSwitch
    	If _IsPressed("27") And $shippos_x < $breite - 16 * $scale Then
    		$shippos_x += $shipspeed
    		_GDIPlus_RegionTranslate($shipPath, +$shipspeed, 0)
    	EndIf
    	If _IsPressed("25") And $shippos_x > 0 Then
    		$shippos_x -= $shipspeed
    		_GDIPlus_RegionTranslate($shipPath, -$shipspeed, 0)
    	EndIf
    	If _IsPressed("20") And _Timer_Diff($shoottimer) > $firedelay Then _fire(-1)
    	If _Timer_Diff($movetimer) > $speed Then move()
    WEnd
    Func _draw($hWnd, $iMsg, $iIDTimer, $iTime)
    	For $i1 = 0 To $groese - 1
    		For $i2 = 0 To Ceiling($groese/$difficulti) - 1;feld enthällt immer den index des zu zeichnenden objekts
    			Switch $Field[$i1][$i2];object wird in position translatet und gezeichnet danch wider zurück
    				Case 0
    					_GDIPlus_RegionTranslate($EnemyPaths[0], ($i1 * 16 * $scale) + $posx, ($i2 * 16 * $scale) + $posy)
    					_GDIPlus_GraphicsFillRegion($hBuffer, $EnemyPaths[0], $brush_grau)
    					_GDIPlus_RegionTranslate($EnemyPaths[0], -($i1 * 16 * $scale) - $posx, -($i2 * 16 * $scale) - $posy)
    				Case 1
    					_GDIPlus_RegionTranslate($EnemyPaths[1], ($i1 * 16 * $scale) + $posx, ($i2 * 16 * $scale) + $posy)
    					_GDIPlus_GraphicsFillRegion($hBuffer, $EnemyPaths[1], $brush_blau)
    					_GDIPlus_RegionTranslate($EnemyPaths[1], -($i1 * 16 * $scale) - $posx, -($i2 * 16 * $scale) - $posy)
    				Case 2
    					_GDIPlus_RegionTranslate($EnemyPaths[2], ($i1 * 16 * $scale) + $posx, ($i2 * 16 * $scale) + $posy)
    					_GDIPlus_GraphicsFillRegion($hBuffer, $EnemyPaths[2], $brush_gruen)
    					_GDIPlus_RegionTranslate($EnemyPaths[2], -($i1 * 16 * $scale) - $posx, -($i2 * 16 * $scale) - $posy)
    				Case 3
    					_GDIPlus_RegionTranslate($EnemyPaths[3], ($i1 * 16 * $scale) + $posx, ($i2 * 16 * $scale) + $posy)
    					_GDIPlus_GraphicsFillRegion($hBuffer, $EnemyPaths[3], $brush_rot)
    					_GDIPlus_RegionTranslate($EnemyPaths[3], -($i1 * 16 * $scale) - $posx, -($i2 * 16 * $scale) - $posy)
    				Case 4
    					_GDIPlus_RegionTranslate($EnemyPaths[4], ($i1 * 16 * $scale) + $posx, ($i2 * 16 * $scale) + $posy)
    					_GDIPlus_GraphicsFillRegion($hBuffer, $EnemyPaths[4], $brush_white)
    					_GDIPlus_RegionTranslate($EnemyPaths[4], -($i1 * 16 * $scale) - $posx, -($i2 * 16 * $scale) - $posy)
    			EndSwitch
    		Next
    	Next
    	For $i1 = 0 To Floor($groese / 4);erstellen der Deckung
    		_GDIPlus_GraphicsFillRegion($hBuffer, $HidePath[$i1], $brush_gruen)
    	Next
    	For $i1 = 1 To $bullets[0][0];geschosse einzeichnen
    		_GDIPlus_GraphicsDrawLine($hBuffer, $bullets[$i1][0], $bullets[$i1][1], $bullets[$i1][0], $bullets[$i1][1] - $scale * 2, $pen_white)
    	Next
    	For $1=0 to $lifes-1;leben zeichnen
    	_GDIPlus_RegionTranslate($lifePath ,20*$scale*$1 ,0)
    	_GDIPlus_GraphicsFillRegion($hBuffer, $lifePath,$brush_rot)
    	_GDIPlus_RegionTranslate($lifePath ,-20*$scale*$1 ,0)
    	Next
    	_GDIPlus_GraphicsFillRegion($hBuffer, $shipPath, $brush_white);schiff zeichnen region wird translatet um die pos zu erreichen
    	_GDIPlus_GraphicsDrawStringEx($hBuffer, "Speed: " & Round(400 / $speed, 3), $hFont, $tSpeedrect, $hFormat, $brush_white)
    	_GDIPlus_GraphicsDrawStringEx($hBuffer, "Wave: " & $wave, $hFont, $tWaverect, $hFormat, $brush_white)
    	_GDIPlus_GraphicsDrawStringEx($hBuffer, "Score: " & $score, $hFont, $tScorerect, $hFormat, $brush_white)
    	_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0);Buffer zeichnen
    	_GDIPlus_GraphicsFillRect($hBuffer, 0, 0, $breite, $hoehe);buffer leeren
    EndFunc
    Func movebullets($hWnd, $iMsg, $iIDTimer, $iTime);bewegt/zerstört geschosse, hit detection, Score
    	For $i1 = 1 To $bullets[0][0]
    		$bullets[$i1][1] += $bullets[$i1][2]
    		If $bullets[$i1][1] < 0 Or $bullets[$i1][1] > $hoehe Then
    			_ArrayDelete($bullets, $i1)
    			$bullets[0][0] -= 1
    			movebullets(0,0,0,0);rekursiver aufruf da sonst  for to nicht mehr stimmt
    			Return;ruft sich solange selber auf bis alle kugeln weg sind die außerhalb des feldes liegen
    		EndIf
    	Next
    	For $i1 = 1 To $bullets[0][0];hit detection
    		If $bullets[$i1][1] > $shippos_y Then;;wenn das schiff getroffen wird
    			If $bullets[$i1][0] >$shippos_x and $bullets[$i1][0]<$shippos_x+$scale*16 Then
    			_loose()
    			_ArrayDelete($bullets, $i1);kugel löschen
    			$bullets[0][0] -= 1;anzahl der kugeln anpassen
    			movebullets(0,0,0,0)
    			Return
    			EndIf
    		EndIf
    		$__Temp01 = ($bullets[$i1][0] - $posx) / ($scale * 16);kugel pos X im feld
    		$__Temp02 = ($bullets[$i1][1] - $posy) / ($scale * 16);kugel pos Y im feld
    		If $__Temp01 < $groese And $__Temp01 > 0 Then;X pos im gegnerfeld
    			If $__Temp02 < Ceiling($groese/$difficulti) And $__Temp02 > 0 Then;Y pos im gegnerfeld
    				If $Field[Floor($__Temp01)][Floor($__Temp02)] <> -1 Then;und gegner vorhanden
    					Switch $Field[Floor($__Temp01)][Floor($__Temp02)];score je nach gegner erhöhen
    						Case 0
    							$score += 10
    						Case 1
    							$score += 20
    						Case 2
    							$score += 25
    						Case 3
    							$score += 35
    						Case 4
    							$score += 50
    					EndSwitch
    					$Field[Floor($__Temp01)][Floor($__Temp02)] = -1;gegner löschen
    					_ArrayDelete($bullets, $i1);kugel löschen
    					$killcounter -= 1
    					$bullets[0][0] -= 1;anzahl der kugeln anpassen
    					movebullets(0,0,0,0);rekursiver aufruf da sonst  for to nicht mehr stimmt wenn ein array element gelöscht wird (do until alternative)
    					Return;ruft sich solange selber auf bis alle kugeln weg sind die außerhalb des feldes liegen
    				EndIf
    			EndIf
    		EndIf
    	Next
    EndFunc   ;==>movebullets
    Func _fire($obj);-1=ship 0-$groese=gegner ,erstellt Geschosse
    	ReDim $bullets[$bullets[0][0] + 2][3]
    	$bullets[0][0] += 1
    	If $obj = -1 Then
    		$shoottimer = _Timer_Init()
    		$bullets[$bullets[0][0]][0] = $shippos_x + $scale * 8;schiffposition X
    		$bullets[$bullets[0][0]][1] = $shippos_y;schiffposition Y
    		$bullets[$bullets[0][0]][2] = -$firespeed; Geschwindigkeit der Geschosse in Pixel pro 50ms
    	Else
    		For $1=Ceiling($groese/$difficulti)-1 to 0 step -1;der vorderste gegner muss schießen
    			If $Field[$obj][$1]<>-1 Then
    				$shoottimer = _Timer_Init()
    				$bullets[$bullets[0][0]][1] = $posy+5 + ($1+1) * $scale * 16
    				$bullets[$bullets[0][0]][0] = $posx + ($obj-.5+Random(0,1))* $scale * 16 + $scale * 8;random.. sorgt für dezent abweichende schusspfade so das keine sichere stellen entstehen
    				$bullets[$bullets[0][0]][2] = +$firespeed
    				ExitLoop
    		EndIf
    			Next
    	EndIf
    EndFunc   ;==>_fire
    Func move();bewegt Schiffflotte
    	$counter += 1
    	If $counter = $movespace + 1 Then
    		If $dir = 1 Then
    			$dir = 0
    		Else
    			$dir = 1
    			$posy += $scale * 12
    			$speed -= $scale * 6
    		EndIf
    		$counter = 1
    	EndIf
    	If $dir = 1 Then
    		$posx += $scale * 16
    	Else
    		$posx -= $scale * 16
    	EndIf
    	$movetimer = _Timer_Init();timer zurücksetzen
    EndFunc   ;==>move
    Func _win()
    	_GDIPlus_GraphicsDrawStringEx($hBuffer, "WIN", $hFont_big, $tWin_loose_rect, $hFormat, $brush_gruen)
    	_draw(0,0,0,0)
    
    
    	For $ie = 0 To $groese - 1;;neues level erstellen
    	For $ie2 = 0 To Ceiling($groese/$difficulti) - 1
    			$killcounter += 1
    			$Field[$ie][$ie2] = Random(0, 4, 1)
    	Next
    Next
    $posx=0;;pos zurücksetzen
    $posy=0;;dito
    $lifes+=1;;leben um 1 erhöhen pro level
    $bullets[0][0]=0; schüsse löschen
    $speed=400-(($speed-400)/100);erhöt die geschwindigkeit um 1% der geschwindigkeitsdifferez zwischen start und ende der runde
    EndFunc   ;==>_win
    Func _loose()
    	$lifes-=1
    	If $lifes >0 Then
    
    
    	Else
    	_GDIPlus_GraphicsDrawStringEx($hBuffer, "RIP", $hFont_big, $tWin_loose_rect, $hFormat, $brush_gruen)
    	_Timer_KillAllTimers ( $Form1);killt die mit _Timer_SetTimer erstellten timer
    	_Timer_KillTimer ( $Form1, $movetimer );killt den rest
    	_Timer_KillTimer ( $Form1, $shoottimer )
    _draw(0,0,0,0)
    EndIf
    EndFunc   ;==>_win
    Func enemyfire($hWnd, $iMsg, $iIDTimer, $iTime)
    	For $1=0 to 9;die reihe die über einem ist sollte feuern
    	If $shippos_x> $posx+($1-.6)*$scale*16+$scale*8 And $shippos_x< $posx+($1+.6)*$scale*16+$scale*8 Then;der gegner der am nähsten ist feuert
    _fire($1)
    EndIf
    Next
    	EndFunc
    Alles anzeigen
    Spoiler anzeigen


    Ältere Versionen hier

    AutoIt
    #include <GUIConstantsEx.au3>
    #include <Gdiplus.au3>
    #include <Misc.au3>
    #include <Array.au3>
    Global $breite = 400 ;fenstergröße, mindestens:400
    Global $hoehe = $breite;fenstergröße
    Global $groese = 10; höhe/(breite) des feldes
    Global $difficulti = 2;0=Profi 1=Schwer 2=Normal 3=Leicht
    Global $movespace = Floor($groese / 2)
    Global $scale = $breite / 16 / ($groese + $movespace);größe der objekte
    Global $shipspeed = $scale * 8, $shippos_x = 0, $shippos_y = $hoehe - 24 * $scale - 30
    Global $firespeed = $scale * 6;6
    Global $firedelay = 333;3 Geschosse pro sek.
    Global $wave = 0, $score = 0, $speed = 400, $posx = 0, $posy = 0, $counter, $killcounter = 0, $dir = 1;startposition
    Global $enemy[5][11] = [[384, 2016, 16380, 32766, 32766, 29646, 16380, 1632, 3504, 6168, 12300],[4104, 2064, 8184, 15324, 32766, 24570, 20490, 20082, 0, 0, 0],[384, 960, 2016, 3504, 8184, 8184, 576, 1440, 2640, 0, 0],[960, 4080, 8184, 16380, 28086, 65535, 14748, 4104, 0, 0, 0],[448, 8188, 16382, 15518, 16382, 864, 1712, 6156, 0, 0, 0]];gegnerform 16x11 pixel
    Global $hide[11] = [65535, 65535, 65535, 65535, 63519, 61455, 57351, 57351, 57351, 57351, 0]
    Global $ship[11] = [384, 384, 960, 960, 8184, 16380, 16380, 16380, 0, 0, 0]
    Global $Field[$groese][Ceiling($groese/$difficulti)];gegnerflotte
    Global $EnemyPaths[5], $HidePath[Floor($groese / 4) + 1], $bullets[2][3] = [[1, 0, 0]];[x][Y]=X=laufende NR Y=0=Xpos Y=1=Ypos Y=2=Dir/Speed
    For $ie = 0 To $groese - 1
    	For $ie2 = 0 To Ceiling($groese/$difficulti) - 1
    			$killcounter += 1
    			$Field[$ie][$ie2] = Random(0, 4, 1)
    	Next
    Next
    _GDIPlus_Startup()
    $Form1 = GUICreate("Invader", $breite, $hoehe)
    GUISetState(@SW_SHOW)
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($Form1)
    _GDIPlus_GraphicsClear($hGraphics, 0xFF000000)
    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($breite, $hoehe, $hGraphics)
    $hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    $brush_grau = _GDIPlus_BrushCreateSolid(0xFF888888)
    $brush_blau = _GDIPlus_BrushCreateSolid(0xFF0000FF)
    $brush_gruen = _GDIPlus_BrushCreateSolid(0xFF00FF00)
    $brush_rot = _GDIPlus_BrushCreateSolid(0xFFFF0000)
    $brush_white = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
    $pen_white = _GDIPlus_PenCreate(0xFFFFFFFF, $scale, 2)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
    $hFont_big = _GDIPlus_FontCreate($hFamily, $hoehe/8, 2)
    $tWaverect = _GDIPlus_RectFCreate(10, $hoehe - 20, 100, 20)
    $tScorerect = _GDIPlus_RectFCreate(110, $hoehe - 20, 150, 20)
    $tSpeedrect = _GDIPlus_RectFCreate(260, $hoehe - 20, 160, 20)
    $tWin_loose_rect = _GDIPlus_RectFCreate($breite / 4, $hoehe /4, $breite / 2, $hoehe/2)
    For $i0 = 0 To 4
    	$__Temp = _GDIPlus_PathCreate()
    	For $i1 = 0 To 10
    		For $i2 = 0 To 15
    			if BitAND(BitShift(1, $i2 * -1), $enemy[$i0][$i1]) Then _GDIPlus_PathAddRectangle($__Temp, $i2 * $scale, $i1 * $scale, $scale, $scale)
    		Next
    	Next
    	$EnemyPaths[$i0] = _GDIPlus_RegionCreateFromPath($__Temp);kostengünstig ein Gegner erstellt
    Next
    $__Temp = _GDIPlus_PathCreate()
    For $i1 = 0 To 10
    	For $i2 = 0 To 15
    		if (BitAND(BitShift(1, $i2 * -1), $ship[$i1])) then _GDIPlus_PathAddRectangle($__Temp, $i2 * $scale, $i1 * $scale + $shippos_y, $scale, $scale)
    	Next
    Next
    $shipPath = _GDIPlus_RegionCreateFromPath($__Temp)
    $__Temp = _GDIPlus_PathCreate()
    For $i1 = 0 To 10
    	For $i2 = 0 To 15
    		if (BitAND(BitShift(1, $i2 * -1), $hide[$i1])) then _GDIPlus_PathAddRectangle($__Temp, $i2 * $scale, $i1 * $scale + $hoehe - 40 * $scale - 30, $scale, $scale)
    	Next
    Next
    For $i1 = 0 To Floor($groese / 4)
    	$HidePath[$i1] = _GDIPlus_RegionCreateFromPath($__Temp)
    	_GDIPlus_RegionTranslate($HidePath[$i1], $i1 * ($breite / ($groese / 4)), 0)
    Next
    $movetimer = TimerInit()
    $firetimer = TimerInit()
    $shoottimer = TimerInit()
    While 1
    	If $killcounter = 0 Then _win()
    	$nMsg = GUIGetMsg()
    	Switch $nMsg
    		Case $GUI_EVENT_CLOSE
    			Exit
    	EndSwitch
    	If _IsPressed("27") And $shippos_x < $breite - 16 * $scale Then
    		$shippos_x += $shipspeed
    		_GDIPlus_RegionTranslate($shipPath, +$shipspeed, 0)
    	EndIf
    	If _IsPressed("25") And $shippos_x > 0 Then
    		$shippos_x -= $shipspeed
    		_GDIPlus_RegionTranslate($shipPath, -$shipspeed, 0)
    	EndIf
    	If _IsPressed("20") And TimerDiff($shoottimer) > $firedelay Then _fire(-1)
    	If TimerDiff($movetimer) > $speed Then move()
    	If TimerDiff($firetimer) > 50 Then movebullets()
    	For $i1 = 0 To $groese - 1
    		For $i2 = 0 To Ceiling($groese/$difficulti) - 1;feld enthällt immer den index des zu zeichnenden objekts
    			Switch $Field[$i1][$i2];object wird in position translatet und gezeichnet danch wider zurück
    				Case 0
    					_GDIPlus_RegionTranslate($EnemyPaths[0], ($i1 * 16 * $scale) + $posx, ($i2 * 16 * $scale) + $posy)
    					_GDIPlus_GraphicsFillRegion($hBuffer, $EnemyPaths[0], $brush_grau)
    					_GDIPlus_RegionTranslate($EnemyPaths[0], -($i1 * 16 * $scale) - $posx, -($i2 * 16 * $scale) - $posy)
    				Case 1
    					_GDIPlus_RegionTranslate($EnemyPaths[1], ($i1 * 16 * $scale) + $posx, ($i2 * 16 * $scale) + $posy)
    					_GDIPlus_GraphicsFillRegion($hBuffer, $EnemyPaths[1], $brush_blau)
    					_GDIPlus_RegionTranslate($EnemyPaths[1], -($i1 * 16 * $scale) - $posx, -($i2 * 16 * $scale) - $posy)
    				Case 2
    					_GDIPlus_RegionTranslate($EnemyPaths[2], ($i1 * 16 * $scale) + $posx, ($i2 * 16 * $scale) + $posy)
    					_GDIPlus_GraphicsFillRegion($hBuffer, $EnemyPaths[2], $brush_gruen)
    					_GDIPlus_RegionTranslate($EnemyPaths[2], -($i1 * 16 * $scale) - $posx, -($i2 * 16 * $scale) - $posy)
    				Case 3
    					_GDIPlus_RegionTranslate($EnemyPaths[3], ($i1 * 16 * $scale) + $posx, ($i2 * 16 * $scale) + $posy)
    					_GDIPlus_GraphicsFillRegion($hBuffer, $EnemyPaths[3], $brush_rot)
    					_GDIPlus_RegionTranslate($EnemyPaths[3], -($i1 * 16 * $scale) - $posx, -($i2 * 16 * $scale) - $posy)
    				Case 4
    					_GDIPlus_RegionTranslate($EnemyPaths[4], ($i1 * 16 * $scale) + $posx, ($i2 * 16 * $scale) + $posy)
    					_GDIPlus_GraphicsFillRegion($hBuffer, $EnemyPaths[4], $brush_white)
    					_GDIPlus_RegionTranslate($EnemyPaths[4], -($i1 * 16 * $scale) - $posx, -($i2 * 16 * $scale) - $posy)
    			EndSwitch
    		Next
    	Next
    	For $i1 = 0 To Floor($groese / 4);erstellen der Deckung
    		_GDIPlus_GraphicsFillRegion($hBuffer, $HidePath[$i1], $brush_gruen)
    	Next
    	For $i1 = 1 To $bullets[0][0];geschosse einzeichnen
    		_GDIPlus_GraphicsDrawLine($hBuffer, $bullets[$i1][0], $bullets[$i1][1], $bullets[$i1][0], $bullets[$i1][1] - $scale * 2, $pen_white)
    	Next
    	_GDIPlus_GraphicsFillRegion($hBuffer, $shipPath, $brush_white);schiff zeichnen region wird translatet um die pos zu erreichen
    	_GDIPlus_GraphicsDrawStringEx($hBuffer, "Speed: " & Round(400 / $speed, 3), $hFont, $tSpeedrect, $hFormat, $brush_white)
    	_GDIPlus_GraphicsDrawStringEx($hBuffer, "Wave: " & $wave, $hFont, $tWaverect, $hFormat, $brush_white)
    	_GDIPlus_GraphicsDrawStringEx($hBuffer, "Score: " & $score, $hFont, $tScorerect, $hFormat, $brush_white)
    	_GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap, 0, 0);Buffer zeichnen
    	_GDIPlus_GraphicsFillRect($hBuffer, 0, 0, $breite, $hoehe);buffer leeren
    WEnd
    Func movebullets();bewegt/zerstört geschosse, hit detection, Score
    	For $i1 = 1 To $bullets[0][0]
    		$bullets[$i1][1] += $bullets[$i1][2]
    		If $bullets[$i1][1] < 0 Or $bullets[$i1][1] > $hoehe Then
    			_ArrayDelete($bullets, $i1)
    			$bullets[0][0] -= 1
    			movebullets();rekursiver aufruf da sonst  for to nicht mehr stimmt
    			Return;ruft sich solange selber auf bis alle kugeln weg sind die außerhalb des feldes liegen
    		EndIf
    	Next
    	For $i1 = 1 To $bullets[0][0];hit detection
    		$__Temp01 = ($bullets[$i1][0] - $posx) / ($scale * 16);kugel pos X im feld
    		$__Temp02 = ($bullets[$i1][1] - $posy) / ($scale * 16);kugel pos Y im feld
    		If $__Temp01 < $groese And $__Temp01 > 0 Then;X pos im gegnerfeld
    			If $__Temp02 < Ceiling($groese/$difficulti) And $__Temp02 > 0 Then;Y pos im gegnerfeld
    				If $Field[Floor($__Temp01)][Floor($__Temp02)] <> -1 Then;und gegner vorhanden
    					Switch $Field[Floor($__Temp01)][Floor($__Temp02)];score je nach gegner erhöhen
    						Case 0
    							$score += 10
    						Case 1
    							$score += 20
    						Case 2
    							$score += 25
    						Case 3
    							$score += 35
    						Case 4
    							$score += 50
    					EndSwitch
    					$Field[Floor($__Temp01)][Floor($__Temp02)] = -1;gegner löschen
    					_ArrayDelete($bullets, $i1);kugel löschen
    					$killcounter -= 1
    					$bullets[0][0] -= 1;anzahl der kugeln anpassen
    					movebullets();rekursiver aufruf da sonst  for to nicht mehr stimmt wenn ein array element gelöscht wird (do until alternative)
    					Return;ruft sich solange selber auf bis alle kugeln weg sind die außerhalb des feldes liegen
    				EndIf
    			EndIf
    		EndIf
    	Next
    	$firetimer = TimerInit();timer nullen
    EndFunc   ;==>movebullets
    Func _fire($obj);-1=ship 0-$groese=gegner ,erstellt Geschosse
    	ReDim $bullets[$bullets[0][0] + 2][3]
    	$bullets[0][0] += 1
    	If $obj = -1 Then
    		$shoottimer = TimerInit()
    		$bullets[$bullets[0][0]][0] = $shippos_x + $scale * 8;schiffposition X
    		$bullets[$bullets[0][0]][1] = $shippos_y;schiffposition Y
    		$bullets[$bullets[0][0]][2] = -$firespeed; Geschwindigkeit der Geschosse in Pixel pro 50ms
    	Else
    		$bullets[$bullets[0][0]][0] = $posx + Mod($obj, $groese) * $scale * 16 + $scale * 8
    		$bullets[$bullets[0][0]][1] = $posy + Floor($obj / $groese) * $scale * 16
    		$bullets[$bullets[0][0]][2] = +$firespeed
    	EndIf
    EndFunc   ;==>_fire
    Func move();bewegt Schiff
    	$counter += 1
    	If $counter = $movespace + 1 Then
    		If $dir = 1 Then
    			$dir = 0
    		Else
    			$dir = 1
    			$posy += $scale * 12
    			$speed -= $scale * 6
    		EndIf
    		$counter = 1
    	EndIf
    	If $dir = 1 Then
    		$posx += $scale * 16
    	Else
    		$posx -= $scale * 16
    	EndIf
    	$movetimer = TimerInit()
    EndFunc   ;==>move
    Func _win()
    	_GDIPlus_GraphicsDrawStringEx($hBuffer, "WIN", $hFont_big, $tWin_loose_rect, $hFormat, $brush_gruen)
    EndFunc   ;==>_win
    Alles anzeigen


  • Tic Tac Toe mit KI

    • bollen
    • 24. Mai 2015 um 19:02

    noch ein altes stück code eine schlichte variante von Tic Tac Toe mit anschaltbarer KI. Zur Entspannung für den frustrierten Programmierer.

    €: musste schlichte streichen nach Andys post

    [autoit]

    #include <WindowsConstants.au3>
    #include <guiConstants.au3>
    Global $i_counter = 0
    Global $a_s_TicTacToe_logic[9] = ["124836", "0247", "016458", "0645", "18172635", "2834", "037842", "1468", "250467"]
    Global $a_s_TicTacToe_sieg[8] = ["012", "345", "678", "036", "147", "258", "048", "246"]
    Global $b_KI = 0
    $h_GUI_TicTacToe = GUICreate("TicTacToe", 356, 500)
    GUISetBkColor(0x000000)
    $id_BUTTON_Neustart = GUICtrlCreateButton("Neustart", 20, 400, 75, 25)
    $id_BUTTON_ComputerZeichen = GUICtrlCreateButton("KI Zeichen", 20, 440, 150, 20)
    $id_BUTTON_KiStart = GUICtrlCreateButton("KI Start", 200, 440, 100, 20)
    $id_BUTTON_KiStop = GUICtrlCreateButton("KI Stop", 200, 460, 100, 20, $WS_DISABLED)
    GUISetFont(30, 500, "", "Comic Sans", $h_GUI_TicTacToe, 5)
    Global $a_id_BUTTON_Field[9], $a_s_Field[9]
    $i_counter = 0
    For $i1 = 1 To 3
    For $i2 = 1 To 3
    $a_id_BUTTON_Field[$i_counter] = GUICtrlCreateButton("", 120 * ($i2 - 1), 128 * ($i1 - 1), 115, 121);erzeuge spielfeld 0=oben links
    $i_counter += 1
    Next
    Next
    $i_counter = 0;counter widerverwendet für spielzüge
    GUICtrlSetDefBkColor(0x000000, $h_GUI_TicTacToe)
    GUICtrlSetDefColor(0xFFFFFF, $h_GUI_TicTacToe)
    Global $h_LABEL_NextesZeichen = GUICtrlCreateLabel("X", 260, 390, 50, 50);
    $h_LABEL_KiZeichen = GUICtrlCreateLabel("O", 75, 460, 50, 50)
    GUISetState(@SW_SHOW, $h_GUI_TicTacToe)
    While 1
    $hMsg = GUIGetMsg()
    Switch $hMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $id_BUTTON_KiStart
    $b_KI = 1
    GUICtrlSetState($id_BUTTON_KiStop, $GUI_ENABLE)
    GUICtrlSetState($id_BUTTON_KiStart, $GUI_DISABLE)
    Case $id_BUTTON_KiStop
    $b_KI = 0
    GUICtrlSetState($id_BUTTON_KiStart, $GUI_ENABLE)
    GUICtrlSetState($id_BUTTON_KiStop, $GUI_DISABLE)
    Case $id_BUTTON_Neustart
    For $i1 = 0 To 8;Buttons zurücksetzen
    GUICtrlSetData($a_id_BUTTON_Field[$i1], "")
    GUICtrlSetState($a_id_BUTTON_Field[$i1], $GUI_ENABLE)
    $a_s_Field[$i1] = ""
    Next
    $i_counter = Random(0, 1, 1);zufälliger Start
    GUICtrlSetData($h_LABEL_NextesZeichen, Mod($i_counter, 2) ? "O" : "X");Anzeige nextes Zeichen
    Case $a_id_BUTTON_Field[0] To $a_id_BUTTON_Field[8]; nacheinander erstellte buttons haben aufsteigende IDs
    GUICtrlSetState($hMsg, $GUI_DISABLE);gedrückter Button ausgrauen
    GUICtrlSetData($hMsg, Mod($i_counter, 2) ? "O" : "X")
    $i_counter += 1;zähler erhöhen
    GUICtrlSetData($h_LABEL_NextesZeichen, Mod($i_counter, 2) ? "O" : "X");Anzeige nextes Zeichen
    _test_win()
    Case $id_BUTTON_ComputerZeichen
    GUICtrlSetData($h_LABEL_KiZeichen, GUICtrlRead($h_LABEL_KiZeichen) = "O" ? "X" : "O");KI Zeichen setzen
    EndSwitch
    If GUICtrlRead($h_LABEL_KiZeichen) = (Mod($i_counter, 2) ? "O" : "X") And $b_KI = 1 Then;KI zug
    $s__Temp01 = (Mod($i_counter, 2) ? "O" : "X")
    For $i1 = 0 To 8
    If $a_s_Field[$i1] = "" Then
    For $i2 = 1 To StringLen($a_s_TicTacToe_logic[$i1]) - 1 Step 2
    If $a_s_Field[StringMid($a_s_TicTacToe_logic[$i1], $i2, 1)] == $s__Temp01 And $a_s_Field[StringMid($a_s_TicTacToe_logic[$i1], $i2 + 1, 1)] == $s__Temp01 Then;wenn 2 felder so belegt sind das das spiel von der KI gewonnen werden kann
    _KI_Button($i1)
    ExitLoop 2
    EndIf
    Next
    EndIf
    Next
    If GUICtrlRead($h_LABEL_KiZeichen) = (Mod($i_counter, 2) ? "O" : "X") Then;noch nichts gemacht
    $s__Temp01 = (Mod($i_counter + 1, 2) ? "O" : "X");spieler Zeichen
    For $i1 = 0 To 8
    If $a_s_Field[$i1] = "" Then
    For $i2 = 1 To StringLen($a_s_TicTacToe_logic[$i1]) - 1 Step 2
    If $a_s_Field[StringMid($a_s_TicTacToe_logic[$i1], $i2, 1)] == $s__Temp01 And $a_s_Field[StringMid($a_s_TicTacToe_logic[$i1], $i2 + 1, 1)] == $s__Temp01 Then;wenn 2 felder so belegt sind das das spiel vom spieler gewonnen werden kann (vereiteln)
    _KI_Button($i1)
    ExitLoop 2
    EndIf
    Next
    EndIf
    Next
    EndIf
    If GUICtrlRead($h_LABEL_KiZeichen) = (Mod($i_counter, 2) ? "O" : "X") Then;noch nichts gemacht
    Select
    Case $a_s_Field[1] = "" And $a_s_Field[7] = "" And $a_s_Field[4] = (Mod($i_counter, 2) ? "O" : "X");vorzugsweise in das feld setzen in dem der Spieler noch gewinnen kann
    _KI_Button(1)
    Case $a_s_Field[3] = "" And $a_s_Field[5] = "" And $a_s_Field[4] = (Mod($i_counter, 2) ? "O" : "X");vorzugsweise in das feld setzen in dem der Spieler noch gewinnen kann
    _KI_Button(3)
    Case $a_s_Field[4] = "";mitte frei
    _KI_Button(4)
    Case $a_s_Field[0] = "";oben links frei
    _KI_Button(0)
    Case $a_s_Field[2] = "";oben rechts frei
    _KI_Button(2)
    Case $a_s_Field[6] = "";unten links frei
    _KI_Button(6)
    Case $a_s_Field[8] = "";unten rechts frei
    _KI_Button(8)
    Case $a_s_Field[3] = ""
    _KI_Button(3)
    Case $a_s_Field[1] = ""
    _KI_Button(1)
    Case $a_s_Field[5] = ""
    _KI_Button(5)
    Case $a_s_Field[7] = ""
    _KI_Button(7)
    EndSelect
    EndIf
    EndIf
    WEnd
    Func _KI_Button($i_Index)
    GUICtrlSetState($a_id_BUTTON_Field[$i_Index], $GUI_DISABLE);gedrückter Button ausgrauen
    GUICtrlSetData($a_id_BUTTON_Field[$i_Index], Mod($i_counter, 2) ? "O" : "X");Zeichen Anzeigen
    $i_counter += 1;zähler erhöhen
    GUICtrlSetData($h_LABEL_NextesZeichen, Mod($i_counter, 2) ? "O" : "X");Anzeige nextes Zeichen
    _test_win();schauen ob wer gewonnen hat
    EndFunc ;==>_KI_Button
    Func _test_win()
    For $i1 = 0 To 8
    $a_s_Field[$i1] = GUICtrlRead($a_id_BUTTON_Field[$i1]);button infos holen
    Next
    $s__Temp01 = (Mod($i_counter, 2) ? "O" : "X")
    $s__Temp02 = (Mod($i_counter + 1, 2) ? "O" : "X")
    For $i1 = 0 To 7;test auf sieg
    If $a_s_Field[StringMid($a_s_TicTacToe_sieg[$i1], 1, 1)] == $s__Temp01 And $a_s_Field[StringMid($a_s_TicTacToe_sieg[$i1], 2, 1)] == $s__Temp01 And $a_s_Field[StringMid($a_s_TicTacToe_sieg[$i1], 3, 1)] == $s__Temp01 Then _TicTacToe_Win($s__Temp01)
    If $a_s_Field[StringMid($a_s_TicTacToe_sieg[$i1], 1, 1)] == $s__Temp02 And $a_s_Field[StringMid($a_s_TicTacToe_sieg[$i1], 2, 1)] == $s__Temp02 And $a_s_Field[StringMid($a_s_TicTacToe_sieg[$i1], 3, 1)] == $s__Temp02 Then _TicTacToe_Win($s__Temp02)
    Next
    EndFunc ;==>_test_win
    Func _TicTacToe_Win($s_win)
    MsgBox(0, "", $s_win & " gewinnt")
    For $i1 = 0 To 8;Buttons zurücksetzen
    GUICtrlSetData($a_id_BUTTON_Field[$i1], "")
    GUICtrlSetState($a_id_BUTTON_Field[$i1], $GUI_ENABLE)
    Next
    $i_counter = Random(0, 1, 1);zufälliger anfang
    GUICtrlSetData($h_LABEL_NextesZeichen, Mod($i_counter, 2) ? "O" : "X");Anzeige nextes Zeichen
    EndFunc ;==>_TicTacToe_Win

    [/autoit]
  • Script zum erstellen beliebig großer Labyrinthe

    • bollen
    • 24. Mai 2015 um 16:13

    Unter Autoit V3.3.10.4 hat alles super funktioniert :D
    ganz sauber war es nicht aber schnell :whistling:

  • Script zum erstellen beliebig großer Labyrinthe

    • bollen
    • 24. Mai 2015 um 16:02

    jetzt sollte nicht nur ein weißes Bild am ende bleiben ich musste jedoch alle Ternäre Operatoren durch if then ersetzen was der performace etwas geschadet hat

  • Programm aus Programm starten funktioniert nicht ganz

    • bollen
    • 24. Mai 2015 um 15:06

    Höchstwarscheinlich musst du das "working dir" anpassen der zweite parameter von Run("program" ,"workingdir") sonst wird das Programm im gleichen Pfad wie dein Hauptprogramm ausgeführt also in etwa so

    [autoit]

    Run($SCRIPTPATH & "Data\Tools\Handelstool Fensterversion\Handelstool.exe",$SCRIPTPATH & "Data\Tools\Handelstool Fensterversion\")

    [/autoit]
  • Script zum erstellen beliebig großer Labyrinthe

    • bollen
    • 24. Mai 2015 um 14:56

    Hallo!
    ich habe gerade ein altes Programm von mir gefunden welches Labyrinthe in beliebiger Größe erstellt viel Spaß damit.

    ich würde mich über Verbesserungsvorschläge und Feedback freuen

    €: auf Autoit V3.3.12.0 angepasst

    Spoiler anzeigen
    AutoIt
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <Gdiplus.au3>
    #include <Misc.au3>
    #include <EditConstants.au3>
    Global $cpx, $cpy, $kasten = 0, $dir, $timer, $splitter, $hGraphics, $red, $weg, $bitmap
    $Stack = ObjCreate("System.Collections.Stack")
    HotKeySet("{ESC}", "_exit")
    _GDIPlus_Startup()
    $Form1 = GUICreate("Maze", 289, 342, 192, 124)
    $Input_X_Blocks = GUICtrlCreateInput(250, 40, 20, 121, 21, $ES_NUMBER)
    $Input_Y_Blocks = GUICtrlCreateInput(250, 40, 60, 121, 21, $ES_NUMBER)
    $Input_startx = GUICtrlCreateInput(1, 40, 140, 121, 21, $ES_NUMBER)
    $Input_starty = GUICtrlCreateInput(1, 40, 180, 121, 21, $ES_NUMBER)
    $Input_endex = GUICtrlCreateInput(250, 40, 220, 121, 21, $ES_NUMBER)
    $Input_endey = GUICtrlCreateInput(250, 40, 260, 121, 21, $ES_NUMBER)
    GUICtrlCreateLabel("X Blocks", 176, 20, 236, 17)
    GUICtrlCreateLabel("Y Blocks", 176, 60, 236, 17)
    $id_LABEL_AnzahlBlocks = GUICtrlCreateLabel("Anzahl an Feldern " & GUICtrlRead($Input_X_Blocks) * GUICtrlRead($Input_Y_Blocks), 40, 100, 236, 17)
    GUICtrlCreateLabel("START X", 176, 140, 236, 17)
    GUICtrlCreateLabel("START Y", 176, 180, 236, 17)
    GUICtrlCreateLabel("ENDE X", 176, 220, 236, 17)
    GUICtrlCreateLabel("ENDE Y", 176, 260, 236, 17)
    $Button_Create = GUICtrlCreateButton("Create", 40, 296, 75, 25)
    $Progress1 = GUICtrlCreateProgress(4, 320, 280, 20)
    GUISetState(@SW_SHOW)
    While 1
    	$nMsg = GUIGetMsg()
    	Switch $nMsg
    		Case $GUI_EVENT_CLOSE
    			_exit()
    		Case $Input_X_Blocks
    			GUICtrlSetData($Input_endex, GUICtrlRead($Input_X_Blocks))
    			GUICtrlSetData($id_LABEL_AnzahlBlocks, "Anzahl an Feldern " & GUICtrlRead($Input_X_Blocks) * GUICtrlRead($Input_Y_Blocks))
    		Case $Input_Y_Blocks
    			GUICtrlSetData($Input_endey, GUICtrlRead($Input_Y_Blocks))
    			GUICtrlSetData($id_LABEL_AnzahlBlocks, "Anzahl an Feldern " & GUICtrlRead($Input_X_Blocks) * GUICtrlRead($Input_Y_Blocks))
    		Case $Button_Create
    			$xBlocks = GUICtrlRead($Input_X_Blocks) + 2
    			$yBlocks = GUICtrlRead($Input_Y_Blocks) + 2
    			$startx = GUICtrlRead($Input_startx)
    			$starty = GUICtrlRead($Input_starty)
    			$endex = GUICtrlRead($Input_endex)
    			$endey = GUICtrlRead($Input_endey)
    			If $xBlocks < 4 Then
    				MsgBox(0, "", "Wert in X Blocks zu klein, mindestens 2")
    			Else
    				If $yBlocks < 4 Then
    					MsgBox(0, "", "Wert in Y Blocks zu klein, mindestens 2")
    				Else
    					If $startx < 1 Or $startx > $endex Then
    						MsgBox(0, "", "Startwert x liegt Auserhalb")
    					Else
    						If $starty < 1 Or $starty > $endey Then
    							MsgBox(0, "", "Startwert y liegt Auserhalb ")
    						Else
    							$cpx = $startx;$cpx=current position x
    							$cpy = $starty;$cpx=current position y
    							$anzahlblocks = (($xBlocks - 2) * ($yBlocks - 2) - 1)
    							Dim $maze[$xBlocks][$yBlocks];2D Feld Array
    							$wi = (@DesktopHeight - 20) / (($xBlocks < $yBlocks) ? $yBlocks : $xBlocks) * 0.95;Breite der kästchen, abhängig von anzahl
    							$timer = TimerInit()
    							_setwalls()
    							ConsoleWrite(TimerDiff($timer))
    							$timer = TimerInit()
    							_createMaze()
    							$timer1Diff = Round(TimerDiff($timer) / 1000, 4)
    							_drawmaze()
    						EndIf
    					EndIf
    				EndIf
    			EndIf
    	EndSwitch
    WEnd
    Func _setwalls();Randbegrenzungen als solche festlegen
    	For $i1 = 0 To $xBlocks - 1
    		$maze[$i1][0] = 16
    		$maze[$i1][$yBlocks - 1] = 16
    	Next
    	For $i1 = 0 To $yBlocks - 1
    		$maze[0][$i1] = 16
    		$maze[$xBlocks - 1][$i1] = 16
    	Next
    EndFunc   ;==>_setwalls
    Func _createMaze()
    	Do
    		$dir = Random(1, 4, 1);bewegungsrichtung
    		If ($dir = 4 And Mod($dir, $cpx) < $cpx / 2) Then GUICtrlSetData($Progress1, 100 / ($xBlocks * $yBlocks - $xBlocks - $yBlocks) * $kasten, "")
    		If $cpx = $endex And $cpy = $endey Then $splitter = $Stack.ToArray;ziel erreicht
    		If $cpx <= 0 Or $cpy <= 0 Or $cpx >= $xBlocks Or $cpy >= $yBlocks Then
    			_backstep()
    		Else
    			If $maze[$cpx][$cpy - 0x1] * $maze[$cpx][$cpy + 0x1] * $maze[$cpx + 0x1][$cpy] * $maze[$cpx - 0x1][$cpy] Then
    				_backstep()
    			Else
    				_math()
    			EndIf
    		EndIf
    	Until $anzahlblocks = $kasten ;bis alle blöcke betreten wurden
    EndFunc   ;==>_createMaze
    Func _math();1=0ben /2=rechts /4=unten /8=links
    	Switch $dir
    		Case 1
    			If $cpy > 0 And $maze[$cpx][$cpy - 0x1] = 0 Then;N
    				$maze[$cpx][$cpy] += 0x1
    				$cpy -= 0x1
    				$maze[$cpx][$cpy] = 0x4
    				$Stack.push(1)
    				$kasten += 0x1
    			EndIf
    		Case 2
    			If $cpx < $xBlocks And $maze[$cpx + 0x1][$cpy] = 0 Then;O
    				$maze[$cpx][$cpy] += 0x2
    				$cpx += 0x1
    				$maze[$cpx][$cpy] = 0x8
    				$Stack.push(2)
    				$kasten += 0x1
    			EndIf
    		Case 3
    			If $cpy < $yBlocks And $maze[$cpx][$cpy + 0x1] = 0 Then;S
    				$maze[$cpx][$cpy] += 0x4
    				$cpy += 0x1
    				$maze[$cpx][$cpy] = 0x1
    				$Stack.push(3)
    				$kasten += 0x1
    			EndIf
    		Case 4
    			If $cpx > 0 And $maze[$cpx - 0x1][$cpy] = 0 Then;W
    				$maze[$cpx][$cpy] += 0x8
    				$cpx -= 0x1
    				$maze[$cpx][$cpy] = 0x2
    				$Stack.push(4)
    				$kasten += 0x1
    			EndIf
    	EndSwitch
    EndFunc   ;==>_math
    Func _backstep()
    	Switch $Stack.pop
    		Case 1
    			$cpy += 0x1
    		Case 2
    			$cpx -= 0x1
    		Case 3
    			$cpy -= 0x1
    		Case 4
    			$cpx += 0x1
    	EndSwitch
    EndFunc   ;==>_backstep
    Func _drawmaze()
    	$Form2 = GUICreate("", @DesktopHeight - 40, @DesktopHeight - 40)
    	GUISwitch($Form2)
    	GUISetState(@SW_SHOW, $Form2)
    	$hGraphics = _GDIPlus_GraphicsCreateFromHWND($Form2)
    	_GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2)
    	$bitmap = _GDIPlus_BitmapCreateFromGraphics(@DesktopHeight - 40, @DesktopHeight - 40, $hGraphics)
    	$buffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
    	Global $black = _GDIPlus_PenCreate(0xFF000000)
    	$red = _GDIPlus_PenCreate(0xFFFF0000, $wi * 0.8);Stift für läufer
    	$weg = _GDIPlus_PenCreate(0xFF00FF00, $wi);Stift für lösungsweg
    	$Temp_01 = 10 + ($wi / 2)
    	For $i1 = 0 To $xBlocks - 1
    		$wi2 = $i1 * $wi + 10
    		For $i2 = 0 To $yBlocks - 1
    			If (BitAND($maze[$i1][$i2], 0x1) = 0) Then GDIPlus_GraphicsDrawLine($buffer, $wi2, $i2 * $wi + 10, $wi2 + $wi, $i2 * $wi + 10)
    			If (BitAND($maze[$i1][$i2], 0x2) = 0) Then GDIPlus_GraphicsDrawLine($buffer, $wi2 + $wi, $i2 * $wi + 10 + $wi, $wi2 + $wi, $i2 * $wi + 10)
    			If (BitAND($maze[$i1][$i2], 0x4) = 0) Then GDIPlus_GraphicsDrawLine($buffer, $wi2 + $wi, $i2 * $wi + 10 + $wi, $wi2, $i2 * $wi + 10 + $wi)
    			If (BitAND($maze[$i1][$i2], 0x8) = 0) Then GDIPlus_GraphicsDrawLine($buffer, $wi2, $i2 * $wi + 10, $wi2, $i2 * $wi + 10 + $wi)
    		Next
    	Next
    	GDIPlus_GraphicsDrawLine($buffer, ($startx * $wi - ($wi / 2)) + $wi + 10, ($starty * $wi) + 10, ($startx * $wi - ($wi / 2)) + $wi + 10, ($starty * $wi + $wi) + 10, $weg);start
    	GDIPlus_GraphicsDrawLine($buffer, ($endex * $wi - ($wi / 2)) + $wi + 10, ($endey * $wi) + 10, ($endex * $wi - ($wi / 2)) + $wi + 10, ($endey * $wi + $wi) + 10, $red);ende
    	_GDIPlus_GraphicsDrawImage($buffer, $bitmap, 0, 0)
    	If MsgBox(4, "LÖSEN?", "es hat " & $timer1Diff & " Sekunden gedauert " & $anzahlblocks & " felder zu erstellen" & @CRLF & "Soll das Labyrint gelöst werden?") = 6 Then
    		$solvex = $startx
    		$solvey = $starty
    		For $1a = UBound($splitter) - 1 To 0 Step -1;array wurde runter gepopt also ist es vom ende ausgehend
    			Switch $splitter[$1a]
    				Case 1;N
    					GDIPlus_GraphicsDrawLine($buffer, $solvex * $wi + $Temp_01, $solvey * $wi + $Temp_01, $solvex * $wi + $Temp_01, $solvey * $wi + $Temp_01 - $wi, $red)
    					$solvey -= 1
    				Case 2;O
    					GDIPlus_GraphicsDrawLine($buffer, $solvex * $wi + $Temp_01, $solvey * $wi + $Temp_01, $solvex * $wi + $Temp_01 + $wi, $solvey * $wi + $Temp_01, $red)
    					$solvex += 1
    				Case 3;S
    					GDIPlus_GraphicsDrawLine($buffer, $solvex * $wi + $Temp_01, $solvey * $wi + $Temp_01, $solvex * $wi + $Temp_01, $solvey * $wi + $Temp_01 + $wi, $red)
    					$solvey += 1
    				Case 4;W
    					GDIPlus_GraphicsDrawLine($buffer, $solvex * $wi + $Temp_01, $solvey * $wi + $Temp_01, $solvex * $wi + $Temp_01 - $wi, $solvey * $wi + $Temp_01, $red)
    					$solvex -= 1
    			EndSwitch
    		Next
    		_GDIPlus_GraphicsDrawImage($hGraphics, $bitmap, 0, 0)
    	EndIf
    	_GDIPlus_GraphicsDrawImage($buffer, $bitmap, 0, 0)
    	$hGraphics = _GDIPlus_GraphicsCreateFromHWND($Form2)
    	$solvex = $startx
    	$solvey = $starty
    	_GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF)
    	_GDIPlus_GraphicsDrawImage($hGraphics, $bitmap, 0, 0)
    	GDIPlus_GraphicsDrawLine($hGraphics, ($solvex * $wi - ($wi / 2)) + $wi + 10, 2 + (($solvey * $wi) + 10), ($solvex * $wi - ($wi / 2)) + $wi + 10, (($solvey * $wi + $wi) + 10) - 2, $red)
    	Do
    		Sleep(100)
    		If _IsPressed(57) And BitAND($maze[$solvex][$solvey], 1) = 1 Then;bewegung und wandtestN
    			$solvey -= 1;w
    			_GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF)
    			_GDIPlus_GraphicsDrawImage($hGraphics, $bitmap, 0, 0)
    			GDIPlus_GraphicsDrawLine($hGraphics, ($solvex * $wi - ($wi / 2)) + $wi + 10, 2 + (($solvey * $wi) + 10), ($solvex * $wi - ($wi / 2)) + $wi + 10, (($solvey * $wi + $wi) + 10) - 2, $red)
    		EndIf
    		If _IsPressed(41) And BitAND($maze[$solvex][$solvey], 8) = 8 Then;bewegung und wandtestW
    			$solvex -= 1;a
    			_GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF)
    			_GDIPlus_GraphicsDrawImage($hGraphics, $bitmap, 0, 0)
    			GDIPlus_GraphicsDrawLine($hGraphics, ($solvex * $wi - ($wi / 2)) + $wi + 10, 2 + (($solvey * $wi) + 10), ($solvex * $wi - ($wi / 2)) + $wi + 10, (($solvey * $wi + $wi) + 10) - 2, $red)
    		EndIf
    		If _IsPressed(53) And BitAND($maze[$solvex][$solvey], 4) = 4 Then;bewegung und wandtestS
    			$solvey += 1;s
    			_GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF)
    			_GDIPlus_GraphicsDrawImage($hGraphics, $bitmap, 0, 0)
    			GDIPlus_GraphicsDrawLine($hGraphics, ($solvex * $wi - ($wi / 2)) + $wi + 10, 2 + (($solvey * $wi) + 10), ($solvex * $wi - ($wi / 2)) + $wi + 10, (($solvey * $wi + $wi) + 10) - 2, $red)
    		EndIf
    		If _IsPressed(44) And BitAND($maze[$solvex][$solvey], 2) = 2 Then;bewegung und wandtestO
    			$solvex += 1;d
    			_GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF)
    			_GDIPlus_GraphicsDrawImage($hGraphics, $bitmap, 0, 0)
    			GDIPlus_GraphicsDrawLine($hGraphics, ($solvex * $wi - ($wi / 2)) + $wi + 10, 2 + (($solvey * $wi) + 10), ($solvex * $wi - ($wi / 2)) + $wi + 10, (($solvey * $wi + $wi) + 10) - 2, $red)
    		EndIf
    		If $solvex = $endex And $solvey = $endey Then;am ende angekommen
    			MsgBox(0, "", "Sie haben gewonnen!!")
    			_exit();beenden
    		EndIf
    	Until GUIGetMsg() = $GUI_EVENT_CLOSE
    EndFunc   ;==>_drawmaze
    Func GDIPlus_GraphicsDrawLine($hGraphics, $iX1, $iY1, $iX2, $iY2, $hPen = $black);kein errorhandling kein zeitverlust
    	DllCall($__g_hGDIPDll, "int", "GdipDrawLineI", "handle", $hGraphics, "handle", $hPen, "int", $iX1, "int", $iY1, "int", $iX2, "int", $iY2)
    EndFunc   ;==>GDIPlus_GraphicsDrawLine
    Func _exit()
    	_GDIPlus_BitmapDispose($bitmap);Aufräumen
    	_GDIPlus_PenDispose($red)
    	_GDIPlus_PenDispose($weg)
    	_GDIPlus_GraphicsDispose($hGraphics)
    	_GDIPlus_Shutdown()
    	Exit
    EndFunc   ;==>_exit
    Alles anzeigen

    bernd670: Code neu formatiert

  • WM_Notify reagiert nicht

    • bollen
    • 8. Mai 2014 um 17:25

    du definiertst in zeile 20 $ListeWE aber in zeile 33 weist du das handle des list views der variable $hListeWE zu. Wenn du das "h" entfernst funktioniert es :D

    €: Oskar war schneller :(

  • AutoIt & ASM

    • bollen
    • 7. Mai 2014 um 22:25

    Toller script Mars,
    €: stürzt leider tatsächlich ab wen der asm code länger ist
    leider wird der ASM code durch das sleep nur selten ausgeführt deshalb hab ich eine version mit Timern gemacht in der der code nicht so gebremst wird

    Spoiler anzeigen
    [autoit]

    #include 'EasyASM.au3'
    #include <WinAPI.au3>
    #include <Timers.au3>

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

    Opt('GUIOnEventMode', 1)
    _ASM_Startup()

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

    ; Haupteigenschaften des Programms
    Global Const $sTitel = 'Test 01' ; Titel des Fensters
    Global Const $iW = Int(@DesktopWidth / 256) * 128 ; Breite des Fensters
    Global Const $iH = Int(@DesktopHeight / 2) ; Höhe des Fensters
    Global Const $iMemSize = 64 ; Reserviertes RAM in Bytes
    Global Const $nFrameRate = 60 ; Gewünschte Framerate (ob diese eingehalten wird hängt vom BitBlt, sowie vom ASM ab)

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

    ; Aufbau der übergebenen Daten:
    ; int[5]
    ; [0] - Ptr für die Bitmapdaten
    ; [1] - Ptr für das reservierte RAM
    ; [2] - Anzahl reservierte Bytes (damit man im ASM weiß wie viel RAM man zur Verfügung hat)
    ; [3] - Breite der Anzeige | Die Anzahl Pixel errechnet man sich am
    ; [4] - Höhe der Anzeige | besten selbst, so bleibt $vData kleiner ;)
    Global $Memory = DllStructCreate('int[' & $iMemSize & ']')
    Global $Image = _ASM_CreateBitmap($iW, $iH)
    Global $hGUI = GUICreate($sTitel, $iW, $iH), $bExit = False
    Global $nAuslastung, $iFPS, $nFPS, $iFPS_Timer = TimerInit()
    Global $hDC = _WinAPI_GetDC($hGUI), $hDC_IMG = DllStructGetData($Image, 1, 1)
    Global $ntDLL = DllOpen('ntdll.dll'), $vNano = DllStructCreate('int64 time'), $pNano = DllStructGetPtr($vNano)
    Global $vData = DllStructCreate('int[5]'), $pData = DllStructGetPtr($vData)
    Global $iMyASM = _ASM_AddOP(_MyASM())
    DllStructSetData($vData, 1, DllStructGetData($Image, 1, 4), 1) ; Ptr auf die Bitmapdaten
    DllStructSetData($vData, 1, DllStructGetPtr($Memory), 2) ; Ptr auf das reservierte RAM
    DllStructSetData($vData, 1, $iMemSize, 3) ; Anzahl reservierte Bytes
    DllStructSetData($vData, 1, $iW, 4) ; Breite der Anzeige
    DllStructSetData($vData, 1, $iH, 5) ; Höhe der Anzeige
    GUISetOnEvent(-3, '_Exit', $hGUI)
    GUISetState(@SW_SHOW, $hGUI)

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

    Global $i_timer1delay=10
    $timer = _Timer_SetTimer($hGUI, $i_timer1delay, "Paint");zeichnet alle x sekunden die GUI neu
    _Main()

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

    ; ===============================================================================================================================
    ; Hier den eigenen Code einfügen. Das Restliche Skript unberührt lassen (außer man möchte es erweitern oder Fehler bekämpfen)
    ; ===============================================================================================================================
    Func _MyASM()
    _('use32')

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

    ; Beim Call sind die Adressen um 4 Byte verschoben,
    ; später, beim Zugriff auf unsere Struct um Ram oder
    ; beim Zugriff auf die Bitmap ist das nicht mehr so !
    ; Um zur ersten Struct zu kommen müssen wir [esp+4] nehmen,
    ; hier liegt die ptr zu unserer DatenStruct

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

    _('mov eax, [esp+4]') ; Ptr auf die Datenstruct

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

    ; Wir wissen wie die Struct aussieht:
    ; ptrIMG|ptrMEM|anzahl|breite|höhe
    ; +0 | +4 | +8 | +12 | +16
    ; Hier gibts keine Verschiebung mehr, nie wieder :)

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

    _('mov ebx, [eax+12]') ; Breite der Anzeige
    _('mov ecx, [eax+16]') ; Höhe der Anzeige
    _('imul ecx, ebx') ; Anzahl Pixel in ecx

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

    ; Jetzt haben wir erstmal die Anzahl Pixel
    ; Fehlt nur noch eine Position an der wir
    ; wild herummalen können...

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

    _('mov esi, [eax]') ; Ptr der Anzeige in ebx

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

    ; man könnte jetzt jedes freie Register nutzen,
    ; wir nehmen einfach mal esi.
    ; Damit wir das Bild färben können brauchen
    ; wir noch eine Farbe die sich am besten
    ; laufend verändert. Dazu springen wir in
    ; unser bereitgestelltes RAM und benutzen die ersten 4 Byte. (0x FF FF FF FF = 4 Byte)

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

    _('mov edx, [eax+4]') ; Ptr unseres Rams
    _('mov ebx, [edx]') ; Unsere ersten 4 Bytes !
    _('add ebx, 1024') ; Wir erhöhen die Farbe
    _('or ebx, 0xFF000000') ; Falls der Alphakanal flöten geht (overflow)
    _('mov [edx], ebx') ; neue Farbe speichern

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

    ; Jetzt nur noch Alle Pixel ablaufen und die
    ; Farbe hineinmalen. (Dabei kann man sie natürlich
    ; weiterhin nach belieben manupulieren). Zum Glück
    ; haben wir ptrIMG sowie die Anzahl Pixel bereits in esi und ecx

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

    _('_Label_01:') ; Sprungstelle mit kreativem Namen
    _('add ebx, 512') ; Weil es so schön war :)
    _('or ebx, 0xFF200080') ; bischl
    _('mov [esi], ebx') ; Die Farbe in die Bitmap schreiben

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

    _('add esi, 4') ; 1PX = 4Byte weiterrücken
    _('dec ecx') ; Verbleibende Pixel = einer weniger als vorher (dec = decrement -> ecx -=1)
    _('ja _Label_01') ; Solange ecx > 0 springen wir zur Sprungstelle (ja = jump above)
    _('')
    _('')
    _('')
    _('ret') ; Braucht keine Sau :O

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

    EndFunc ;==>_MyASM
    ; ===============================================================================================================================
    ; Hauptschleife inklusive Datenfreigabe
    ; ===============================================================================================================================
    Func _Main()
    While Not $bExit
    _ASM_Call($iMyASM, $pData); ASM code ausführen
    If TimerDiff($iFPS_Timer) > 1000 Then
    $iFPS_Timer = TimerInit()
    $nFPS = $iFPS
    $iFPS = 0
    WinSetTitle($hGUI, '', $sTitel & ' - (@' & $nFPS & 'FPS)')
    EndIf
    WEnd
    _Release()
    EndFunc ;==>_Main

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

    Func Paint($hWnd, $Msg, $iIDTimer, $dwTime)
    _WinAPI_BitBlt($hDC, 0, 0, $iW, $iH, $hDC_IMG, 0, 0, 0xCC0020);blittet in die GUI
    $iFPS += 1;fps + 1 ;D
    _Timer_SetTimer($hGUI, $i_timer1delay, "Paint", $timer);timer widerverwenden
    EndFunc ;==>Paint
    ; ===============================================================================================================================
    ; Die eigentliche Funktion um alle benutzten Ressourcen freizugeben.
    ; ===============================================================================================================================
    Func _Release()
    _Timer_KillAllTimers($hGUI);timer killen
    _WinAPI_ReleaseDC($hGUI, $hDC)
    $_Memory = 0
    _ASM_DeleteBitmap($Image)
    _ASM_Shutdown()
    DllClose($ntDLL)
    EndFunc ;==>_Release

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

    ; ===============================================================================================================================
    ; Da man mittem im ASM nicht unbedingt aus dem Skript gehen sollte,
    ; gibt es eine Variable die ein beenden der Hauptschleife verursacht.
    ; Der laufende ASM Code wird also nicht unterbrochen.
    ; ===============================================================================================================================
    Func _Exit()
    $bExit = True
    EndFunc ;==>_Exit

    [/autoit]


    €: unpassender ASM code für das Beispiel da es jetzt natürlich zu oft läuft

  • ListView mit Spalten- und Zeilenüberschriften

    • bollen
    • 6. Mai 2014 um 17:59

    meinst du etwa so etwas ?
    Das würde ich unter Zeilenüberschrift verstehen

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <ListviewConstants.au3>

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

    Opt('GUIOnEventMode', 1)

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

    Global Const $sTitle = "ListView Test"
    $Width = 429
    $Height = 341
    $platzhalter=" ";schöner mit _GUICtrlListView_SetColumnWidth(
    Global $hGUIMain = GUICreate($sTitle, $Width, $Height, 22, 22, 0x80C70000)
    Global $lstStrct = GUICtrlCreateListView($platzhalter&"|Spalte 1|Spalte 2|Spalte 3|Spalte 4", 13, 32, $Width - 26, $Height - 82, 0, BitOr($LVS_EX_DOUBLEBUFFER, $WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT))
    For $i1=0 to 9;ein paar items einfügen
    GUICtrlCreateListViewItem("Zeilenüberschrift "&$i1&"|text1|text2|text3|text4" ,$lstStrct)
    Next
    GUISetOnEvent(-3, '_Close', $hGUIMain)

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

    GUICtrlSetResizing($lstStrct, 0x66)

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

    GUISetState(@SW_SHOW, $hGUIMain)

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

    While 1
    WEnd

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

    Func _Close()
    Exit
    EndFunc

    [/autoit]
  • GUI Bild verhindert Eingaben

    • bollen
    • 6. Mai 2014 um 17:38

    du musst dem Bild noch Disabeln sonst fängt es alle events ab.

    [autoit]


    #include <GuiConstantsEx.au3>
    #include <WindowsConstants.au3>
    _start()

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

    func _start()
    GuiCreate("Welcome",854,333)
    GUICtrlCreatePic("bg_checkin.jpg",-5,0,864,343)
    GUICtrlSetState(-1 ,$GUI_DISABLE);verhindert das das Bild die events abfängt
    GuiSetState(@SW_Show)
    $Name = GuiCTRLCreateInput("Type in your user name", 625,25,125,20)
    $PW = GuiCTRLCreateInput("Type in your password",625,75,125,20)
    $Save = GUICtrlCreateCheckbox("Remember LogIn",625,125)
    $LogIn = GuiCtrlCreateButton("LogIn now",625,175)
    While 1
    $gmsg = GuiGetMsg()
    Switch $gmsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

    [/autoit]

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™