Das Bild wird nur ein mal angezeigt weil SplashImage nur ein mal aktiv sein kann. ![]()
Du müsstest eine andere Anzeigemethode wählen, wenn du das Bild in mehreren Fenstern sehen willst.
z.B. Ein Fenster mit dem Stil $WS_POPUP, was einem SplashImage schon recht nahe kommt denke ich.
Beiträge von name22
-
-
Hier ist ein ganz einfaches GDI+ Script, welches einem Bildschrimschoner ähnelt...
Ich habe die benötigte Schriftart mit der MemFont Methode ins Script gepackt.
Hoffe es gefällt euch...
Ich musste das Script wegen der über 1MB großen Schriftart in ein zip packen.

Edit: Da das Script über 100000 Zeichen lang ist konnte ich es natürlich hier nicht spoilern.

Edit2: Ich habe nun Ubuntus Version als Screensaver noch mit angehängt, wer ihn installieren will muss einfach nur das Script kompilieren und in .scr umbenennen ;).
Edit3: Das Script lädt nun die mit ";" getrennten Wörter/Sätze aus einer Datei im Scriptverzeichnis und zeigt sie in zufälliger Reihenfolge an.
-
So eine Explosion? Oder größer als die Platten selbst?
-
Ich auch. Wenn du das selbst gemacht hast bin ich wirklich tief beeindruckt.

-
Zitat
immer wenn ich ini's verwende geht irgentwas schief
Scheinbar brauchen wir jetzt auch noch ein gutes Ini Tutorial...
Was meinst du denn mit "Etwas geht schief"? Vielleicht ist es ja etwas ganz banales bei dem man dir sofort helfen kann.
-
Zitat
Danke, das funktioniert, nur wenn ich 1 töte, dann töte ich alle ausser 1

Das hängt mit deinem Array zusammen ich hab im Moment leider keine Zeit mich damit zubeschäftigen.
Schau dir mal an wie das 2 dimensionale Array von den Schüssen verwendet wird.
-
Horizontal? Oh ich hab mich schon wieder verschrieben.
Ich meinte, dass bei den sich vertikal verschiebenden Platten der Doodle manchmal ein bisschen Höhenversetzt abspringt. -
Die neue Version funktioniert bis auf die Horizontalen Platten echt Prima.
Ich bin von diesem Projekt echt beeindruckt. Das ist ein absolutes Aushängeschild für AutoIt Spiele
Das Spiel ist ja schon eine richtige Herausforderung geworden.
-
Das ist das gleiche was wir 3 vor dir schon geschrieben haben...

-
So?
Spoiler anzeigen
[autoit]#include <GUIConstantsEx.au3>
[/autoit] [autoit][/autoit] [autoit]$Form1 = GUICreate("Form1", 165, 81, 192, 124)
[/autoit] [autoit][/autoit] [autoit]
$Label1 = GUICtrlCreateLabel("AutoIt", 24,
$Label2 = GUICtrlCreateLabel("Google", 24, 32)
$Label3 = GUICtrlCreateLabel("Youtube", 24, 56)
GUISetState()While 1
[/autoit]
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Label1
ShellExecute("http://www.autoit.de/")
Case $Label2
ShellExecute("http://www.google.de/")
Case $Label3
ShellExecute("http://www.youtube.com/")
EndSwitch
WEnd -
Wenn ich weiß wofür das ist helfe ich dir.

1. Fehlt da ein EndIf.
2. Macht man eine Zählschleife lieber mit For.
3. Liess die Hilfe
-
Du könntest dir wenigstens ein bisschen mehr Mühe geben.

Ich kann nicht ALLES für dich machen, es ist ja schließlich DEIN Projekt.
Spoiler anzeigen
[autoit]#include <GDIPlus.au3>
[/autoit] [autoit][/autoit] [autoit]
#include <Misc.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]$iGUIWidth = 400
[/autoit] [autoit][/autoit] [autoit]
$iGUIHeight = 400
$GUIColorBG = 0xFF000000$iShots = 0
[/autoit] [autoit][/autoit] [autoit]
$iMaxShots = 5 + 1
$iShotSpeed = 3
$iCoolDownTime = 500
$iTimerShot = $iCoolDownTime * - 1
$iTimerGegner = TimerInit()$hU32DLL = DllOpen("User32.dll")
[/autoit] [autoit][/autoit] [autoit]$hWnd = GUICreate("Space Invaders", $iGUIWidth, $iGUIHeight)
[/autoit] [autoit][/autoit] [autoit]
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetState()_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
[/autoit] [autoit][/autoit] [autoit]
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iGUIWidth, $iGUIHeight, $hGraphic)
$hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
_GDIPlus_GraphicsClear($hGraphic, $GUIColorBG)$hImage_Enemy = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\gegner.jpg")
[/autoit] [autoit][/autoit] [autoit]
$hImage_Ship = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Raumschiff.jpg")
$hBrush_Shot = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)Dim $aGegner[2][2]
[/autoit] [autoit][/autoit] [autoit]
For $i = 1 To 5
_Array2DAdd($aGegner, 0 + (($i - 1) * 45) & "|" & 0)
NextDim $aShot[2][2]
[/autoit] [autoit][/autoit] [autoit]$iX_Ship = $iGUIWidth / 2 - 25
[/autoit] [autoit][/autoit] [autoit]
$iY_Ship = $iGUIHeight - 30While 1
[/autoit] [autoit][/autoit] [autoit]
If _IsPressed("27", $hU32DLL) And $iX_Ship < $iGUIWidth - 50 Then $iX_Ship += 2
If _IsPressed("25", $hU32DLL) And $iX_Ship > 0 Then $iX_Ship -= 2
If _IsPressed("20", $hU32DLL) And TimerDiff($iTimerShot) >= $iCoolDownTime And UBound($aShot) < $iMaxShots Then
_Array2DAdd($aShot, $iX_Ship + 21 & "|" & $iY_Ship - 10)
$iTimerShot = TimerInit()
EndIf_GDIPlus_GraphicsClear($hBuffer, $GUIColorBG)
[/autoit] [autoit][/autoit] [autoit]
For $i = 1 To UBound($aShot) - 1
If $aShot[$i][1] <> "" Then
_GDIPlus_GraphicsFillRect($hBuffer, $aShot[$i][0], $aShot[$i][1], 5, 10, $hBrush_Shot)
$aShot[$i][1] -= $iShotSpeed
EndIf
Next
For $i = 1 To UBound($aShot) - 1
If $aShot[$i][1] <= 0 Then
_Array2DDelete($aShot, $i)
ExitLoop
EndIf
For $j = 2 To UBound($aGegner) - 1
If $aShot[$i][1] <= $aGegner[$j][1] + 23 And $aShot[$i][0] >= $aGegner[$i][0] And $aShot[$i][0] <= $aGegner[$i][0] + 40 Then
_Array2DDelete($aGegner, $j)
ExitLoop
EndIf
Next
Next
If TimerDiff($iTimerGegner) >= 1000 Then
For $i = 1 To UBound($aGegner) - 1
If $aGegner[$i][0] + 40 >= $iGUIWidth Then
$aGegner[$i][1] += 25
$aGegner[$i][0] = 0
Else
$aGegner[$i][0] += 45
EndIf
Next
$iTimerGegner = TimerInit()
EndIf
For $i = 1 To UBound($aGegner) - 1
_GDIPlus_GraphicsDrawImageRect($hBuffer, $hImage_Enemy, $aGegner[$i][0], $aGegner[$i][1], 40, 23)
Next
_GDIPlus_GraphicsDrawImageRect($hBuffer, $hImage_Ship, $iX_Ship, $iY_Ship, 50, 30)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iGUIWidth, $iGUIHeight)
Sleep(20)
WEndFunc _Exit()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
DllClose($hU32DLL)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_GraphicsDispose($hBuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_ImageDispose($hImage_Ship)
_GDIPlus_BrushDispose($hBrush_Shot)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_Exit;------------------------------------------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]
;
; Function _Array2DAdd(ByRef $avArray, $sValue='')
;
; Description Redim Array Size and add an Array element at last position
; Works with any occurences in 2nd Dimension
; Works also with 1D-Array
;
; Parameter $avArray Given Array
; optional $sValue Value of new Element, parts must be seperate with '|'
;
; Return Succes -1
; Failure 0 and set @error
; @error = 1 given array is not array
; @error = 2 given parts of Element too less/much
;
; Author BugFix ([email='bugfix@autoit.de'][/email])
;------------------------------------------------------------------------------------------------------------
Func _Array2DAdd(ByRef $avArray, $sValue = '')
If (Not IsArray($avArray)) Then
SetError(1)
Return 0
EndIf
Local $i
Local $UBound2nd = UBound($avArray, 2)
If @error = 2 Then
ReDim $avArray[UBound($avArray) + 1]
$avArray[UBound($avArray) - 1] = $sValue
Else
Local $arValue
ReDim $avArray[UBound($avArray) + 1][$UBound2nd]
If $sValue = '' Then
For $i = 0 To $UBound2nd - 2
$sValue &= '|'
Next
EndIf
$arValue = StringSplit($sValue, '|')
If $arValue[0] <> $UBound2nd Then
SetError(2)
Return 0
EndIf
For $i = 0 To $UBound2nd - 1
$avArray[UBound($avArray) - 1][$i] = $arValue[$i + 1]
Next
EndIf
Return -1
EndFunc ;==>_Array2DAdd;----------------------------------------------------------------------------------------------------------------------
[/autoit]
; Fuction _Array2DDelete(ByRef $ARRAY, $iDEL)
;
; Description Delete one row on a given index in an 1D/2D -Array
;
; Parameter $ARRAY the array, where one row will deleted
; $iDEL Row-Index to delete
;
; Return Succes -1 ByRef $ARRAY
; Failure 0 set @error = 1; given array are not array
; set @error = 2; index is out of range
;
; Author BugFix ([email='bugfix@autoit.de'][/email])
;----------------------------------------------------------------------------------------------------------------------
Func _Array2DDelete(ByRef $ARRAY, $iDEL)
If (Not IsArray($ARRAY)) Then
SetError(1)
Return 0
EndIf
If ($iDEL < 0) Or ($iDEL > UBound($ARRAY) - 1) Then
SetError(2)
Return 0
EndIf
Local $i, $k, $l
Local $UBound2nd = UBound($ARRAY, 2)
If @error = 2 Then
Local $arTmp[UBound($ARRAY) - 1]
$k = 0
For $i = 0 To UBound($ARRAY) - 1
If $i <> $iDEL Then
$arTmp[$k] = $ARRAY[$i]
$k += 1
EndIf
Next
Else
Local $arTmp[UBound($ARRAY) - 1][$UBound2nd]
$k = 0
For $i = 0 To UBound($ARRAY) - 1
If $i <> $iDEL Then
For $l = 0 To $UBound2nd - 1
$arTmp[$k][$l] = $ARRAY[$i][$l]
Next
$k += 1
EndIf
Next
EndIf
$ARRAY = $arTmp
Return -1
EndFunc ;==>_Array2DDelete
Müsste so funktionieren, ich hab's noch nicht wirklich getestet.
-
Würdest du mir mal zuhören hättest du's hinbekommen
.
Ich bin schon auf die nächste Version gespannt.
Viel fehlt ja nicht bis zum Original. 
-
Den Botverdacht hatte ich nur weil ca. 5 Minuten vorher ein anderer Thread von Keane wegen einem Bot geclosed wurde.
-
Zitat
Ich habe noch ein nettes Skript hier zu liegen ,das dein Programm schützen kann.
Eben das ist aus oben genannten Gründen nicht möglich...
Jeder "trottel" der einen Decompiler hat kann einfach deine exe zurück in ein Script verwandeln und diese Update Funktion entfernen.
Oder er wartet einfach bis irgend ein anderer das gemacht hat und holt sich dann die Version ohne deinen Check.
Ach ja, hier das Ergebnis der Forensuche.

MysticSun: Wieso stellst du denn dein Script nicht einfach hier rein?
-
Kann es sein, dass das ganze im OnEvent Mode besser ist?
Spoiler anzeigen
[autoit]#include <GDIPlus.au3>
[/autoit] [autoit][/autoit] [autoit]
#include <GUIConstants.au3>
#include <Misc.au3>Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]$iGUIWidth = 400
[/autoit] [autoit][/autoit] [autoit]
$iGUIHeight = 400
$GUIColorBG = 0xFF000000$iShots = 0
[/autoit] [autoit][/autoit] [autoit]
$iMaxShots = 5 + 1
$iShotSpeed = 3
$iCoolDownTime = 500
$iTimerShot = $iCoolDownTime * - 1$hU32DLL = DllOpen("User32.dll")
[/autoit] [autoit][/autoit] [autoit]$hWnd = GUICreate("Space Invaders", $iGUIWidth, $iGUIHeight)
[/autoit] [autoit][/autoit] [autoit]
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetState()_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
[/autoit] [autoit][/autoit] [autoit]
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iGUIWidth, $iGUIHeight, $hGraphic)
$hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
_GDIPlus_GraphicsClear($hGraphic, $GUIColorBG)$hImage_Ship = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Raumschiff.jpg")
[/autoit] [autoit][/autoit] [autoit]
$hBrush_Shot = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)Dim $aShot[2][2]
[/autoit] [autoit][/autoit] [autoit]$iX_Ship = $iGUIWidth / 2 - 25
[/autoit] [autoit][/autoit] [autoit]
$iY_Ship = $iGUIHeight - 30While 1
[/autoit] [autoit][/autoit] [autoit]
If _IsPressed("27", $hU32DLL) And $iX_Ship < $iGUIWidth - 50 Then $iX_Ship += 2
If _IsPressed("25", $hU32DLL) And $iX_Ship > 0 Then $iX_Ship -= 2
If _IsPressed("20", $hU32DLL) And TimerDiff($iTimerShot) >= $iCoolDownTime And UBound($aShot) < $iMaxShots Then
_Array2DAdd($aShot, $iX_Ship + 23 & "|" & $iY_Ship - 10)
$iTimerShot = TimerInit()
EndIf_GDIPlus_GraphicsClear($hBuffer, $GUIColorBG)
[/autoit] [autoit][/autoit] [autoit]
For $i = 1 To UBound($aShot) - 1
If $aShot[$i][1] <> "" Then
_GDIPlus_GraphicsFillRect($hBuffer, $aShot[$i][0], $aShot[$i][1], 5, 10, $hBrush_Shot)
$aShot[$i][1] -= $iShotSpeed
EndIf
Next
For $i = 1 To UBound($aShot) - 1
If $aShot[$i][1] <= 0 Then
_Array2DDelete($aShot, $i)
ExitLoop
EndIf
Next
_GDIPlus_GraphicsDrawImageRect($hBuffer, $hImage_Ship, $iX_Ship, $iY_Ship, 50, 30)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iGUIWidth, $iGUIHeight)
Sleep(20)
WEndFunc _Exit()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
DllClose($hU32DLL)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_GraphicsDispose($hBuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_ImageDispose($hImage_Ship)
_GDIPlus_BrushDispose($hBrush_Shot)
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_Exit;------------------------------------------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]
;
; Function _Array2DAdd(ByRef $avArray, $sValue='')
;
; Description Redim Array Size and add an Array element at last position
; Works with any occurences in 2nd Dimension
; Works also with 1D-Array
;
; Parameter $avArray Given Array
; optional $sValue Value of new Element, parts must be seperate with '|'
;
; Return Succes -1
; Failure 0 and set @error
; @error = 1 given array is not array
; @error = 2 given parts of Element too less/much
;
; Author BugFix ([email='bugfix@autoit.de'][/email])
;------------------------------------------------------------------------------------------------------------
Func _Array2DAdd(ByRef $avArray, $sValue = '')
If (Not IsArray($avArray)) Then
SetError(1)
Return 0
EndIf
Local $i
Local $UBound2nd = UBound($avArray, 2)
If @error = 2 Then
ReDim $avArray[UBound($avArray) + 1]
$avArray[UBound($avArray) - 1] = $sValue
Else
Local $arValue
ReDim $avArray[UBound($avArray) + 1][$UBound2nd]
If $sValue = '' Then
For $i = 0 To $UBound2nd - 2
$sValue &= '|'
Next
EndIf
$arValue = StringSplit($sValue, '|')
If $arValue[0] <> $UBound2nd Then
SetError(2)
Return 0
EndIf
For $i = 0 To $UBound2nd - 1
$avArray[UBound($avArray) - 1][$i] = $arValue[$i + 1]
Next
EndIf
Return -1
EndFunc ;==>_Array2DAdd;----------------------------------------------------------------------------------------------------------------------
[/autoit]
; Fuction _Array2DDelete(ByRef $ARRAY, $iDEL)
;
; Description Delete one row on a given index in an 1D/2D -Array
;
; Parameter $ARRAY the array, where one row will deleted
; $iDEL Row-Index to delete
;
; Return Succes -1 ByRef $ARRAY
; Failure 0 set @error = 1; given array are not array
; set @error = 2; index is out of range
;
; Author BugFix ([email='bugfix@autoit.de'][/email])
;----------------------------------------------------------------------------------------------------------------------
Func _Array2DDelete(ByRef $ARRAY, $iDEL)
If (Not IsArray($ARRAY)) Then
SetError(1)
Return 0
EndIf
If ($iDEL < 0) Or ($iDEL > UBound($ARRAY) - 1) Then
SetError(2)
Return 0
EndIf
Local $i, $k, $l
Local $UBound2nd = UBound($ARRAY, 2)
If @error = 2 Then
Local $arTmp[UBound($ARRAY) - 1]
$k = 0
For $i = 0 To UBound($ARRAY) - 1
If $i <> $iDEL Then
$arTmp[$k] = $ARRAY[$i]
$k += 1
EndIf
Next
Else
Local $arTmp[UBound($ARRAY) - 1][$UBound2nd]
$k = 0
For $i = 0 To UBound($ARRAY) - 1
If $i <> $iDEL Then
For $l = 0 To $UBound2nd - 1
$arTmp[$k][$l] = $ARRAY[$i][$l]
Next
$k += 1
EndIf
Next
EndIf
$ARRAY = $arTmp
Return -1
EndFunc ;==>_Array2DDelete -
So einen Thread gab es hier schon mal. Einfach die Forensuche nutzen.
Abgesehen davon ist es dank Decompilern fast unmöglich seine Scripts irgendwie zu schützen.
-
UEZ meinst du nicht das ist ein wenig zu viel auf einmal für einen GDI+ Anfänger.

Obwohl es natürlich die absolute Musterlösung eines AutoIt Spiels darstellt.
-
Ein kleines Beispiel? Ich versuch's.

Spoiler anzeigen
[autoit]#include <Misc.au3>
[/autoit] [autoit][/autoit] [autoit]
#include <GDIPlus.au3>
#include <GUIConstants.au3>_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$hBitmap = _GDIPlus_BitmapCreateFromFile(FileOpenDialog("Bild auswählen", @ScriptDir, "Bilder (*.jpg;*.png;*.bmp)", 3))
[/autoit] [autoit][/autoit] [autoit]
$iWidth = _GDIPlus_ImageGetWidth($hBitmap)
$iHeight = _GDIPlus_ImageGetHeight($hBitmap)MsgBox(64, "Farbe", "Zu suchende Farbe auswählen")
[/autoit] [autoit][/autoit] [autoit]
$iSearchColor = StringTrimLeft(_ChooseColor(2), 2)
MsgBox(64, "Farbe", "Füllfarbe auswählen")
$iFillColor = StringTrimLeft(_ChooseColor(2), 2)For $iY = 0 To $iHeight
[/autoit] [autoit][/autoit] [autoit]
For $iX = 0 To $iWidth
If _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY) = "0xFF" & $iSearchColor Then _GDIPlus_BitmapSetPixel($hBitmap, $iX, $iY, "0xFF" & $iFillColor)
Next
Next_GDIPlus_ImageSaveToFile($hBitmap, FileSaveDialog("Bild speichern unter", @ScriptDir, "(*.png)", 18) & ".png")
[/autoit] [autoit][/autoit] [autoit]; #FUNCTION# ====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Name...........: _GDIPlus_BitmapGetPixel
; Description ...: Gets the color of a specified pixel in this bitmap
; Syntax.........: _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY)
; Parameters ....: $hBitmap - Pointer to the Bitmap object
; $iX - The X coordinate of the pixel
; $iY - The Y coordinate of the pixel
; Return values .: Success - Returns the pixel color of the bitmap
; Failure - 0 and either:
; |@error and @extended are set if DllCall failed
; |$GDIP_STATUS contains a non zero value specifying the error code
; Remarks .......: None
; Related .......: _GDIPlus_BitmapSetPixel
; Link ..........; @@MsdnLink@@ GdipBitmapGetPixel
; Example .......; Yes
; ===============================================================================================================================
Func _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipBitmapGetPixel", "hwnd", $hBitmap, "int", $iX, "int", $iY, "uint*", 0)If @error Then Return SetError(@error, @extended, 0)
[/autoit] [autoit][/autoit] [autoit]
$GDIP_STATUS = $aResult[0]
Return $aResult[4]
EndFunc ;==>_GDIPlus_BitmapGetPixel; #FUNCTION# ====================================================================================================================
[/autoit] [autoit][/autoit] [autoit]
; Name...........: _GDIPlus_BitmapSetPixel
; Description ...: Sets the color of a specified pixel in this bitmap
; Syntax.........: _GDIPlus_BitmapSetPixel($hBitmap, $iX, $iY, $iARGB)
; Parameters ....: $hBitmap - Pointer to the Bitmap object
; $iX - The X coordinate of the pixel
; $iY - The Y coordinate of the pixel
; $iARGB - The new color of the pixel
; Return values .: Success - True
; Failure - False and either:
; |@error and @extended are set if DllCall failed
; |$GDIP_STATUS contains a non zero value specifying the error code
; Remarks .......: None
; Related .......: _GDIPlus_BitmapGetPixel
; Link ..........; @@MsdnLink@@ GdipBitmapSetPixel
; Example .......; Yes
; ===============================================================================================================================
Func _GDIPlus_BitmapSetPixel($hBitmap, $iX, $iY, $iARGB)
Local $aResult = DllCall($ghGDIPDll, "uint", "GdipBitmapSetPixel", "hwnd", $hBitmap, "int", $iX, "int", $iY, "uint", $iARGB)If @error Then Return SetError(@error, @extended, False)
[/autoit]
$GDIP_STATUS = $aResult[0]
Return $aResult[0] = 0
EndFunc ;==>_GDIPlus_BitmapSetPixel -
Ich hatte nur die zwei If Abfragen bei _IsPressed vertauscht
So stimmt es und man kann nicht zur Seite raus:Spoiler anzeigen
[autoit]#include <GDIPlus.au3>
[/autoit] [autoit][/autoit] [autoit]
#include <GUIConstants.au3>
#include <Misc.au3>$iGUIWidth = 400
[/autoit] [autoit][/autoit] [autoit]
$iGUIHeight = 400
$GUIColorBG = 0xFF000000$iShots = 0
[/autoit] [autoit][/autoit] [autoit]
$iMaxShots = 5
$iShotSpeed = 5
$iCoolDownTime = 500
$iTimerShot = $iCoolDownTime * - 1$hWnd = GUICreate("Test", $iGUIWidth, $iGUIHeight)
[/autoit] [autoit][/autoit] [autoit]
GUISetState()_GDIPlus_Startup()
[/autoit] [autoit][/autoit] [autoit]$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
[/autoit] [autoit][/autoit] [autoit]
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iGUIWidth, $iGUIHeight, $hGraphic)
$hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
_GDIPlus_GraphicsClear($hGraphic, $GUIColorBG)$hImage_Ship = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Raumschiff.jpg")
[/autoit] [autoit][/autoit] [autoit]
$hBrush_Shot = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)Dim $aShot[2][2]
[/autoit] [autoit][/autoit] [autoit]$iX_Ship = $iGUIWidth / 2 - 25
[/autoit] [autoit][/autoit] [autoit]
$iY_Ship = $iGUIHeight - 30AdlibRegister("_ReDraw", 20)
[/autoit] [autoit][/autoit] [autoit]While 1
[/autoit] [autoit][/autoit] [autoit]
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
AdlibUnRegister()
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_GraphicsDispose($hBuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_ImageDispose($hImage_Ship)
_GDIPlus_BrushDispose($hBrush_Shot)
_GDIPlus_Shutdown()
Exit
EndSwitch
WEndFunc _ReDraw()
[/autoit] [autoit][/autoit] [autoit]
If _IsPressed("27") And $iX_Ship < $iGUIWidth - 50 Then $iX_Ship += 2
If _IsPressed("25") And $iX_Ship > 0 Then $iX_Ship -= 2
If _IsPressed("20") And TimerDiff($iTimerShot) >= $iCoolDownTime And UBound($aShot) < $iMaxShots Then
_Array2DAdd($aShot, $iX_Ship + 23 & "|" & $iY_Ship - 10)
$iTimerShot = TimerInit()
EndIf_GDIPlus_GraphicsClear($hBuffer, $GUIColorBG)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
For $i = 1 To UBound($aShot) - 1
If $aShot[$i][1] <> "" Then
_GDIPlus_GraphicsFillRect($hBuffer, $aShot[$i][0], $aShot[$i][1], 5, 10, $hBrush_Shot)
$aShot[$i][1] -= $iShotSpeed
EndIf
Next
For $i = 1 To UBound($aShot) - 1
If $aShot[$i][1] <= 0 Then
_Array2DDelete($aShot, $i)
ExitLoop
EndIf
Next
_GDIPlus_GraphicsDrawImageRect($hBuffer, $hImage_Ship, $iX_Ship, $iY_Ship, 50, 30)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iGUIWidth, $iGUIHeight)
EndFunc ;==>_ReDraw;------------------------------------------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]
;
; Function _Array2DAdd(ByRef $avArray, $sValue='')
;
; Description Redim Array Size and add an Array element at last position
; Works with any occurences in 2nd Dimension
; Works also with 1D-Array
;
; Parameter $avArray Given Array
; optional $sValue Value of new Element, parts must be seperate with '|'
;
; Return Succes -1
; Failure 0 and set @error
; @error = 1 given array is not array
; @error = 2 given parts of Element too less/much
;
; Author BugFix ([email='bugfix@autoit.de'][/email])
;------------------------------------------------------------------------------------------------------------
Func _Array2DAdd(ByRef $avArray, $sValue='')
If ( Not IsArray($avArray) ) Then
SetError(1)
Return 0
EndIf
Local $i
Local $UBound2nd = UBound($avArray,2)
If @error = 2 Then
ReDim $avArray[UBound($avArray)+1]
$avArray[UBound($avArray)-1] = $sValue
Else
Local $arValue
ReDim $avArray[UBound($avArray)+1][$UBound2nd]
If $sValue = '' Then
For $i = 0 To $UBound2nd-2
$sValue &= '|'
Next
EndIf
$arValue = StringSplit($sValue, '|')
If $arValue[0] <> $UBound2nd Then
SetError(2)
Return 0
EndIf
For $i = 0 To $UBound2nd-1
$avArray[UBound($avArray)-1][$i] = $arValue[$i+1]
Next
EndIf
Return -1
EndFunc ;==>_Array2DAdd;----------------------------------------------------------------------------------------------------------------------
[/autoit]
; Fuction _Array2DDelete(ByRef $ARRAY, $iDEL)
;
; Description Delete one row on a given index in an 1D/2D -Array
;
; Parameter $ARRAY the array, where one row will deleted
; $iDEL Row-Index to delete
;
; Return Succes -1 ByRef $ARRAY
; Failure 0 set @error = 1; given array are not array
; set @error = 2; index is out of range
;
; Author BugFix ([email='bugfix@autoit.de'][/email])
;----------------------------------------------------------------------------------------------------------------------
Func _Array2DDelete(ByRef $ARRAY, $iDEL)
If ( Not IsArray($ARRAY) ) Then
SetError(1)
Return 0
EndIf
If ( $iDEL < 0 ) Or ( $iDEL > UBound($ARRAY)-1 ) Then
SetError(2)
Return 0
EndIf
Local $i, $k, $l
Local $UBound2nd = UBound($ARRAY,2)
If @error = 2 Then
Local $arTmp[UBound($ARRAY)-1]
$k = 0
For $i = 0 To UBound($ARRAY)-1
If $i <> $iDEL Then
$arTmp[$k] = $ARRAY[$i]
$k += 1
EndIf
Next
Else
Local $arTmp[UBound($ARRAY)-1][$UBound2nd]
$k = 0
For $i = 0 To UBound($ARRAY)-1
If $i <> $iDEL Then
For $l = 0 To $UBound2nd-1
$arTmp[$k][$l] = $ARRAY[$i][$l]
Next
$k += 1
EndIf
Next
EndIf
$ARRAY = $arTmp
Return -1
EndFunc ;==>_Array2DDelete