Kleines Game (kleinste zahl finden) unbekannter fehler

  • Hallo,

    hab mir aus langeweile ein kleines game gestaltet. es wird noch ausgebaut aber es funtioniert schon mal relativ gut. es startet immer wieder von vorn wenn man die kleinste zahl gefunden hat. jedoch immer beim 4 mal kann man keine zahlen mehr ancklicken.
    ich vermute mal das spiel ist überlastet. wohlmöglich mit meiner while-schleife die noch eine for-next schleife enthält.. aber ich weiß nicht wie ichs sonst machen soll O.o
    vllt hat ja jemand verbesserungsvorschläge für mich.
    game ist im anhang

    screenshoot:
    [Blockierte Grafik: http://img847.imageshack.us/img847/8393/image1un.jpg]

    vlg Inferior

  • Der Fehler ist weg!

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEX.au3>
    #include <StaticConstants.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #Include <Array.au3>

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

    Dim $circle[10]
    Dim $number[10]
    Dim $controll[1]
    Dim $number_array[1]
    Dim $pos[35][2] = _
    [ _
    [20, 70], _
    [90, 70], _
    [160, 70], _
    [230, 70], _
    [300, 70], _
    [370, 70], _
    [440, 70], _
    [20, 140], _
    [90, 140], _
    [160, 140], _
    [230, 140], _
    [300, 140], _
    [370, 140], _
    [440, 140], _
    [20, 210], _
    [90, 210], _
    [160, 210], _
    [230, 210], _
    [300, 210], _
    [370, 210], _
    [440, 210], _
    [20, 280], _
    [90, 280], _
    [160, 280], _
    [230, 280], _
    [300, 280], _
    [370, 280], _
    [440, 280], _
    [20, 350], _
    [90, 350], _
    [160, 350], _
    [230, 350], _
    [300, 350], _
    [370, 350], _
    [440, 350] _
    ]

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

    $begin = TimerInit()

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

    $Main = GUICreate("NumberGame", 520, 450)
    GUISetBkColor(0x009FC6)

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

    GUICtrlCreateInput("", 0, 0, 520, 45, BitOR($ES_CENTER,$ES_READONLY))
    GUICtrlSetFont(-1, 27)
    GUICtrlSetData(-1, "Wähle die kleinste Zahl")
    GUICtrlSetState(-1, $GUI_DISABLE)

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

    Game()

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

    _ArrayDelete($number_array, 0)
    $min_number = _ArrayMin($number_array, 1)
    $max_number = _ArrayMax($number_array, 1)

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

    GUISetState()

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

    While 1
    $Main = GUIGetMsg()
    For $i = 0 To 9
    Switch $Main
    Case $GUI_EVENT_CLOSE
    Exit
    Case $circle[$i]
    If GUICtrlRead($number[$i]) = $min_number Then
    MsgBox(0, "NumberGame - Richtig", "Das ist richtig!" & @CRLF & "Die kleinste Zahl lautet " & GUICtrlRead($number[$i]) & "." & @CRLF & @CRLF & "Zeit: " & Round(TimerDiff($begin))/1000 & " Sekunden")
    ReDim $controll[1] ;Ohne das Redim, wird die Anzahl der Arrayelemente viel zu groß!
    Game()
    Else
    MsgBox(0, "NumberGame - Falsch", "Das ist falsch!" & @CRLF & "Die Zahl " & GUICtrlRead($number[$i]) & " ist nicht die kleinste Zahl.")
    EndIf
    EndSwitch
    Next
    WEnd

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

    Func Game()

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

    $begin = TimerInit()
    Dim $number_array[1]

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

    For $i = 0 To 9

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

    GUICtrlDelete($circle[$i])
    GUICtrlDelete($number[$i])

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

    $random_white = Random(0, 34, 1)
    $random_high = Random(0, 34, 1)

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

    While 1
    ConsoleWrite("X "&$i&@CRLF)
    If _ArrayFindAll($controll, $pos[$random_white][0] & $pos[$random_high][1]) <> -1 then
    $random_white = Random(0, 34, 1)
    $random_high = Random(0, 34, 1)
    Else
    ExitLoop
    EndIf
    WEnd

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

    $circle[$i] = GUICtrlCreateIcon("files\circle.ico", "circle.ico", $pos[$random_white][0], $pos[$random_high][1], 60, 60)
    $number[$i] = GUICtrlCreateLabel(Random(1, 99, 1), $pos[$random_white][0]+20, $pos[$random_high][1]+20, 20, 18, $SS_CENTER)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetFont(-1, 12, 600)

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

    _ArrayAdd($controll, $pos[$random_white][0] & $pos[$random_high][1])
    _ArrayAdd($number_array, GUICtrlRead($number[$i]))
    Next

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

    _ArrayDelete($number_array, 0)
    $min_number = _ArrayMin($number_array, 1)
    $max_number = _ArrayMax($number_array, 1)

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

    GUISetState()
    EndFunc

    [/autoit]
  • hallo,

    vielen dank TheShadowAE! funktioniert prächtig. hab mittlerweile ein punktesystem eingebaut und versuch jetzt einen random wächsel zwischen kleinster zahl/größter/zahl/was mir noch einfällt ;)
    vllt brauch ich ja nochmal eure hilfe

    lg Inferior

  • Hi Inferior,
    ich hab grad mal das Spiel getestet und einen Bug gefunden.
    Ich weiß, das Thema ist hier eigentlich gelöst, wollte nur mal bemerken, vielleicht ist es ja hilfreich für dich.
    Hab die verbesserte Version von TheShadowAE getestet, gleich in der ersten Runde folgende Situation:
    [Blockierte Grafik: http://img31.imageshack.us/img31/556/showexg.jpg]
    Ich habe auf 19 geklickt, augenscheinlich auch die kleinste Zahl - jedoch kommt die Meldung, das dies falsch sei.
    Vielleicht kannst du dir das ja mal ansehen.

  • hi stayawayknight,

    vielen dank für deine antwort. ja die eigendliche frage meinerseits ist geklärt jedoch würd ich an dem spiel noch ein wenig weiter arbeiten wollen. das selbe wie dir ist mir auch passiert mit der zahl eins (die offensichtlich die kleinste zahl war)
    jedoch weiß ich noch nicht woran das liegt.. jemand eine idee?

    hast du mal versucht andere zahlen anzuklicken? waren alle zahlen die "falsche" lösung?

    mfg Inferior

    EDIT:

    hab mein script mal erweitert und ein punktesystem hinzugefügt. über die punktevergabe lässt sich noch streiten aber meine frage ist wie kann ich jetzt den start und stop-button am besten einbinden?

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEX.au3>
    #include <StaticConstants.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #Include <Array.au3>

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

    Dim $circle[10]
    Dim $number[10]
    Dim $controll[1]
    Dim $game = 0
    Dim $number_array[1]
    Dim $pos[35][2] = _
    [ _
    [20, 70], _
    [90, 70], _
    [160, 70], _
    [230, 70], _
    [300, 70], _
    [370, 70], _
    [440, 70], _
    [20, 140], _
    [90, 140], _
    [160, 140], _
    [230, 140], _
    [300, 140], _
    [370, 140], _
    [440, 140], _
    [20, 210], _
    [90, 210], _
    [160, 210], _
    [230, 210], _
    [300, 210], _
    [370, 210], _
    [440, 210], _
    [20, 280], _
    [90, 280], _
    [160, 280], _
    [230, 280], _
    [300, 280], _
    [370, 280], _
    [440, 280], _
    [20, 350], _
    [90, 350], _
    [160, 350], _
    [230, 350], _
    [300, 350], _
    [370, 350], _
    [440, 350] _
    ]

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

    Dim $mode[2][1] = _
    [ _
    ["Wähle die kleinste Zahl"], _
    ["Wähle die größte Zahl"] _
    ]

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

    $begin = TimerInit()

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

    $Main = GUICreate("Game", 520, 470)

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

    GUISetBkColor(0x009FC6)

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

    GUICtrlCreateLabel("", 0, 430, 520, 40)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetState(-1, $GUI_DISABLE)

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

    $mode_random = Random(0, 1, 1)
    GUICtrlCreateInput("", 0, 0, 520, 45, BitOR($ES_CENTER,$ES_READONLY))
    GUICtrlSetFont(-1, 27)
    ;GUICtrlSetData(-1, $mode[$mode_random][0]) für verschiedene spielarten
    GUICtrlSetData(-1, $mode[0][0]) ;kleinste zahl
    GUICtrlSetState(-1, $GUI_DISABLE)

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

    $score = GUICtrlCreateLabel("0", 259, 432, 50, 18, $SS_RIGHT)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetColor(-1, 0xFE0000)
    GUICtrlSetFont(-1, 10, 600)
    GUICtrlCreateLabel("Punkte", 313, 432, 55, 18)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetColor(-1, 0xFE0000)
    GUICtrlSetFont(-1, 10, 600)

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

    $game_label = GUICtrlCreateLabel($game & " Runde", 279, 451, 80, 20, $SS_RIGHT)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetColor(-1, 0xFE0000)
    GUICtrlSetFont(-1, 10, 600)

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

    GUICtrlCreateLabel("letzte Punktzahl", 158, 435, 91, 12)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetColor(-1, 0xFE0000)
    GUICtrlSetFont(-1, 8, 600)

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

    $last_score = GUICtrlCreateLabel("0", 158, 450, 91, 16, $ES_CENTER)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetColor(-1, 0xFE0000)
    GUICtrlSetFont(-1, 10, 600)

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

    $start = GUICtrlCreateButton("Start", 367, 433, 150, 35)
    GUICtrlSetFont(-1, 16)
    $stopp = GUICtrlCreateButton("Stopp", 3, 433, 150, 35)
    GUICtrlSetFont(-1, 16)

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

    CreateNumbers()

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

    _ArrayDelete($number_array, 0)
    $min_number = _ArrayMin($number_array, 1)
    $max_number = _ArrayMax($number_array, 1)

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

    GUISetState()

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

    While 1
    $Main = GUIGetMsg()
    For $i = 0 To 9
    Switch $Main
    Case $GUI_EVENT_CLOSE
    Exit
    Case $circle[$i]
    If GUICtrlRead($number[$i]) = $min_number Then

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

    $time = Round(TimerDiff($begin))/1000

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

    MsgBox(0, "Game - Richtig", "Das ist richtig!" & @CRLF & "Die kleinste Zahl lautet " & GUICtrlRead($number[$i]) & "." & @CRLF & @CRLF & "Zeit: " & $time & " Sekunden")

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

    If $time < 0.5 Then
    GUICtrlSetData($score, GUICtrlRead($score) +1500)
    GUICtrlSetData($last_score, 1500)
    ElseIf $time < 1 Then
    GUICtrlSetData($score, GUICtrlRead($score) +1000)
    GUICtrlSetData($last_score, 1000)
    ElseIf $time < 1.5 Then
    GUICtrlSetData($score, GUICtrlRead($score) +800)
    GUICtrlSetData($last_score, 800)
    ElseIf $time < 2 Then
    GUICtrlSetData($score, GUICtrlRead($score) +600)
    GUICtrlSetData($last_score, 600)
    ElseIf $time < 2.5 Then
    GUICtrlSetData($score, GUICtrlRead($score) +400)
    GUICtrlSetData($last_score, 400)
    ElseIf $time < 3 Then
    GUICtrlSetData($score, GUICtrlRead($score) +200)
    GUICtrlSetData($last_score, 200)
    EndIf

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

    ReDim $controll[1]
    CreateNumbers()
    Else
    MsgBox(0, "Game - Falsch", "Das ist falsch!" & @CRLF & "Die Zahl " & GUICtrlRead($number[$i]) & " ist nicht die kleinste Zahl.")
    GUICtrlSetData($score, GUICtrlRead($score) -1000)
    EndIf
    EndSwitch
    Next
    WEnd

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

    Func CreateNumbers()

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

    $game = $game+1
    GUICtrlSetData($game_label, $game & " Runde")

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

    $begin = TimerInit()
    Dim $number_array[1]

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

    For $i = 0 To 9

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

    GUICtrlDelete($circle[$i])
    GUICtrlDelete($number[$i])

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

    $random_white = Random(0, 34, 1)
    $random_high = Random(0, 34, 1)

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

    While 1
    If _ArrayFindAll($controll, $pos[$random_white][0] & $pos[$random_high][1]) <> -1 then
    $random_white = Random(0, 34, 1)
    $random_high = Random(0, 34, 1)
    Else
    ExitLoop
    EndIf
    WEnd

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

    $circle[$i] = GUICtrlCreateIcon("files\circle.ico", "circle.ico", $pos[$random_white][0], $pos[$random_high][1], 60, 60)
    $number[$i] = GUICtrlCreateLabel(Random(1, 99, 1), $pos[$random_white][0]+20, $pos[$random_high][1]+20, 20, 18, $SS_CENTER)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetFont(-1, 12, 600)

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

    _ArrayAdd($controll, $pos[$random_white][0] & $pos[$random_high][1])
    _ArrayAdd($number_array, GUICtrlRead($number[$i]))
    Next

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

    _ArrayDelete($number_array, 0)
    $min_number = _ArrayMin($number_array, 1)
    $max_number = _ArrayMax($number_array, 1)

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

    GUISetState()
    EndFunc

    [/autoit]

    2 Mal editiert, zuletzt von Inferior (27. Mai 2011 um 18:15)

  • So neuste Version:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEX.au3>
    #include <StaticConstants.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #Include <Array.au3>

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

    Dim $circle[10]
    Dim $number[10]
    Dim $controll[1]
    Dim $game = 0
    Dim $mode_random
    Dim $number_array[1]
    Dim $pos[35][2] = _
    [ _
    [20, 70], _
    [90, 70], _
    [160, 70], _
    [230, 70], _
    [300, 70], _
    [370, 70], _
    [440, 70], _
    [20, 140], _
    [90, 140], _
    [160, 140], _
    [230, 140], _
    [300, 140], _
    [370, 140], _
    [440, 140], _
    [20, 210], _
    [90, 210], _
    [160, 210], _
    [230, 210], _
    [300, 210], _
    [370, 210], _
    [440, 210], _
    [20, 280], _
    [90, 280], _
    [160, 280], _
    [230, 280], _
    [300, 280], _
    [370, 280], _
    [440, 280], _
    [20, 350], _
    [90, 350], _
    [160, 350], _
    [230, 350], _
    [300, 350], _
    [370, 350], _
    [440, 350] _
    ]

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

    Dim $mode[10][1] = _
    [ _
    ["Wähle die kleinste Zahl"], _
    ["Wähle die größte Zahl"], _
    ["15-5=?"], _
    ["7*7=?"], _
    ["80-13=?"], _
    ["30+69=?"], _
    ["50+39=?"], _
    ["13+55=?"], _
    ["52-49=?"], _
    ["24+37=?"] _
    ]

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

    $begin = TimerInit()

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

    $Main = GUICreate("Game", 520, 470)

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

    GUISetBkColor(0x009FC6)

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

    GUICtrlCreateLabel("", 0, 430, 520, 40)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $question = GUICtrlCreateInput("", 0, 0, 520, 45, BitOR($ES_CENTER,$ES_READONLY))
    GUICtrlSetFont(-1, 27)
    GUICtrlSetState(-1, $GUI_DISABLE)

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

    $score = GUICtrlCreateLabel("0", 257, 432, 50, 18, $SS_RIGHT)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetColor(-1, 0xFE0000)
    GUICtrlSetFont(-1, 10, 600)
    GUICtrlCreateLabel("Punkte", 314, 432, 55, 18)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetColor(-1, 0xFE0000)
    GUICtrlSetFont(-1, 10, 600)

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

    $game_label = GUICtrlCreateLabel($game & ". Runde", 280, 451, 80, 20, $SS_RIGHT)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetColor(-1, 0xFE0000)
    GUICtrlSetFont(-1, 10, 600)

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

    GUICtrlCreateLabel("letzte Punktzahl", 158, 435, 91, 12)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetColor(-1, 0xFE0000)
    GUICtrlSetFont(-1, 8, 600)

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

    $last_score = GUICtrlCreateLabel("0", 158, 450, 91, 16, $ES_CENTER)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetColor(-1, 0xFE0000)
    GUICtrlSetFont(-1, 10, 600)

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

    $start = GUICtrlCreateButton("Start", 367, 433, 150, 35)
    GUICtrlSetFont(-1, 16)
    $stopp = GUICtrlCreateButton("Stopp", 3, 433, 150, 35)
    GUICtrlSetFont(-1, 16)

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

    CreateNumbers()

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

    _ArrayDelete($number_array, 0)
    $min_number = _ArrayMin($number_array, 1)
    $max_number = _ArrayMax($number_array, 1)

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

    GUISetState()

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

    While 1
    $Main = GUIGetMsg()
    For $i = 0 To 9
    Switch $Main
    Case $GUI_EVENT_CLOSE
    Exit
    Case $circle[$i]
    If $mode_random = 0 Then
    If GUICtrlRead($number[$i]) = $min_number Then
    DistributePoints()
    ToolTip("")
    ReDim $controll[1]
    CreateNumbers()
    Else
    ToolTip(GUICtrlRead($number[$i]) & " ist nicht die kleinste Zahl.", Default, Default, "Falsch", 3)
    GUICtrlSetData($score, GUICtrlRead($score) -1000)
    GUICtrlSetData($last_score, -1000)
    EndIf
    ElseIf $mode_random = 1 Then
    If GUICtrlRead($number[$i]) = $max_number Then
    DistributePoints()
    ToolTip("")
    ReDim $controll[1]
    CreateNumbers()
    Else
    ToolTip(GUICtrlRead($number[$i]) & " ist nicht die größte Zahl.", Default, Default, "Falsch", 3)
    GUICtrlSetData($score, GUICtrlRead($score) -1000)
    GUICtrlSetData($last_score, -1000)
    EndIf
    ElseIf $mode_random = 2 Then
    If GUICtrlRead($number[$i]) = 40 Then
    DistributePoints()
    ToolTip("")
    ReDim $controll[1]
    CreateNumbers()
    Else
    ToolTip(StringTrimRight($mode[$mode_random][0], 2) & " ist nicht " & GUICtrlRead($number[$i]) & ".", Default, Default, "Falsch", 3)
    GUICtrlSetData($score, GUICtrlRead($score) -1000)
    GUICtrlSetData($last_score, -1000)
    EndIf
    ElseIf $mode_random = 3 Then
    If GUICtrlRead($number[$i]) = 49 Then
    DistributePoints()
    ToolTip("")
    ReDim $controll[1]
    CreateNumbers()
    Else
    ToolTip(StringTrimRight($mode[$mode_random][0], 2) & " ist nicht " & GUICtrlRead($number[$i]) & ".", Default, Default, "Falsch", 3)
    GUICtrlSetData($score, GUICtrlRead($score) -1000)
    GUICtrlSetData($last_score, -1000)
    EndIf
    ElseIf $mode_random = 4 Then
    If GUICtrlRead($number[$i]) = 67 Then
    DistributePoints()
    ToolTip("")
    ReDim $controll[1]
    CreateNumbers()
    Else
    ToolTip(StringTrimRight($mode[$mode_random][0], 2) & " ist nicht " & GUICtrlRead($number[$i]) & ".", Default, Default, "Falsch", 3)
    GUICtrlSetData($score, GUICtrlRead($score) -1000)
    GUICtrlSetData($last_score, -1000)
    EndIf
    ElseIf $mode_random = 5 Then
    If GUICtrlRead($number[$i]) = 99 Then
    DistributePoints()
    ToolTip("")
    ReDim $controll[1]
    CreateNumbers()
    Else
    ToolTip(StringTrimRight($mode[$mode_random][0], 2) & " ist nicht " & GUICtrlRead($number[$i]) & ".", Default, Default, "Falsch", 3)
    GUICtrlSetData($score, GUICtrlRead($score) -1000)
    GUICtrlSetData($last_score, -1000)
    EndIf
    ElseIf $mode_random = 6 Then
    If GUICtrlRead($number[$i]) = 89 Then
    DistributePoints()
    ToolTip("")
    ReDim $controll[1]
    CreateNumbers()
    Else
    ToolTip(StringTrimRight($mode[$mode_random][0], 2) & " ist nicht " & GUICtrlRead($number[$i]) & ".", Default, Default, "Falsch", 3)
    GUICtrlSetData($score, GUICtrlRead($score) -1000)
    GUICtrlSetData($last_score, -1000)
    EndIf
    ElseIf $mode_random = 7 Then
    If GUICtrlRead($number[$i]) = 68 Then
    DistributePoints()
    ToolTip("")
    ReDim $controll[1]
    CreateNumbers()
    Else
    ToolTip(StringTrimRight($mode[$mode_random][0], 2) & " ist nicht " & GUICtrlRead($number[$i]) & ".", Default, Default, "Falsch", 3)
    GUICtrlSetData($score, GUICtrlRead($score) -1000)
    GUICtrlSetData($last_score, -1000)
    EndIf
    ElseIf $mode_random = 8 Then
    If GUICtrlRead($number[$i]) = 3 Then
    DistributePoints()
    ToolTip("")
    ReDim $controll[1]
    CreateNumbers()
    Else
    ToolTip(StringTrimRight($mode[$mode_random][0], 2) & " ist nicht " & GUICtrlRead($number[$i]) & ".", Default, Default, "Falsch", 3)
    GUICtrlSetData($score, GUICtrlRead($score) -1000)
    GUICtrlSetData($last_score, -1000)
    EndIf
    ElseIf $mode_random = 9 Then
    If GUICtrlRead($number[$i]) = 61 Then
    DistributePoints()
    ToolTip("")
    ReDim $controll[1]
    CreateNumbers()
    Else
    ToolTip(StringTrimRight($mode[$mode_random][0], 2) & " ist nicht " & GUICtrlRead($number[$i]) & ".", Default, Default, "Falsch", 3)
    GUICtrlSetData($score, GUICtrlRead($score) -1000)
    GUICtrlSetData($last_score, -1000)
    EndIf
    EndIf
    EndSwitch
    Next
    WEnd

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

    Func CreateNumbers()

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

    $mode_random = Random(0, 9, 1)
    GUICtrlSetData($question, $mode[$mode_random][0])

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

    $game = $game+1
    GUICtrlSetData($game_label, $game & ". Runde")

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

    $begin = TimerInit()

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

    For $i = 0 To 9

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

    GUICtrlDelete($circle[$i])
    GUICtrlDelete($number[$i])

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

    $random_white = Random(0, 34, 1)
    $random_high = Random(0, 34, 1)

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

    While 1
    If _ArrayFindAll($controll, $pos[$random_white][0] & $pos[$random_high][1]) <> -1 then
    $random_white = Random(0, 34, 1)
    $random_high = Random(0, 34, 1)
    Else
    ExitLoop
    EndIf
    WEnd

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

    $circle[$i] = GUICtrlCreateIcon("files\circle.ico", "circle.ico", $pos[$random_white][0], $pos[$random_high][1], 60, 60)
    $number[$i] = GUICtrlCreateLabel(Random(1, 99, 1), $pos[$random_white][0]+20, $pos[$random_high][1]+20, 20, 18, $SS_CENTER)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUICtrlSetFont(-1, 12, 600)

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

    If $mode_random = 2 Then GUICtrlSetData($number[Random(0, 9)], 40)
    If $mode_random = 3 Then GUICtrlSetData($number[Random(0, 9)], 49)
    If $mode_random = 4 Then GUICtrlSetData($number[Random(0, 9)], 67)
    If $mode_random = 5 Then GUICtrlSetData($number[Random(0, 9)], 99)
    If $mode_random = 6 Then GUICtrlSetData($number[Random(0, 9)], 89)
    If $mode_random = 7 Then GUICtrlSetData($number[Random(0, 9)], 68)
    If $mode_random = 8 Then GUICtrlSetData($number[Random(0, 9)], 3)
    If $mode_random = 9 Then GUICtrlSetData($number[Random(0, 9)], 61)

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

    _ArrayAdd($controll, $pos[$random_white][0] & $pos[$random_high][1])
    _ArrayAdd($number_array, GUICtrlRead($number[$i]))
    Next

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

    _ArrayDelete($number_array, 0)

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

    $min_number = _ArrayMin($number_array, 1)
    $max_number = _ArrayMax($number_array, 1)

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

    GUISetState()
    EndFunc

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

    Func DistributePoints()
    $time = Round(TimerDiff($begin))/1000

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

    If $time < 0.5 Then
    GUICtrlSetData($score, GUICtrlRead($score) +1500)
    GUICtrlSetData($last_score, 1500)
    ElseIf $time < 1 Then
    GUICtrlSetData($score, GUICtrlRead($score) +1000)
    GUICtrlSetData($last_score, 1000)
    ElseIf $time < 1.5 Then
    GUICtrlSetData($score, GUICtrlRead($score) +850)
    GUICtrlSetData($last_score, 850)
    ElseIf $time < 2 Then
    GUICtrlSetData($score, GUICtrlRead($score) +700)
    GUICtrlSetData($last_score, 700)
    ElseIf $time < 2.5 Then
    GUICtrlSetData($score, GUICtrlRead($score) +550)
    GUICtrlSetData($last_score, 550)
    ElseIf $time < 3 Then
    GUICtrlSetData($score, GUICtrlRead($score) +400)
    GUICtrlSetData($last_score, 400)
    ElseIf $time < 3.5 Then
    GUICtrlSetData($score, GUICtrlRead($score) +250)
    GUICtrlSetData($last_score, 250)
    ElseIf $time < 4 Then
    GUICtrlSetData($score, GUICtrlRead($score) +100)
    GUICtrlSetData($last_score, 100)
    EndIf
    EndFunc

    [/autoit]

    wechselt jetzt zwischen kleinste und größte zahl. den fehler von stayawayknight konnte ich nach langer testfase nicht mehr feststellen.
    werd wohl noch nen highscore mit einbauen und versuchen einen vergleich mit den punkten herstellen zu können.. wie zB das spiel dauert immer nur 10 runden und da gilt es möglichst viele punkte zu sammeln.
    das mit dem start und stopp knopf ist auch noch nicht eingebunden. aber spielbar ist es schon ganz gut also viel spaß dabei ;)

    bild was ihr dazu braucht:
    [Blockierte Grafik: http://1click-image.de/user/image/423486907.ico]

    EDIT:
    Neue Version. neben kleineste und größte Zahl nun auch Rechenfragen

    2 Mal editiert, zuletzt von Inferior (28. Mai 2011 um 19:45)