Jump to content

Don't know why this isn't working


 Share

Recommended Posts

Hello, I'm making a click em game, but as soon as I click start, no matter what the updown is, it will give me a message box saying I've won in 0 seconds. Any help? Thanks.

#include <GUIConstantsEx.au3>

$Need = False
$Num = 0
$Timing = False
$Time = 0
$StartTime = 0
$ScoreGoal = 10
$TimeLast = 0
$Playing = False
For $x = 1 To 101
    Dim $Button[$x]
Next
$Score = 0
$Left = 0
$Top = 0
$Left = StringSplit("0|30|60|90|120|150|180|210|240|270|0|30" & _
                    "|60|90|120|150|180|210|240|270|0|30|60|90" & _
                    "|120|150|180|210|240|270|0|30|60|90|120|150" & _
                    "|180|210|240|270|0|30|60|90|120|150|180" & _
                    "|210|240|270|0|30|60|90|120|150|180|210|240" & _
                    "|270|0|30|60|90|120|150|180|210|240|270" & _
                    "|0|30|60|90|120|150|180|210|240|270|0|30" & _
                    "|60|90|120|150|180|210|240|270|0|30|60|90" & _
                    "|120|150|180|210|240|270", "|")
$Top = StringSplit("0|0|0|0|0|0|0|0|0|0|30|30" & _
                    "|30|30|30|30|30|30|30|30|60|60|60|60" & _
                    "|60|60|60|60|60|60|90|90|90|90|90|90" & _
                    "|90|90|90|90|120|120|120|120|120|120|120" & _
                    "|120|120|120|150|150|150|150|150|150|150|150|150" & _
                    "|150|180|180|180|180|180|180|180|180|180|180" & _
                    "|210|210|210|210|210|210|210|210|210|210|240|240" & _
                    "|240|240|240|240|240|240|240|240|270|270|270|270" & _
                    "|270|270|270|270|270|270", "|")

$Main = GUICreate("Click 'Em!", 300, 400)

$TopBk = GUICtrlCreateGraphic(0, 0, 300, 300, 0x03)
$BottomBk = GUICtrlCreateGraphic(0, 301, 300, 100)
$ScoreLab = GUICtrlCreateLabel("Score: " & $Score & "/", 20, 320)
$TimeLab = GUICtrlCreateLabel("Time: ", 20, 350, 100)
$UpDownLab = GUICtrlCreateInput("10", 70, 317, 40, 20)
$OutOfUpDown = GUICtrlCreateUpdown($UpDownLab)
$StartBut = GUICtrlCreateButton("Start!", 200, 320, 60, 30)
GUICtrlSetBkColor($TopBk, 0x000000)
GUICtrlSetBkColor($BottomBk, 0x888888)
GUICtrlSetState($BottomBk, $GUI_DISABLE)
GUICtrlSetBkColor($ScoreLab, 0x888888)
GUICtrlSetBkColor($TimeLab, 0x888888)
For $x = 1 To $Left[0]
    $Button[$x] = GUICtrlCreateGraphic($Left[$x], $Top[$x], 30, 30)
    GUICtrlSetBkColor($Button[$x], 0x000000)
Next

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $Need = True
            $Num = Random(1, 100, 1)
            $Need = False
            GUICtrlSetBkColor($Button[$Num], 0xFF0000)
        Case $msg = $Button[$Num] And $Playing = True
            $Score = $Score + 1
            GUICtrlSetData($ScoreLab, "Score: " & $Score & "/")
            GUICtrlSetBkColor($Button[$Num], 0x000000)
            $Need = True
        Case $Time = 10
            $Playing = False
        Case $Score = $ScoreGoal
            MsgBox(0, "You won!", "You won in " & $Time & " seconds!")
            $Playing = False
            $Need = False
            $Score = 0
        Case $Timing = False And $Playing = True
            $Time = @SEC - $StartTime
            $Timing = True
        Case $msg = $StartBut
            $Playing = True
            $Need = True
            $Timing = True
            $ScoreGoal = GUICtrlRead($OutOfUpDown)
        Case $Timing = True
            If $Time <> $TimeLast And $Playing = True Then
                GUICtrlSetData($TimeLab, "Time: " & 10 - $Time)
            EndIf
            $TimeLast = $Time
    EndSelect
WEnd
Exit
Edited by Minikori

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Link to comment
Share on other sites

When you have a graphic as a background, you have to set its style to disabled if you want controls in the same region to be accessible.

Okay I added GUICtrlSetState($BottomBk, $GUI_DISABLE) and now as soon as I click start it says I won in zero seconds.

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Link to comment
Share on other sites

the problem that you enabled timing and need on start

Case $msg = $StartBut
            $Playing = True
            $Need = True
            $Timing = True
            $ScoreGoal = GUICtrlRead($OutOfUpDown)

here it is working

#include <GUIConstantsEx.au3>

$Need = False
$Num = 0
$Timing = False
$Time = 0
$StartTime = 0
$ScoreGoal = 10
$TimeLast = 0
$Playing = False
For $x = 1 To 101
    Dim $Button[$x]
Next
$Score = 0
$Left = 0
$Top = 0
$Left = StringSplit("0|30|60|90|120|150|180|210|240|270|0|30" & _
                    "|60|90|120|150|180|210|240|270|0|30|60|90" & _
                    "|120|150|180|210|240|270|0|30|60|90|120|150" & _
                    "|180|210|240|270|0|30|60|90|120|150|180" & _
                    "|210|240|270|0|30|60|90|120|150|180|210|240" & _
                    "|270|0|30|60|90|120|150|180|210|240|270" & _
                    "|0|30|60|90|120|150|180|210|240|270|0|30" & _
                    "|60|90|120|150|180|210|240|270|0|30|60|90" & _
                    "|120|150|180|210|240|270", "|")
$Top = StringSplit("0|0|0|0|0|0|0|0|0|0|30|30" & _
                    "|30|30|30|30|30|30|30|30|60|60|60|60" & _
                    "|60|60|60|60|60|60|90|90|90|90|90|90" & _
                    "|90|90|90|90|120|120|120|120|120|120|120" & _
                    "|120|120|120|150|150|150|150|150|150|150|150|150" & _
                    "|150|180|180|180|180|180|180|180|180|180|180" & _
                    "|210|210|210|210|210|210|210|210|210|210|240|240" & _
                    "|240|240|240|240|240|240|240|240|270|270|270|270" & _
                    "|270|270|270|270|270|270", "|")

$Main = GUICreate("Click 'Em!", 300, 400)

$TopBk = GUICtrlCreateGraphic(0, 0, 300, 300, 0x03)
$BottomBk = GUICtrlCreateGraphic(0, 301, 300, 100)
$ScoreLab = GUICtrlCreateLabel("Score: " & $Score & "/", 20, 320)
$TimeLab = GUICtrlCreateLabel("Time: ", 20, 350, 100)
$UpDownLab = GUICtrlCreateInput("10", 70, 317, 40, 20)
$OutOfUpDown = GUICtrlCreateUpdown($UpDownLab)
$StartBut = GUICtrlCreateButton("Start!", 200, 320, 60, 30)
GUICtrlSetBkColor($TopBk, 0x000000)
GUICtrlSetBkColor($BottomBk, 0x888888)
GUICtrlSetState($BottomBk, $GUI_DISABLE)
GUICtrlSetBkColor($ScoreLab, 0x888888)
GUICtrlSetBkColor($TimeLab, 0x888888)
For $x = 1 To $Left[0]
    $Button[$x] = GUICtrlCreateGraphic($Left[$x], $Top[$x], 30, 30)
    GUICtrlSetBkColor($Button[$x], 0x000000)
Next

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $Need = True
            $Num = Random(1, 100, 1)
            $Need = False
            GUICtrlSetBkColor($Button[$Num], 0xFF0000)
        Case $msg = $Button[$Num] And $Playing = True
            $Score = $Score + 1
            GUICtrlSetData($ScoreLab, "Score: " & $Score & "/")
            GUICtrlSetBkColor($Button[$Num], 0x000000)
            $Need = True
        Case $Time = 10
            $Playing = False
        Case $Score = $ScoreGoal
            MsgBox(0, "You won!", "You won in " & $Time & " seconds!")
            $Playing = False
            $Need = False
            $Score = 0
        Case $Timing = False And $Playing = True
            $Time = @SEC - $StartTime
            $Timing = True
        Case $msg = $StartBut
            $Playing = True
            $ScoreGoal = GUICtrlRead($OutOfUpDown)
        Case $Timing = True
            If $Time <> $TimeLast And $Playing = True Then
                GUICtrlSetData($TimeLab, "Time: " & 10 - $Time)
            EndIf
            $TimeLast = $Time
    EndSelect
WEnd
Exit
Edited by komalo
[font="Palatino Linotype"][size="3"]AutoIt Script Examples :[/size][/font][font="Palatino Linotype"][size="3"]_CaptureBehindWindowGlass CMD for Windows Vista/Seven[/size][/font][left][/left][font="Palatino Linotype"][size="3"]Non AutoIt Script programs : Border Skin - Aero Glass On XP[/size][/font]
Link to comment
Share on other sites

the problem that you enabled timing and need on start

The time is stuck at -1 and once I get to the set goal it doesn't do anything.

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...