Brauche Hilfe Bei Spiel (GDI+ und Variablen neu berechnung)

  • Hi@all,

    ich hab ein Problem, hört sich doof an oder?^^, ich bin grad dabei ein Spiel zu proggen, naja was heist spiel egal.
    undzwar also als erstes kann man mit so nem zelda typ (auch link genannt^^) auf ner wiese laufen
    da liegt mein erstes problem das mit der wiese und dem rumlaufen hab ich gecheckt aber wie krieg ich s hin wenn ich mit dem männchen iwo rauf (bestimmtes feld) komme das sich dann das kampf fenster öffnet?
    und dann wenn das kampf fenster offen ist hat man 3 angriffe und 1 heiler da liegt das zweite problem wie krieg ichs hin das die Lebenspunkte variable "neu berechnet" wird also wenn jetzt die pfeil nachoben taste gedrückt wird ist zb ein angriff der 5 zieht das dann die LP variable "neu berechnet" wird also 100-5 = 95 und das dann angezeigt wird und das wenn jemand bei 0 ist das dann gesagt wird gewonnen/verloren
    hier die unvollständigen skripte:
    wiese:

    Spoiler anzeigen
    [autoit]

    #include <GuiConstants.au3>
    #include <GdiPlus.au3>;das include
    #include <Misc.au3>

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

    OnAutoItExitRegister("_end") ; die Funktion _end am Ende des Scriptes ausführen

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

    $x = 0;x und y deklarieren
    $y = 0

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

    $Gui = GUICreate("Zelpa", 579, 563, 100, 100)
    GUISetState(@SW_SHOW)

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

    _GDIPlus_Startup() ;Gdi starten

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

    $figur = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\figur.gif")
    $bk = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\bg.jpg")
    $height = _GDIPlus_ImageGetHeight($figur)
    $width = _GDIPlus_ImageGetWidth($figur)
    $verhaelnis = $height / $width
    $graphic = _GDIPlus_GraphicsCreateFromHWND($Gui)
    $bitmap = _GDIPlus_BitmapCreateFromGraphics(579, 563, $graphic);----------------- geändert ----------------------
    $buffer = _GDIPlus_ImageGetGraphicsContext($bitmap);----------------- geändert ----------------------

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

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    Select
    Case _IsPressed(25)
    $x -= 3
    Case _IsPressed(26)
    $y -= 3
    Case _IsPressed(27)
    $x += 3
    Case _IsPressed(28)
    $y += 3
    EndSelect

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

    _GDIPlus_GraphicsDrawImageRect($buffer, $bk, 0, 0, 579, 563);----------------- geändert ----------------------
    _GDIPlus_GraphicsDrawImageRect($buffer, $figur, $x, $y, 50, 50 * $verhaelnis);----------------- geändert ----------------------
    _GDIPlus_GraphicsDrawImage($graphic, $bitmap, 0, 0);----------------- geändert ----------------------
    Sleep(3)

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

    WEnd

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

    Func _end();die Exit funktion
    _GDIPlus_GraphicsDispose($graphic);Grafik Objekt freigeben
    _GDIPlus_GraphicsDispose($buffer);----------------- geändert ----------------------
    _GDIPlus_BitmapDispose($bitmap);----------------- geändert ----------------------
    _GDIPlus_ImageDispose($figur);Bild Objekt 1 freigeben
    _GDIPlus_ImageDispose($bk);Bild Objekt 2 freigeben
    _GDIPlus_Shutdown();Ressourcen freigeben
    EndFunc ;==>_end

    [/autoit]

    kampf:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <GuiStatusBar.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>
    #include <GdiPlus.au3>
    $x = 100
    $y = 100
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Kampf", 614, 449, 192, 150)
    $Label1 = GUICtrlCreateLabel($x, 32, 16, 58, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Arial Narrow")
    $Label2 = GUICtrlCreateLabel($y, 488, 264, 58, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Arial Narrow")
    $Pic1 = GUICtrlCreatePic("C:\Users\Bormeister\programmierne\au3\game\images.jpg", 48, 208, 148, 212, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Pic2 = GUICtrlCreatePic("C:\Users\Bormeister\programmierne\au3\game\mo.jpg", 424, 10, 164, 196, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    $Label3 = GUICtrlCreateLabel("Pfeil nach oben: Schlag 15-mal verfügbar 4 Schaden", 280, 320, 278, 17)
    $Label4 = GUICtrlCreateLabel("Pfeil nach links: Tritt 10-mal verfügbar 5 Schaden", 280, 351, 281, 17)
    $Label5 = GUICtrlCreateLabel("Pfeil nach rechts: Heilen 2-mal verfügbar 5 Plus", 280, 367, 257, 17)
    $Label6 = GUICtrlCreateLabel("Pfeil nach unten: Schwert 5-mal verfügbar 10 Schaden", 280, 335, 284, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch

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

    Select
    Case _IsPressed(25) ;links
    $y -= 5
    Case _IsPressed(26) ;oben
    $y -= 4
    Case _IsPressed(27) ;rechts
    $x += 5
    Case _IsPressed(28) ;unten
    $y -= 10
    EndSelect
    WEnd

    [/autoit]


    MFG tomtomone96

    Einmal editiert, zuletzt von tomtomone96 (24. September 2010 um 15:32)

  • [autoit]


    If _isPressed(26) Then

    $neuelebenspunkte -= 5

    Guictrlsetdata ($deinlabel, $neuelebenspunkte)
    endif

    [/autoit]


    war nur auf die schnelle^^

    Du soltest dann die While schleife länger setzen das z.b. 500 msek schleifen sind und die sperre das man nur 10 mal oder 5 mal was machen kann
    Wenn möglich auch mal die Bilder^^


    So ein wenig mehr Zeit ^^:

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>
    #include <GuiStatusBar.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Misc.au3>
    #include <GdiPlus.au3>
    $x = 100
    $y = 100
    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Kampf", 614, 449, 192, 150)
    $Label1 = GUICtrlCreateLabel($x, 32, 16, 58, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Arial Narrow")
    $Label2 = GUICtrlCreateLabel($y, 488, 264, 58, 29)
    GUICtrlSetFont(-1, 16, 400, 0, "Arial Narrow")
    $Pic1 = GUICtrlCreatePic("C:\Users\Bormeister\programmierne\au3\game\images.jpg", 48, 208, 148, 212, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
    $Pic2 = GUICtrlCreatePic("C:\Users\Bormeister\programmierne\au3\game\mo.jpg", 424, 10, 164, 196, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
    $Label3 = GUICtrlCreateLabel("Pfeil nach oben: Schlag 15-mal verfügbar4 Schaden", 280, 320, 278, 17)
    $Label4 = GUICtrlCreateLabel("Pfeil nach links: Tritt 10-mal verfügbar5 Schaden", 280, 351, 281, 17)
    $Label5 = GUICtrlCreateLabel("Pfeil nach rechts: Heilen 2-mal verfügbar 5 Plus", 280, 367, 257, 17)
    $Label6 = GUICtrlCreateLabel("Pfeil nach unten: Schwert5-mal verfügbar 10 Schaden", 280, 335, 284, 17)
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch

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

    Select
    Case _IsPressed(25) ;links

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

    $y -= 5
    GUICtrlSetData($Label2, $y)
    Sleep(500)

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

    Case _IsPressed(26) ;oben
    $y -= 4
    GUICtrlSetData($Label2, $y)
    Sleep(500)
    Case _IsPressed(27) ;rechts
    $x += 5
    GUICtrlSetData($Label1, $x)
    Sleep(500)
    Case _IsPressed(28) ;unten
    $y -= 10
    GUICtrlSetData($Label2, $y)
    Sleep(500)
    EndSelect
    WEnd

    [/autoit]


    das mit der sperre (also nur 5mal und so) kannst du selber einbauen^^

  • Hi BadBunny
    ok thx das funzt ja soweit hast du zufällig auch ne lösung für das andere problem??

  • Frag einfach immer ab wenn die figur die x und y werte deines gegner haben dann Kampf

  • Ok thx habs hinggekriegt code ist jetzt falls das jemanden interresiert:

    [autoit]

    #include <GuiConstants.au3>
    #include <GdiPlus.au3>;das include
    #include <Misc.au3>

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

    OnAutoItExitRegister("_end") ; die Funktion _end am Ende des Scriptes ausführen
    $LV=IniRead(@ScriptDir & "LV.ini", "EP", "2", "1")
    $NM=IniRead(@ScriptDir & "LV.ini", "EP", "3", "Link")
    $x = 0;x und y deklarieren
    $y = 0

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

    $m1=Random(0,579, 1)
    $m2=Random(0,563, 1)
    $m3=Random(0,579, 1)
    $m4=Random(0,563, 1)

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

    $Gui = GUICreate("Zelpa", 579, 563, 100, 100)
    GUISetState(@SW_SHOW)
    _GDIPlus_Startup() ;Gdi starten
    $figur = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\figur.gif")
    $bk = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\bg.jpg")
    $point = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\p.jpg")
    $height = _GDIPlus_ImageGetHeight($figur)
    $width = _GDIPlus_ImageGetWidth($figur)
    $verhaelnis = $height / $width
    $graphic = _GDIPlus_GraphicsCreateFromHWND($Gui)
    $bitmap = _GDIPlus_BitmapCreateFromGraphics(579, 563, $graphic);----------------- geändert ----------------------
    $buffer = _GDIPlus_ImageGetGraphicsContext($bitmap);----------------- geändert ----------------------

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

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    Select
    Case _IsPressed(25)
    $x -= 3
    Case _IsPressed(26)
    $y -= 3
    Case _IsPressed(27)
    $x += 3
    Case _IsPressed(28)
    $y += 3
    EndSelect
    _GDIPlus_GraphicsDrawImage($graphic, $point, $m1, $m2)
    _GDIPlus_GraphicsDrawImage($graphic, $point, $m3, $m4)
    _GDIPlus_GraphicsDrawImageRect($buffer, $bk, 0, 0, 579, 563);----------------- geändert ----------------------
    _GDIPlus_GraphicsDrawImageRect($buffer, $figur, $x, $y, 25, 25 * $verhaelnis);----------------- geändert ----------------------
    _GDIPlus_GraphicsDrawImage($graphic, $bitmap, 0, 0);----------------- geändert ----------------------
    Sleep(3)
    If $x=$m1 or $x=$m1 +1 or $x=$m1 +2 or $x=$m1 +3 or $x=$m1 +4 or $x=$m1 +5 or $x=$m1 -1 or $x=$m1 -2 or $x=$m1 -3 or $x=$m1 -4 or $x=$m1 -5 Then
    IF $y=$m2 or $y=$m2 +1 or $y=$m2 +2 or $y=$m2 +3 or $y=$m2 +4 or $y=$m2 +5 or $y=$m2 -1 or $y=$m2 -2 or $y=$m2 -3 or $y=$m2 -4 or $y=$m2 -5 Then
    run("kampf.exe")
    Exit
    Else
    EndIf
    ElseIf $x=$m3 or $x=$m3 +1 or $x=$m3 +2 or $x=$m3 +3 or $x=$m3 +4 or $x=$m3 +5 or $x=$m3 -1 or $x=$m3 -2 or $x=$m3 -3 or $x=$m3 -4 or $x=$m3 -5 Then
    IF $y=$m4 or $y=$m4 +1 or $y=$m4 +2 or $y=$m4 +3 or $y=$m4 +4 or $y=$m4 +5 or $y=$m4 -1 or $y=$m4 -2 or $y=$m4 -3 or $y=$m4 -4 or $y=$m4 -5 Then
    run("kampf.exe")
    Exit
    Else
    EndIf
    EndIf
    WEnd

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

    Func _end();die Exit funktion
    _GDIPlus_GraphicsDispose($graphic);Grafik Objekt freigeben
    _GDIPlus_GraphicsDispose($buffer);----------------- geändert ----------------------
    _GDIPlus_BitmapDispose($bitmap);----------------- geändert ----------------------
    _GDIPlus_ImageDispose($figur);Bild Objekt 1 freigeben
    _GDIPlus_ImageDispose($bk);Bild Objekt 2 freigeben
    _GDIPlus_ImageDispose($point);Bild Objekt 2 freigeben
    _GDIPlus_Shutdown();Ressourcen freigeben
    EndFunc ;==>_end

    [/autoit]

    :rock: :rock:

    2 Mal editiert, zuletzt von tomtomone96 (23. September 2010 um 20:31)

  • ne ich will das spiel noch erweitern und dann findestes im skripte beriech name zelpa ich kann dir ja dann mal ne pn schreiben :)