Jump to content

Game: How fast are u ?


AlmarM
 Share

Recommended Posts

  • Replies 83
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

@Manadar -- I have modified yours a little just to keep the local saved scores feature and added a little not to say what level that score is from. Other than that I like what you have done, I can really learn a lot from your script, so for that I thank you!

Here is the modified ver.

alien13

Edited by alien13
Link to comment
Share on other sites

Srry, but im not gonne add scripts that I dont understand... Im not THAT good in AutoIT scriping.

So im staying with my Old script THAT I understand ^^

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

well I saw the original script and felt compelled to write a better one. I was disappointed to see that I'm a bit late. I felt like I owe Manadar something, since he came up with the array idea, but I, too, had the idea, and didn't read his scripts before writing mine. I'm sorry if any of it looks similar, I did write it. I decided to leave the random pick out of the code, because depending on how the random buttons are picked, it could make the game very easy. I kept everything exactly the way AlmarM had it, except for the way it was written and how things are displayed. Take a look. I would enjoy feedback from experienced coders able to shorten up my code. So here it is:

Back to Manadar, nice script, although you left out exit functionality during the game, and the ability to change modes once one is picked. I really enjoyed the About screen. I may have to use that in the rest of my scripts, your name of course included.

I completely believe you. The array step was a logical one to make, and you used a one dimensional array.. I always prefer to keep two dimensions, when using two axis's, to make things easier.

The reason why I left out exit functionality is the same reason why I didn't add a lot of things that I could have added. I wanted to show AlmarM the purpose of arrays, and why he should learn them. Nothing else. Also, I doubt putting in exit functionality during the game is a logic step. I may need to rewrite the game to OnEvent mode.

Thanks for the compliment on the About screen. I wrote it for someone else to use, but I figured if he was not going to use it I may well advertise it a little bit more. ;) Also thanks for giving me credit, should you use the about screen. Always appreciate it.

@alien13, I like the way you keep the high scores. :) I do hope you learn a lot from the script, as that is it's primary purpose. Happy to teach!

Edited by Manadar
Link to comment
Share on other sites

Here's a different version of the game, the basics are the same.. You still have to click a button.

Opt("GUIOnEventMode", 1)

#include <GUIConstants.au3>

Dim $gButton[3][2][2], $iStart = 0, $iPressed = 0, $iClicks = 0, $sTime

$sGUI = GUICreate("HowFastAreU2", 400, 400)

GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit")

GUICtrlCreateLabel("Welcome to HowFastAreU version 2! This time you have three different boxes. All three of them move constantly. Your objective is to click on a box as soon as it lits up. How fast can you tick them? Good luck.", 10, 350, 380, 50)

For $x = 0 to 2
    $gButton[$x][0][0] = GUICtrlCreateButton("Start", 10+(60*$x), 10, 50, 50)
    $gButton[$x][1][0] = 10+(60*$x)
    $gButton[$x][1][1] = 10
    GUICtrlSetOnEvent($gButton[$x][0][0],"_Button" & $x)
Next

GUISetState()

While 1
    Sleep(50)
    
    For $x = 0 to 2
        $aPos = ControlGetPos($sGUI,"",$gButton[$x][0][0])
        If ($gButton[$x][1][0] <> $aPos[0]) OR ($gButton[$x][1][1] <> $aPos[1]) Then
            $delX = ($gButton[$x][1][0] - $aPos[0]) / 10
            $delY = ($gButton[$x][1][1] - $aPos[1]) / 10
            If (Round($delX,0) < 5) AND (Round($delY,0) < 5) AND ($gButton[$x][0][1] = $GUI_DISABLE) Then
                GUICtrlSetState($gButton[$x][0][0],$GUI_ENABLE)
                $gButton[$x][0][1] = $GUI_ENABLE
            Else
                ControlMove($sGUI,"",$gButton[$x][0][0],$aPos[0]+$delX,$aPos[1]+$delY)
            EndIf
        EndIf
    Next
WEnd

Func _Button0()
    If Not $iStart Then
        $iPressed += 1
        GUICtrlSetState($gButton[0][0][0],$GUI_DISABLE)
        If $iPressed = 3 Then
            StartGame()
        EndIf
    Else
        $gButton[0][1][0] = Random(10,340,1)
        $gButton[0][1][1] = Random(10,290,1)
        GUICtrlSetState($gButton[0][0][0],$GUI_DISABLE)
        $gButton[0][0][1] = $GUI_DISABLE
        
        $iClicks += 1
        CheckVictory()
    EndIf
EndFunc

Func _Button1()
    If Not $iStart Then
        $iPressed += 1
        GUICtrlSetState($gButton[1][0][0],$GUI_DISABLE)
        If $iPressed = 3 Then
            StartGame()
        EndIf
    Else
        $gButton[1][1][0] = Random(10,340,1)
        $gButton[1][1][1] = Random(10,290,1)
        GUICtrlSetState($gButton[1][0][0],$GUI_DISABLE)
        $gButton[1][0][1] = $GUI_DISABLE
        
        $iClicks += 1
        CheckVictory()
    EndIf
EndFunc

Func _Button2()
    If Not $iStart Then
        $iPressed += 1
        GUICtrlSetState($gButton[2][0][0],$GUI_DISABLE)
        If $iPressed = 3 Then
            StartGame()
        EndIf
    Else
        $gButton[2][1][0] = Random(10,340,1)
        $gButton[2][1][1] = Random(10,290,1)
        GUICtrlSetState($gButton[2][0][0],$GUI_DISABLE)
        $gButton[2][0][1] = $GUI_DISABLE
        
        $iClicks += 1
        CheckVictory()
    EndIf
EndFunc

Func StartGame()
    $iStart = 1
    For $x = 0 to 2
        GUICtrlSetData($gButton[$x][0][0],"Click")
        $gButton[$x][0][1] = $GUI_DISABLE
        $gButton[$x][1][0] = Random(10,340,1)
        $gButton[$x][1][1] = Random(10,290,1)
    Next
    $sTime = TimerInit()
EndFunc

Func CheckVictory()
    If $iClicks > 50 Then
        $temp = Round(TimerDiff($sTime)/1000,1)
        $sResult = "You got them in " & $temp & " seconds."
        If $temp > 30 Then
            $sResult &= @CRLF & @CRLF & "HINT: The boxes that move just a little once you have clicked " & @CRLF & _
            "them become available for clicking sooner, so keep your mouse close!!"
        EndIf
        For $x = 0 to 2
            GUICtrlSetData($gButton[$x][0][0],"Start")
            GUICtrlSetState($gButton[$x][0][0],$GUI_DISABLE)
            $gButton[$x][0][1] = $GUI_DISABLE
            $gButton[$x][1][0] = 10+(60*$x)
            $gButton[$x][1][1] = 10
        Next
        $iStart = 0
        $iPressed = 0
        $iClicks = 0
        $sTime = 0
        MsgBox(0, "Your results..", $sResult)
    EndIf
EndFunc

Func _Exit()
    Exit
EndFunc
Edited by Manadar
Link to comment
Share on other sites

Im at school now so i cant test is and.. Ty for saying the script is good (The idea) But i just cant figure out where all the Click Buttons are :S

And when its disable and enable so... Thats why im not adding it :)...

PS

Some1 mayby have some other EASY ideas for me ?? I mean im bored the last weaks because i dont have any ideas for any scripts... So anyone have an idea for me ?? Not TO hard please...

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

Im at school now so i cant test is and.. Ty for saying the script is good (The idea) But i just cant figure out where all the Click Buttons are :S

And when its disable and enable so... Thats why im not adding it ;)...

PS

Some1 mayby have some other EASY ideas for me ?? I mean im bored the last weaks because i dont have any ideas for any scripts... So anyone have an idea for me ?? Not TO hard please...

Well, maybe you could update your clicking game to have multiple buttons at the same time you can click.. :)
Link to comment
Share on other sites

Well, maybe you could update your clicking game to have multiple buttons at the same time you can click.. :)

You mean? For example

X = Enabled Button

O = Disabled Button

O X O O O

O O O X O

X O O O X

O O O O O

O O X O O

X O O O O

Is that what you mean ?? Exexpt that there are many Enabled. Or is that what you mean ;) ?

But I dont get whats fun about that, because it will easier

Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

  • 11 months later...

Woah!

Never knewn there was a discussion between Manadar and me.

Afther re-reading it all, there is one thing I want to say:

Sorry

Just re-read all things I said :P

AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

  • 6 months later...

I win!!! rawr.

Rawr, I'm a dinosaur!!

small bug. control click works on disabled buttons and it only times from begininnig to end.

0.2 is the new record.

ControlClick ("How fast are u ?", "", 3)
ControlClick ("How fast are u ?", "", 4)

very simple really

without cheating got it down to 20.3.

MDiesel

Edited by mdiesel
Link to comment
Share on other sites

A little harder to cheat on I think? The label at the bottom tells you column and row to click on I believe I did that part right, in case I didn't columns are vertical, rows are horizontal.

CODE
#include <GuiConstants.au3>

#include <Constants.au3>

Dim $button[100][100]

Global $dif, $start_button

$r = 0

$b = 0

$r1 = 1

$r2 = 1

HotKeySet("{F4}", "HighScores")

$Main = GUICreate("How fast are u ?", 470, 640) ; Given this GUI a name

GUISetState(@SW_SHOW)

For $w = 1 to 6

For $i = 1 to 6

$r += 1

$button[$i][$w] = GUICtrlCreateButton("Button" & $r, ($i * 10) + ($i * 50), ($w * 10) + ($w * 50), 50, 50)

GUICtrlSetState(-1,$GUI_DISABLE)

Next

Next

$Quick_HighScore = GUICtrlCreateEdit("Quick Highscore view" & @CRLF & @CRLF, 60, 430, 350, 120)

$start_button = GUICtrlCreateButton("Start",50,560,80,30)

$Restart_Button = GUICtrlCreateButton("Restart", 150, 560, 80, 30)

$HighScores = GUICtrlCreateButton("High Scores", 250, 560, 80, 30)

$About = GUICtrlCreateButton("About", 350, 560, 80, 30)

$label = GUICtrlCreateLabel("Label",200,600,200,20)

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

Exit

;~

Case $msg = $Start_Button

For $w = 1 To 6

For $i = 1 To 6

GUICtrlSetState($button[$i][$w],$GUI_ENABLE)

;~ MsgBox(0,"","")

Next

Next

$r1 = Random(1,6,1)

$r2 = Random(1,6,1)

$begin = TimerInit()

GUICtrlSetData($label, "Column: " & $r1 & " Row: " & $r2)

Case $msg = $button[$r1][$r2]

$b += 1

$r1 = Random(1,6,1)

$r2 = Random(1,6,1)

GUICtrlSetData($label, "Column: " & $r1 & " Row: " & $r2)

;~ Case $msg[1] = $main

;~ MsgBox(0,"",$msg[1])

Case $b = 10

Beep(500, 100)

$dif = Round(TimerDiff($begin) / 1000, 1)

MsgBox(0, "Your Time: ", "Your time is: " & $dif & " seconds. ")

GUICtrlSetData($Quick_HighScore, $dif & " Seconds" & @CRLF, "|")

;Asks the user if they want to save their score

If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer

$iMsgBoxAnswer = MsgBox(36, "Save", "Would you like to save your score?")

Select

Case $iMsgBoxAnswer = 6 ;Yes

Save() ; Goes to the save function

Case $iMsgBoxAnswer = 7 ;No

;nothing

EndSelect

_reset()

Case $msg = $Restart_Button

_Reset()

Case $msg = $HighScores

HighScores()

Case $msg = $About

About()

EndSelect

Sleep (20)

WEnd

Func _Reset()

Sleep(100)

;~ MsgBox(0, "Restart", "Restarting" & @CRLF & "Please wait...", 2)

$r1 = Random(1,6,1)

$r2 = Random(1,6,1)

$b = 0

For $w = 1 To 6

For $i = 1 To 6

GUICtrlSetState($button[$i][$w],$GUI_DISABLE)

;~ MsgBox(0,"","")

Next

Next

Sleep(100)

EndFunc ;==>_Reset

Func Save()

FileWrite(@ScriptDir & "\Scores.txt", $dif & " Seconds" & @CRLF)

MsgBox(64, "Saved", "Your high score has been saved!") ; Tells you it is saved

HighScores() ; Opens the high scores window

EndFunc ;==>Save

Func HighScores()

$Scores = FileRead(@ScriptDir & "\Scores.txt") ; Reads the scores from the txt file

If @error Then

MsgBox(0, "", "Error occurred, you probably haven't saved any scores yet.")

Else

GUISetState(@SW_HIDE, $Main)

$HSW = GUICreate("High Scores", 241, 237)

$HS = GUICtrlCreateEdit("Scores:"& @CRLF & $Scores, 10, 10, 221, 217, BitOR($ES_READONLY, $ES_WANTRETURN))

GUISetState(@SW_SHOW)

While 3

$msg3 = GUIGetMsg()

Select

Case $msg3 = $GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

GUIDelete($HSW)

GUISetState(@SW_SHOW, $Main)

EndIf

EndFunc ;==>HighScores

Func About()

GUISetState(@SW_HIDE, $Main)

$AboutWindow = GUICreate("About", 250, 200)

$ProgramName = GUICtrlCreateLabel("How fast are u?", 85, 26)

$ProgramDescription = GUICtrlCreateEdit("Credits:" & @CRLF & @CRLF & "Scripter: AlmarM" & @CRLF & "Game by: AlmarM" & @CRLF & "Some things edited by: alien13", 20, 60, 210, 126, BitOR($ES_READONLY, $ES_WANTRETURN))

GUISetState(@SW_SHOW)

While 2

$msg2 = GUIGetMsg()

Select

Case $msg2 = $GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

GUIDelete($AboutWindow)

GUISetState(@SW_SHOW, $Main)

EndFunc

Edited by youknowwho4eva

Giggity

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...