Hallo Leutz,
es geht wieder um mein Spiel. Unzwar wenn ich _GDIPlus_GraphicsSetSmoothingMode verwende mit dem Modus 2, kommen durch die Glättung immer diese Linien, wie kann ich die wieder wegmachen?
autoit.de/wcf/attachment/9313/
Script:
Spoiler anzeigen
#include <Array.au3>
#include <GDIPlus.au3>
#include <GUIConstants.au3>
#include <Misc.au3>
Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Global $aEnableForGo[4] ; [links, oben, rechts, unten]
Global $Timer[5], $Hold[4]
Global $iWidth = 600
Global $iHeight = 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 $aPoints = $aBG
[/autoit] [autoit][/autoit] [autoit]$hDLL = DllOpen("user32.dll")
[/autoit] [autoit][/autoit] [autoit]$hGui = GUICreate("PacMan made by m-obi", $iWidth, $iHeight)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetState()
_GDIPlus_Startup ()
[/autoit] [autoit][/autoit] [autoit]$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphic)
$hBuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hBuffer, 2)
$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 TimerDiff($Timer[0]) > 200 Then _Draw(1)
;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
If Not $Hold[1] Then $Timer[2] = TimerInit()
$Hold[1] = 1
$iAngleStart = 290
$iY -= 10
_Draw()
While _IsPressed("26", $hDLL) And TimerDiff($Timer[2]) < 300
Sleep(10)
WEnd
Case _IsPressed("28", $hDLL) And $aEnableForGo[3] ;unten
If Not $Hold[3] Then $Timer[4] = TimerInit()
$Hold[3] = 1
$iAngleStart = 110
$iY += 10
_Draw()
While _IsPressed("28", $hDLL) And TimerDiff($Timer[4]) < 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
If Not $Hold[0] Then $Timer[1] = TimerInit()
$Hold[0] = 1
$iAngleStart = 200
$iX -= 10
_Draw()
While _IsPressed("25", $hDLL) And TimerDiff($Timer[1]) < 300
Sleep(10)
WEnd
Case _IsPressed("27", $hDLL) And $aEnableForGo[2] ;rechts
If Not $Hold[2] Then $Timer[3] = TimerInit()
$Hold[2] = 1
$iAngleStart = 20
$iX += 10
_Draw()
While _IsPressed("27", $hDLL) And TimerDiff($Timer[3]) < 300
Sleep(10)
WEnd
EndSelect
EndIf
WEnd
Func _Draw($iTyp = 0)
AdlibUnRegister("_SquarePos")
_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 Then $aPoints[Int($aSquarePos[1])][Int($aSquarePos[0])] = 0
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[0]) > 200, 1, 2)
Case 1
_GDIPlus_GraphicsFillPie($hBuffer, $iX, $iY, 50, 50, $iAngleStart, $iAngleEnd, $pac)
ExitLoop
Case 2
_GDIPlus_GraphicsFillPie($hBuffer, $iX, $iY, 50, 50, $iAngleStart - 15, $iAngleEnd + 30, $pac)
ExitLoop
EndSwitch
WEnd
_GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iWidth, $iHeight)
EndFunc
Func _DrawPoints()
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)
Next
Next
EndFunc
Func _AniPacMan()
_Draw(2)
$Timer[0] = 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 _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