Hey Leute
wie einige vielleicht schon gemerkt haben versuche ich gerade GDI+ zu lernen.
Ich wollte mal Snake nachprogrammieren, aber jetzt weiß ich nicht mehr weiter. Wie bekomme ich es hin, dass wenn die Schlange um die Ecke läuft, dass dann die Wurst nen knick bekommt?
Ja ich hab die SuFu nach Snake abgesucht aber alle GDI+ sachen waren mir einfach viel zu umfangreich und deshalb hab ich nix kapiert -.-
Spoiler anzeigen
#include <GuiConstants.au3>
#include <GDIPlus.au3>
#include <Misc.au3>
OnAutoItExitRegister("_EXIT")
[/autoit] [autoit][/autoit] [autoit]$x = 100
$y = 100
$score = 1
$width = 10
$kx = 300
$ky = 400
$direction = "down"
$Gui = GUICreate("Snake",500,500,100,100)
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup()
$brushSchwarz = _GDIPlus_BrushCreateSolid(0xFF000000)
$brushWeiss = _GDIPlus_BrushCreateSolid(0xFFFFFFFF)
$brushGruen = _GDIPlus_BrushCreateSolid(0xFF60CC3F)
$graphic = _GDIPlus_GraphicsCreateFromHWND($Gui)
$bitmap = _GDIPlus_BitmapCreateFromGraphics(500, 500, $graphic)
$buffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
GUISetState()
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Do
$msg = GUIGetMsg()
Select
Case _IsPressed(25) ;links
$direction = "left"
Case _IsPressed(26) ;oben
$direction = "up"
Case _IsPressed(27) ;rechts
$direction = "right"
Case _IsPressed(28) ;unten
$direction = "down"
EndSelect
If $direction == "left" And $x >= 0 Then $x -= 2
If $direction == "up" And $y >= 0 Then $y -= 2
If $direction == "right" And $x <= 500 Then $x += 2
If $direction == "down" And $y <= 500 Then $y += 2
_GDIPlus_GraphicsFillRect($buffer, 0, 0, 500, 500, $brushWeiss)
_GDIPlus_GraphicsFillRect($buffer, $x, $y, $width, 10, $brushSchwarz)
_GDIPlus_GraphicsFillRect($buffer, $kx, $ky, 10, 10, $brushGruen)
_GDIPlus_GraphicsDrawImageRect($graphic, $bitmap, 0, 0, 500, 500)
Select
Case $x >= ($kx - 5) And $x <= ($kx + 5) And $y >= ($ky - 5) And $y <= ($ky + 5)
$score += 1
$kx = Random(1,490,1)
$ky = Random(1,490,1)
$width += 10
EndSelect
Until $msg = $GUI_EVENT_CLOSE
[/autoit] [autoit][/autoit] [autoit]Func _EXIT()
_GDIPlus_Shutdown()
EndFunc