spiel

  • hallo ich komme in meinem spiel nicht weiter, habe auch schon gesucht aber nichts gefunden.
    also wennman einen button drückt soll ein neues fenster geöffnet werden wo steht ausbau zur nächsten stufe(für den anfang). nach dem klicken soll ein timer ablaufen(ca. 2 min), dann soll die überschrift des Button von z.b.: "stall" auf "stall stufe: 1" geändert werden. habe nur keine ahnung wie man das macht.
    hoffe ihr könnt helfen.

    [autoit]

    #include <GUIConstants.au3>

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

    #Region ### START Koda GUI section ### Form=Burgia.kxf\Burgia.kxf
    $Form1 = GUICreate("Form1", 625, 445, 193, 125)
    GUISetBkColor(0x00FF00)
    $Stall = GUICtrlCreateButton("Stall", 56, 48, 121, 89, 0)
    $Kaserne = GUICtrlCreateButton("Kaserne", 240, 48, 121, 89, 0)
    $Rathaus = GUICtrlCreateButton("Rathaus", 56, 208, 121, 89, 0)
    $Haus = GUICtrlCreateButton("Haus", 240, 208, 121, 89, 0)
    $Burg = GUICtrlCreateButton("Burg", 408, 104, 121, 121, 0)
    $Bauernhof = GUICtrlCreateButton("Bauernhof", 400, 312, 185, 121, 0)
    GUICtrlSetBkColor(-1, 0x808000)
    $Date1 = GUICtrlCreateDate("2009/05/09 09:32:2", 504, 8, 113, 33)
    $MonthCal1 = GUICtrlCreateMonthCal("2009/05/09", 392, 8, 97, 33)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    EndSwitch
    WEnd

    [/autoit]
  • im script zb. _start()

    und dann noch

    [autoit]

    Func _start()
    GUICreate("GUI",300,300)

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

    GUISETSTATE()

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

    While 1
    Switch GUIGetMsg()
    Case -3
    Exit
    EndSwitch
    WEnd
    EndFunc

    [/autoit]
  • Wiso aber du wolltest doch das dann ein neues Fenster geöfnet wird !!! Und das geht so

  • ja das mim fenster schon aber wie mache ich dass es sich bei klick auf einem, butten öffnet und das darein steht "ausbau zur nächsten stufe" und dann der timer abläuft?

  • Spoiler anzeigen
    [autoit]

    #include <GUIConstants.au3>

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

    #Region ### START Koda GUI section ### Form=Burgia.kxf\Burgia.kxf
    $Form1 = GUICreate("Form1", 625, 445, 193, 125)
    GUISetBkColor(0x00FF00)
    $Stall = GUICtrlCreateButton("Stall", 56, 48, 121, 89, 0)
    $Kaserne = GUICtrlCreateButton("Kaserne", 240, 48, 121, 89, 0)
    $Rathaus = GUICtrlCreateButton("Rathaus", 56, 208, 121, 89, 0)
    $Haus = GUICtrlCreateButton("Haus", 240, 208, 121, 89, 0)
    $Burg = GUICtrlCreateButton("Burg", 408, 104, 121, 121, 0)
    $Bauernhof = GUICtrlCreateButton("Bauernhof", 400, 312, 185, 121, 0)
    GUICtrlSetBkColor(-1, 0x808000)
    $Date1 = GUICtrlCreateDate("2009/05/09 09:32:2", 504, 8, 113, 33)
    $MonthCal1 = GUICtrlCreateMonthCal("2009/05/09", 392, 8, 97, 33)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Bauernhof
    _start()
    EndSwitch
    WEnd

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

    Func _start()
    $gui = GUICreate("GUI",300,300)

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

    GUISETSTATE()

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

    While 1
    Switch GUIGetMsg()
    Case -3
    GUISETSTATE(@SW_HIDE,$gui)
    Exitloop
    EndSwitch
    WEnd
    EndFunc

    [/autoit]
  • Hier schonmal dein Timer ->

    Spoiler anzeigen
    [autoit]

    _Timer_SetTimer($Form1, 1000, "_UpdateClock")
    Func _UpdateClock($hWnd, $Msg, $iIDTimer, $dwTime)
    $x += 1
    $sec = StringFormat("d\n",Mod($x, 60))
    $min = Int($x/60)
    GuiCtrlSetData($Label, "Zeit: " & $min & ":" & $sec)
    EndFunc

    [/autoit]

    Edit: Da Jam wohl nochn bisschen braucht, hab ich dir mal als Ansatz ne schnelle Version gemacht..

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <Timers.au3>
    ;~ #include <WindowsConstants.au3>

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

    opt("GuiOnEventMode",1)
    Dim $lvl[9] = [0,0,0,0,0,0,0,0,0]
    Global $x
    #Region ### START Koda GUI section ### Form=Burgia.kxf\Burgia.kxf
    $Form1 = GUICreate("Form1", 625, 445, 193, 125)
    GuiSetOnEvent($GUI_EVENT_CLOSE, "_Terminate",$Form1)
    GUISetBkColor(0x00FF00)
    $Stall = GUICtrlCreateButton("Stall", 56, 48, 121, 89, 0)
    GuiCtrlSetOnEvent(-1, "_start")
    $Kaserne = GUICtrlCreateButton("Kaserne", 240, 48, 121, 89, 0)
    GuiCtrlSetOnEvent(-1, "_start")
    $Rathaus = GUICtrlCreateButton("Rathaus", 56, 208, 121, 89, 0)
    GuiCtrlSetOnEvent(-1, "_start")
    $Haus = GUICtrlCreateButton("Haus", 240, 208, 121, 89, 0)
    GuiCtrlSetOnEvent(-1, "_start")
    $Burg = GUICtrlCreateButton("Burg", 408, 104, 121, 121, 0)
    GuiCtrlSetOnEvent(-1, "_start")
    $Bauernhof = GUICtrlCreateButton("Bauernhof", 400, 312, 185, 121, 0)
    GuiCtrlSetOnEvent(-1, "_start")
    GUICtrlSetBkColor(-1, 0x808000)
    $Date1 = GUICtrlCreateDate("2009/05/09 09:32:2", 504, 8, 113, 33)
    $MonthCal1 = GUICtrlCreateMonthCal("2009/05/09", 392, 8, 97, 33)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    sleep(100)
    WEnd

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

    Func _start()
    Global $label, $stufe,$gui,$Last_Id
    $gui = GUICreate("GUI",200,100)
    GuiSetOnEvent($GUI_EVENT_CLOSE, "_Terminate",$gui)
    $Last_Id =GuiCtrlRead(@GUI_CtrlId)
    $stufe = GuiCtrlCreateLabel("Stufe von "&$Last_Id&": "&$lvl[@Gui_CtrlId],10,10)
    $label = GuiCtrlCreateLabel("Zeit: 0:00",10,30,150,30)
    _Timer_SetTimer($Form1, 1000, "_UpdateClock")
    GUISETSTATE()
    EndFunc

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

    Func _UpdateClock($hWnd, $Msg, $iIDTimer, $dwTime)
    $x += 1
    $sec = StringFormat("%02d\n",Mod($x, 60))
    $min = Int($x/60)
    GuiCtrlSetData($Label, "Zeit: " & $min & ":" & $sec)
    If $min = 2 Then
    $lvl[@Gui_CtrlId] += 1
    GuiCtrlSetData($stufe,"Stufe von "&$Last_Id&": "&$lvl[@Gui_CtrlId])
    sleep(1500)
    $x = 0
    GuiDelete($gui)
    _Timer_KillAllTimers($gui)
    EndIf
    EndFunc

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

    Func _Terminate()
    _Timer_KillAllTimers($gui)
    Exit
    EndFunc

    [/autoit]

    3 Mal editiert, zuletzt von ChaosKeks (9. Mai 2009 um 11:22)

  • Jo, ich hab ein Bischen gebraucht, da ich noch was anderes machen musste voher! Und ich hab es gleich mit Array gemacht, damit es nicht so lang wird, wenn man es noch weiter ausbaut!
    Aber jetzt ist es fertig!

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <GUIConstantsEx.au3>
    Dim $Bau [6]
    #Region ### START Koda GUI section ### Form=Burgia.kxf\Burgia.kxf
    $Form1 = GUICreate("Form1", 625, 445, 193, 125)
    GUISetBkColor(0x00FF00)
    $Bau[0] = GUICtrlCreateButton("Stall", 56, 48, 121, 89, 0)
    $Bau[1] = GUICtrlCreateButton("Kaserne", 240, 48, 121, 89, 0)
    $Bau[2] = GUICtrlCreateButton("Rathaus", 56, 208, 121, 89, 0)
    $Bau[3] = GUICtrlCreateButton("Haus", 240, 208, 121, 89, 0)
    $Bau[4] = GUICtrlCreateButton("Burg", 408, 104, 121, 121, 0)
    $Bau[5] = GUICtrlCreateButton("Bauernhof", 400, 312, 185, 121, 0)
    GUICtrlSetBkColor(-1, 0x808000)
    $Date1 = GUICtrlCreateDate("2009/05/09 09:32:2", 504, 8, 113, 33)
    $MonthCal1 = GUICtrlCreateMonthCal("2009/05/09", 392, 8, 97, 33)

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

    $AusBau = GUICreate ("Ausbau",200,100,100,100,-1,-1,$Form1)
    $BauB = GUICtrlCreateButton ("",10,70,180,25)
    $Text = GUICtrlCreateLabel ("d",10,10,180,60)
    GUISwitch ($Form1)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    $BauArten = StringSplit ("Stall|Kaserne|Rathaus|Haus|Burg|Bauernhof","|")
    $BauZeiten = StringSplit ("2000|3000|1000|1000|5000|1500","|")
    $Stufen = StringSplit ("0|0|0|0|0|0","|")
    $Zahl = 0
    $Time = 0
    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1]
    Case $Form1
    Switch $nMsg[0]
    Case -3
    Exit
    EndSwitch
    For $1 = 0 To UBound ($Bau) -1
    If $nMsg[0] = $Bau[$1] Then
    If $Time = 0 Then
    _Bau($1+1)
    $Zahl = $1 +1
    Else
    MsgBox (16,"Error","Du kannst nur ein Gebäude auf einmal Ausbauen")
    EndIf
    EndIf
    Next
    Case $AusBau
    Switch $nMsg[0]
    Case -3
    GUISetState (@SW_HIDE,$AusBau)
    Case $BauB
    $Time = $BauZeiten[$Zahl]
    GUICtrlSetState ($BauB,$GUI_DISABLE)
    AdlibEnable ("_Bautime",1000)
    EndSwitch
    EndSwitch
    WEnd
    Func _Bau($Art)
    GUICtrlSetData ($Text,$BauArten[$Art] & " auf Stufe " & $Stufen[$Art] +1 & " ausbauen?")
    GUICtrlSetData ($BauB, $BauArten[$Art] & " Ausbauen")
    GUISetState (@SW_SHOW,$AusBau)
    EndFunc
    Func _Bautime()
    $Time -= 100
    GUICtrlSetData ($Text,"Noch " & $Time /100 & " sec bis zu Fertigstellung")
    If $Time = 0 Then
    GUISetState (@SW_HIDE,$AusBau)
    AdlibDisable ()
    $Stufen[$Zahl] += 1
    GUICtrlSetData ($Bau[$Zahl -1],$BauArten[$Zahl] & " (" & $Stufen[$Zahl] & ")")
    GUICtrlSetState ($BauB,$GUI_ENABLE)
    EndIf
    EndFunc

    [/autoit]

    mfg. Jam00