Hallo,
irgendwie schaffe ich es nicht das meine Grafik die ich mit GDI+ gemacht habe halbwegs transparent wird und man das Spielfeld durscheinend sieht. Also die Gui soll zu 100 % transparent sein, damit die Grafik auch transparent ist. Nicht wundern, das wird nicht so bleiben, wird nur zum testen sein,weil ich nicht weiß wie groß das später wird, später wird es dann als PNG eingebunden.
Achja Script starten und dann die Pause-Taste drücken, dann kommt das Fenster bzw. die Grafik. Die zuständige Funktion dafür heißt _MenuShow ;).
Spoiler anzeigen
#include <Array.au3>
#include <GDIPlus.au3>
#include <GUIConstants.au3>
#include <Misc.au3>
#Include <WinAPI.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Global $aEnableForGo[4] ; [links, oben, rechts, unten]
Global $Timer[6], $Hold[4]
Global $iCountPoints = 0
Global $iGuiWidth = 600
Global $iGuiHeight = 600
Global $iX = 0
Global $iY = 0
Global $iAngleStart = 20
Global $iAngleEnd = 320
Global $piewidth = 0
Global $pieheight = 320
Global $aSquarePos[4]
Global $aBG[12][12] = [[1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1], _
[0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0], _
[0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], _
[1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1], _
[1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1], _
[1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0], _
[1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1], _
[1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1], _
[0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1], _
[1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], _
[1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1], _
[1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1]]
;~ Global $aBG[12][12] = [[1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], _
;~ [0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0], _
;~ [0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0], _
;~ [0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], _
;~ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _
;~ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _
;~ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _
;~ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _
;~ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _
;~ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _
;~ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], _
;~ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
Global $aPoints = $aBG
[/autoit] [autoit][/autoit] [autoit]HotKeySet("{PAUSE}", "_MenuShow")
[/autoit] [autoit][/autoit] [autoit]$hDLL = DllOpen("user32.dll")
[/autoit] [autoit][/autoit] [autoit]$hGui = GUICreate("PacMan made by m-obi", $iGuiWidth, $iGuiHeight)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetState()
_GDIPlus_Startup ()
[/autoit] [autoit][/autoit] [autoit]$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iGuiWidth, $iGuiHeight, $hGraphic)
$hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
$pac = _GDIPlus_BrushCreateSolid(0xFFFFFF00)
$Brush1 = _GDIPlus_BrushCreateSolid(0xFFEEEEEE)
$Brush2 = _GDIPlus_BrushCreateSolid(0xFF000000)
$Brush3 = _GDIPlus_BrushCreateSolid(0xFF636363)
$Brush_Red = _GDIPlus_BrushCreateSolid(0xFFFF0000)
$Brush_Green = _GDIPlus_BrushCreateSolid(0xFF00FF00)
_SquarePos()
_BG()
_DrawPoints()
AdlibRegister("_SquarePos", 50)
AdlibRegister("_AniPacMan", 400)
While 1
;~ If _IsPressed("13", $hDLL) Then
;~ While 1
;~ If Not _IsPressed("13", $hDLL) Then
;~ _Time("stop")
;~ _MenuShow()
;~ ExitLoop
;~ EndIf
;~ WEnd
;~ EndIf
;ConsoleWrite(@CRLF & TimerDiff($Timer[0]))
_CheckPoints()
If TimerDiff($Timer[1]) > 200 Then _Draw(1)
[/autoit] [autoit][/autoit] [autoit];ToolTip($aSquarePos[0] & @CRLF & $aSquarePos[1] & @CRLF & $aSquarePos[2] & @CRLF & $aSquarePos[3])
[/autoit] [autoit][/autoit] [autoit]If $aSquarePos[0] > 0.9 Then $aEnableForGo[0] = $aBG[Int($aSquarePos[1])][Int($aSquarePos[0]) - 1]
If $aSquarePos[1] > 0.9 Then $aEnableForGo[1] = $aBG[Int($aSquarePos[1]) - 1][Int($aSquarePos[0])]
If $aSquarePos[0] < 11 Then $aEnableForGo[2] = $aBG[Int($aSquarePos[1])][Int($aSquarePos[0]) + 1]
If $aSquarePos[1] < 11 Then $aEnableForGo[3] = $aBG[Int($aSquarePos[1]) + 1][Int($aSquarePos[0])]
_SquarePos()
[/autoit] [autoit][/autoit] [autoit]$aEnableForGo[0] = _Iif($aSquarePos[0] = 0.5 Or (Not $aEnableForGo[0] And StringRight($aSquarePos[0], 1) = 5), 0, 1)
$aEnableForGo[1] = _Iif($aSquarePos[1] = 0.5 Or (Not $aEnableForGo[1] And StringRight($aSquarePos[1], 1) = 5), 0, 1)
$aEnableForGo[2] = _Iif($aSquarePos[0] = 11.5 Or (Not $aEnableForGo[2] And StringRight($aSquarePos[0], 1) = 5), 0, 1)
$aEnableForGo[3] = _Iif($aSquarePos[1] = 11.5 Or (Not $aEnableForGo[3] And StringRight($aSquarePos[1], 1) = 5), 0, 1)
If Not _IsPressed("25", $hDLL) Then $Hold[0] = 0
If Not _IsPressed("26", $hDLL) Then $Hold[1] = 0
If Not _IsPressed("27", $hDLL) Then $Hold[2] = 0
If Not _IsPressed("28", $hDLL) Then $Hold[3] = 0
If StringRight($aSquarePos[0], 1) = 5 Then
Select
Case _IsPressed("26", $hDLL) And $aEnableForGo[1] ;oben
_Time("start")
If Not $Hold[1] Then $Timer[3] = TimerInit()
$Hold[1] = 1
$iAngleStart = 290
$iY -= 10
_Draw()
While _IsPressed("26", $hDLL) And TimerDiff($Timer[3]) < 300
Sleep(10)
WEnd
Case _IsPressed("28", $hDLL) And $aEnableForGo[3] ;unten
_Time("start")
If Not $Hold[3] Then $Timer[5] = TimerInit()
$Hold[3] = 1
$iAngleStart = 110
$iY += 10
_Draw()
While _IsPressed("28", $hDLL) And TimerDiff($Timer[5]) < 300
Sleep(10)
WEnd
EndSelect
EndIf
_SquarePos()
[/autoit] [autoit][/autoit] [autoit]If StringRight($aSquarePos[1], 1) = 5 Then
Select
Case _IsPressed("25", $hDLL) And $aEnableForGo[0] ;links
_Time("start")
If Not $Hold[0] Then $Timer[2] = TimerInit()
$Hold[0] = 1
$iAngleStart = 200
$iX -= 10
_Draw()
While _IsPressed("25", $hDLL) And TimerDiff($Timer[2]) < 300
Sleep(10)
WEnd
Case _IsPressed("27", $hDLL) And $aEnableForGo[2] ;rechts
_Time("start")
If Not $Hold[2] Then $Timer[4] = TimerInit()
$Hold[2] = 1
$iAngleStart = 20
$iX += 10
_Draw()
While _IsPressed("27", $hDLL) And TimerDiff($Timer[4]) < 300
Sleep(10)
WEnd
EndSelect
EndIf
WEnd
Func _Draw($iTyp = 0)
AdlibUnRegister("_SquarePos")
_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 0)
_GDIPlus_GraphicsFillRect($hBuffer, Int($aSquarePos[0]) * 50, Int($aSquarePos[1]) * 50, 50, 50, $Brush1)
_GDIPlus_GraphicsFillRect($hBuffer, Int($aSquarePos[2]) * 50, Int($aSquarePos[3]) * 50, 50, 50, $Brush1)
If StringRight($aSquarePos[0], 1) = 5 And StringRight($aSquarePos[1], 1) = 5 And $aPoints[Int($aSquarePos[1])][Int($aSquarePos[0])] Then
$aPoints[Int($aSquarePos[1])][Int($aSquarePos[0])] = 0
$iCountPoints -= 1
EndIf
_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
If $aPoints[Int($aSquarePos[1])][Int($aSquarePos[0])] Then _GDIPlus_GraphicsFillEllipse($hBuffer, Int($aSquarePos[0]) * 50 + 15, Int($aSquarePos[1]) * 50 + 15, 20, 20, $Brush3)
If $aPoints[Int($aSquarePos[3])][Int($aSquarePos[2])] Then _GDIPlus_GraphicsFillEllipse($hBuffer, Int($aSquarePos[2]) * 50 + 15, Int($aSquarePos[3]) * 50 + 15, 20, 20, $Brush3)
AdlibRegister("_SquarePos", 50)
While 1
Switch $iTyp
Case 0
$iTyp = _Iif(TimerDiff($Timer[1]) > 200, 1, 2)
Case 1
_GDIPlus_GraphicsFillPie($hBuffer, $iX + 2, $iY + 2, 46, 46, $iAngleStart, $iAngleEnd, $pac)
ExitLoop
Case 2
_GDIPlus_GraphicsFillPie($hBuffer, $iX + 2, $iY + 2, 46, 46, $iAngleStart - 15, $iAngleEnd + 30, $pac)
ExitLoop
EndSwitch
WEnd
_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 0)
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iGuiWidth, $iGuiHeight)
EndFunc
Func _DrawPoints()
_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
If StringRight($aSquarePos[0], 1) = 5 And StringRight($aSquarePos[1], 1) = 5 Then $aPoints[Int($aSquarePos[1])][Int($aSquarePos[0])] = 0
For $y = 0 To UBound($aPoints) - 1
For $x = 0 To UBound($aPoints, 2) - 1
If $aPoints[$y][$x] Then
_GDIPlus_GraphicsFillEllipse($hBuffer, $x * 50 + 15, $y * 50 + 15, 20, 20, $Brush3)
$iCountPoints += 1
EndIf
Next
Next
_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 0)
EndFunc
Func _AniPacMan()
_Draw(2)
$Timer[1] = TimerInit()
EndFunc
Func _BG()
_GDIPlus_GraphicsFillRect($hBuffer, 0, 0, 600, 600, $Brush2)
For $y = 0 To UBound($aBG) - 1
For $x = 0 To UBound($aBG, 2) - 1
If $aBG[$y][$x] Then _GDIPlus_GraphicsFillRect($hBuffer, $x * 50, $y * 50, 50, 50, $Brush1)
Next
Next
EndFunc
Func _SquarePos()
$aSquarePos[0] = ($iX / 50) + 0.5
$aSquarePos[1] = ($iY / 50) + 0.5
Select
Case StringRight($aSquarePos[0], 1) = 5 And StringRight($aSquarePos[1], 1) = 5
$aSquarePos[2] = $aSquarePos[0]
$aSquarePos[3] = $aSquarePos[1]
Case StringRight($aSquarePos[0], 1) < 5 And StringRight($aSquarePos[1], 1) = 5
$aSquarePos[2] = $aSquarePos[0] - 1
$aSquarePos[3] = $aSquarePos[1]
Case StringRight($aSquarePos[0], 1) = 5 And StringRight($aSquarePos[1], 1) < 5
$aSquarePos[2] = $aSquarePos[0]
$aSquarePos[3] = $aSquarePos[1] - 1
Case StringRight($aSquarePos[0], 1) > 5 And StringRight($aSquarePos[1], 1) = 5
$aSquarePos[2] = $aSquarePos[0] + 1
$aSquarePos[3] = $aSquarePos[1]
Case StringRight($aSquarePos[0], 1) = 5 And StringRight($aSquarePos[1], 1) > 5
$aSquarePos[2] = $aSquarePos[0]
$aSquarePos[3] = $aSquarePos[1] + 1
EndSelect
EndFunc
Func _CheckPoints()
If $iCountPoints = 0 Then
MsgBox(0, "Test", "Test")
EndIf
EndFunc
Func _Time($sCommand)
Local Static $iTime
Switch $sCommand
Case "start"
If $Timer[0] = "" Then $Timer[0] = TimerInit()
Case "stop"
If $Timer[0] <> "" Then
$iTime += TimerDiff($Timer[0])
$Timer[0] = ""
Return $iTime
EndIf
EndSwitch
EndFunc
Func _MenuShow()
_Time("stop")
HotKeySet("{PAUSE}")
Local $iWidth = 200
Local $iHeight = 300
Local $iRadius = 30
Local $iOffset = 3
GUISetState(@SW_DISABLE, $hGui)
Opt("GUIOnEventMode", 0)
$hGuiMenu = GUICreate("Menü", $iWidth + 6, $iHeight + 6, Default, Default, $WS_POPUP, Default, $hGui)
$hContinue = GUICtrlCreateButton("Weiter", 40, 40, 80, 25)
GUISetState()
$hGraphicMenu = _GDIPlus_GraphicsCreateFromHWND($hGuiMenu)
$hBitmapMenu = _GDIPlus_BitmapCreateFromGraphics($iWidth + 6, $iHeight + 6, $hGraphicMenu)
$hBufferMenu = _GDIPlus_ImageGetGraphicsContext($hBitmapMenu)
$Brush_BG = _GDIPlus_BrushCreateSolid(0xAAFFA500)
$Pen_BG_Line = _GDIPlus_PenCreate(0xFF000000, 3)
$Pen_BG_Arc = _GDIPlus_PenCreate(0xFF000000, 3)
_GDIPlus_GraphicsFillRect($hBufferMenu, $iOffset, $iRadius + $iOffset, $iRadius, $iHeight - $iRadius * 2, $Brush_BG)
_GDIPlus_GraphicsFillPie($hBufferMenu, $iOffset, $iOffset, $iRadius * 2, $iRadius * 2, 180, 90, $Brush_BG)
_GDIPlus_GraphicsFillRect($hBufferMenu, $iRadius + $iOffset, $iOffset, $iWidth - $iRadius * 2, $iRadius, $Brush_BG)
_GDIPlus_GraphicsFillPie($hBufferMenu, $iWidth - $iRadius * 2 + $iOffset, $iOffset, $iRadius * 2, $iRadius * 2, 270, 90, $Brush_BG)
_GDIPlus_GraphicsFillRect($hBufferMenu, $iWidth - $iRadius + $iOffset, $iRadius + $iOffset, $iRadius, $iHeight - $iRadius * 2, $Brush_BG)
_GDIPlus_GraphicsFillPie($hBufferMenu, $iWidth - $iRadius * 2 + $iOffset, $iHeight - $iRadius * 2 + $iOffset, $iRadius * 2, $iRadius * 2, 0, 90, $Brush_BG)
_GDIPlus_GraphicsFillRect($hBufferMenu, $iRadius + $iOffset, $iHeight - $iRadius + $iOffset, $iWidth - $iRadius * 2, $iRadius, $Brush_BG)
_GDIPlus_GraphicsFillPie($hBufferMenu, $iOffset, $iHeight - $iRadius * 2 + $iOffset, $iRadius * 2, $iRadius * 2, 90, 90, $Brush_BG)
_GDIPlus_GraphicsFillRect($hBufferMenu, $iRadius + $iOffset, $iRadius + $iOffset, $iWidth - $iRadius * 2, $iHeight - $iRadius * 2, $Brush_BG)
_GDIPlus_GraphicsSetSmoothingMode($hBufferMenu, 2)
_GDIPlus_GraphicsDrawLine($hBufferMenu, $iOffset, $iHeight - $iRadius + $iOffset, $iOffset, $iRadius + $iOffset, $Pen_BG_Line)
_GDIPlus_GraphicsDrawArc($hBufferMenu, $iOffset, $iOffset, $iRadius * 2, $iRadius * 2, 180, 90, $Pen_BG_Arc)
_GDIPlus_GraphicsDrawLine($hBufferMenu, $iRadius + $iOffset, $iOffset, $iWidth - $iRadius + $iOffset, $iOffset, $Pen_BG_Line)
_GDIPlus_GraphicsDrawArc($hBufferMenu, $iWidth - $iRadius * 2 + $iOffset, $iOffset, $iRadius * 2, $iRadius * 2, 270, 90, $Pen_BG_Arc)
_GDIPlus_GraphicsDrawLine($hBufferMenu, $iWidth + $iOffset, $iRadius + $iOffset, $iWidth + $iOffset, $iHeight - $iRadius + $iOffset, $Pen_BG_Line)
_GDIPlus_GraphicsDrawArc($hBufferMenu, $iWidth - $iRadius * 2 + $iOffset, $iHeight - $iRadius * 2 + $iOffset, $iRadius * 2, $iRadius * 2, 0, 90, $Pen_BG_Arc)
_GDIPlus_GraphicsDrawLine($hBufferMenu, $iRadius + $iOffset, $iHeight + $iOffset, $iWidth - $iRadius + $iOffset, $iHeight + $iOffset, $Pen_BG_Line)
_GDIPlus_GraphicsDrawArc($hBufferMenu, $iOffset, $iHeight - $iRadius * 2 + $iOffset, $iRadius * 2, $iRadius * 2, 90, 90, $Pen_BG_Arc)
_GDIPlus_GraphicsSetSmoothingMode($hBufferMenu, 0)
_GDIPlus_GraphicsDrawImageRect($hGraphicMenu, $hBitmapMenu, 0, 0, $iWidth + 6, $iHeight + 6)
While 1
Switch GUIGetMsg()
Case $hContinue
GUISetState(@SW_ENABLE, $hGui)
GUIDelete($hGuiMenu)
Opt("GUIOnEventMode", 1)
HotKeySet("{PAUSE}", "_MenuShow")
_Time("start")
Return
EndSwitch
WEnd
EndFunc
Func _Exit()
_GDIPlus_BrushDispose($pac)
_GDIPlus_BrushDispose($Brush1)
_GDIPlus_BrushDispose($Brush2)
_GDIPlus_BrushDispose($Brush3)
_GDIPlus_GraphicsDispose($hBuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
DllClose($hDLL)
Exit
EndFunc