Sign in to follow this  
Followers 0
lordicast

Bored Time Racers

3 posts in this topic

Ok this script started as GuiCtrlCreateIcon from help and transformed into a full blown game. Complete random Races,Betting and Racing with steroids!. Couple people in the office playing it, kind of addicting.

In Short,.

Players click the mouse frantically to race with other icons.

#include <Misc.Au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>



$RightS = '{up}'
$LeftS = '{left}'

HotKeySet('{Esc}', 'End')




Global $cDir = @ScriptDir
Global $Racer1 = 'Blue Dino'
Global $Racer2 = 'Horsey Horse'
Global $Racer3 = 'Yellow Dino'
Global $Racer4 = @UserName
Global $uSpeed = 2.0

Global $level1 = 2.0
Global $level2 = 1.9
Global $level3 = 1.8
Global $level4 = 1.7
Global $level5 = 1.6
Global $level6 = 1.5


Dim $iOt, $a, $b, $c, $d, $Sec
$iOt = Opt("GUICoordMode", 1)
If FileExists('C:\Users\' & @UserName & '\Documents\logs\trec2') = 0 Then
    DirCreate('C:\Users\' & @UserName & '\Documents\logs')
EndIf

Global $sDir = 'C:\Users\' & @UserName & '\Documents\logs\'
Global $tDir = 'tRec2'
Global $zDir = 'tRer2'

Global $Sb1 = 0.5
Global $Sb2 = 0.5
Global $Sb3 = 0.5
Global $Sb4 = 0.5
Global $Bonus = 0

$nsLok = FileOpen($sDir & $tDir, 0)
$nsLook = FileRead($nsLok)
FileClose($nsLok)

If StringInStr($nsLook, @UserName) = 0 Then
    IniWrite($sDir & $tDir, @UserName, 'money', 1000)
    IniWrite($sDir & $tDir, 'Best', 'Time', '60')
    IniWrite($sDir & $tDir, $Racer1, 'Win', '0')
    IniWrite($sDir & $tDir, $Racer2, 'Win', '0')
    IniWrite($sDir & $tDir, $Racer3, 'Win', '0')
    IniWrite($sDir & $tDir, $Racer4, 'Win', '0')
    Rules()
EndIf



$Ncm = "Bored Time Racers Season 2: Quantum Fingers"

$Gui = GUICreate($Ncm, 600, 230, -1, -1)
GUISetBkColor(0xffffff)




GUICtrlCreateGraphic(333, 16, 20, 164)
GUICtrlSetColor(-1, 000000)
GUICtrlSetBkColor(-1, 0x104E8B)
GUICtrlCreateLabel("", 33, 20, 1, 155, 5)

;names and money
$Nom = StringReplace(@UserName, '.', ' ')
GUICtrlCreateLabel($Nom & ':', 390, 0, 80, 20)
GUICtrlSetColor(-1, 000000)
GUICtrlCreateLabel('Money:', 480, 0, 50, 20)
GUICtrlSetColor(-1, 000000)



$money = IniRead($sDir & $tDir, @UserName, 'money', '')
$monk = GUICtrlCreateLabel($money, 545, 0, 100, 20)
GUICtrlSetColor(-1, 000000)
GUICtrlCreateLabel('Wager', 450, 40, 40, 20)
GUICtrlSetColor(-1, 000000)
$wager = GUICtrlCreateInput('', 500, 40, 60, 20)


$r1 = GUICtrlCreateButton($Racer1, 420, 70, 80, 20)
$r2 = GUICtrlCreateButton($Racer2, 510, 70, 80, 20)
$r3 = GUICtrlCreateButton($Racer3, 420, 100, 80, 20)
$r4 = GUICtrlCreateButton($Racer4, 510, 100, 80, 20)

$rs1 = GUICtrlCreateButton('$2000 Shoes', 310, 190, 100, 20)
$rs2 = GUICtrlCreateButton('$4000 Steroids', 490, 190, 100, 20)
$rs3 = GUICtrlCreateButton('$3000 Rocks', 310, 210, 100, 20)
$rs4 = GUICtrlCreateButton('$10000 Training', 490, 210, 100, 20)

$rsh1 = GUICtrlCreateButton('?', 415, 190, 20, 20)

$rsh2 = GUICtrlCreateButton('?', 465, 190, 20, 20)

$rsh3 = GUICtrlCreateButton('?', 415, 210, 20, 20)

$rsh4 = GUICtrlCreateButton('?', 465, 210, 20, 20)



;Best Times
GUICtrlCreateLabel('Best Time:', 0, 215, 80, 32)
GUICtrlSetColor(-1, 000000)
$heat = IniRead($sDir & $tDir, 'Best', 'Time', '')
$recTime = GUICtrlCreateLabel($heat, 50, 215, 200, 32)
GUICtrlSetColor(-1, 000000)
;---------------------------------------
$Levi = GUICtrlCreateLabel('Level: 1', 200, 190, 60, 16)
GUICtrlSetColor(-1, 000000)
;
GUICtrlCreateLabel("Wins:", 354, 20, 28, 15)
GUICtrlSetColor(-1, 000000)
GUICtrlCreateLabel("Wins:", 354, 60, 28, 15)
GUICtrlSetColor(-1, 000000)
GUICtrlCreateLabel("Wins:", 354, 100, 28, 15)
GUICtrlSetColor(-1, 000000)
GUICtrlCreateLabel("Wins:", 354, 140, 28, 15)
GUICtrlSetColor(-1, 000000)

$b1 = GUICtrlCreateButton('Start', 10, 190, 60, 18)
$RulButton = GUICtrlCreateButton('Rules', 90, 190, 60, 18)
;


;race lines
GUICtrlCreateLabel('====================================================================================================', 32, 10, 300, 8)
GUICtrlSetColor(-1, 000000)
GUICtrlCreateLabel('====================================================================================================', 32, 50, 300, 8)
GUICtrlSetColor(-1, 000000)
GUICtrlCreateLabel('====================================================================================================', 32, 90, 300, 8)
GUICtrlSetColor(-1, 000000)
GUICtrlCreateLabel('====================================================================================================', 32, 130, 300, 8)
GUICtrlSetColor(-1, 000000)
GUICtrlCreateLabel('====================================================================================================', 32, 172, 300, 8)
GUICtrlSetColor(-1, 000000)
;

$n1 = GUICtrlCreateIcon($cDir & "\dinosaur.ani", -1, 0, 20, 32, 32)
$n2 = GUICtrlCreateIcon($cDir & "\horse.ani", -1, 0, 60, 32, 32)
$n3 = GUICtrlCreateIcon($cDir & "\Dinosau2.ani", -1, 0, 100, 32, 32)
$n4 = GUICtrlCreateIcon($cDir & "\walkman.ani", -1, 0, 140, 32, 32)


$aa1 = IniRead($sDir & $tDir, $Racer1, 'Win', '')
$aa2 = IniRead($sDir & $tDir, $Racer2, 'Win', '')
$aa3 = IniRead($sDir & $tDir, $Racer3, 'Win', '')
$aa4 = IniRead($sDir & $tDir, $Racer4, 'Win', '')

$aw = GUICtrlCreateLabel($aa1, 382, 20, 35, 15)
GUICtrlSetColor(-1, 000000)
$bw = GUICtrlCreateLabel($aa2, 382, 60, 35, 15)
GUICtrlSetColor(-1, 000000)
$cw = GUICtrlCreateLabel($aa3, 382, 100, 35, 15)
GUICtrlSetColor(-1, 000000)
$dw = GUICtrlCreateLabel($aa4, 382, 140, 35, 15)
GUICtrlSetColor(-1, 000000)

$winnerbox = GUICtrlCreateEdit('', 418, 126, 180, 50, BitOR($ES_WANTRETURN, $ES_READONLY))
$WinnerMsg = 'Winner Gets Photo Finish Bonus ++ X2' & @CRLF & ' Wow that was close and...'


Global $lucko = 1
Global $BonusD = 0
Global $current = 0
GUISetState(@SW_SHOW)


$placeb = 0
While 1

    Sleep(10)
    $Pos = ControlGetPos('', '', $n4)
    $mx = GUIGetMsg()
    Switch $mx
        Case $b1
            If $placeb = 0 Then
                MsgBox(64, 'Betting Rules', 'You have to place a bet on every race sorry no free rides here buddy')
            Else
                If $Pos[0] = 0 Then
                    GUICtrlSetData($winnerbox, '')
                    $mou = MouseGetPos()
                    ToolTip('Ready', $mou[0] + 50, $mou[1])
                    Sleep(500)
                    ToolTip('')
                    ToolTip('Set', $mou[0] + 50, $mou[1])
                    Sleep(500)
                    ToolTip('')
                    ToolTip('Go!!', $mou[0] + 50, $mou[1])
                    Sleep(500)
                    ToolTip('')
                    Timer()
                    cpuspeed()
                    Race()
                Else
                    MsgBox(48, 'No Cheating', 'Please use Restart button to begin')
                EndIf
            EndIf
        Case $RulButton
            rules()
        Case $r1
            $cat = GUICtrlRead($wager)
            $cat = Number($cat)

            If $cat = '' Then
                MsgBox(64, 'Betting Rules', 'You have to place a bet on every race sorry no free rides here buddy')
            Else

                If $Pos[0] > 0 Then
                    MsgBox(64, 'Betting line', 'You cannot bet till this race is over')
                Else
                    $currentg = IniRead($sDir & $tDir, @UserName, 'money', '')
                    $bett = GUICtrlRead($wager)
                    If $currentg > Number($bett - 1) Then
                        IniWrite($sDir & $zDir, @UserName, $Racer1, $bett)
                        Global $placeb = 1
                        GUICtrlSetData($wager, '')
                        GUICtrlSetState($wager, $GUI_DISABLE)
                        $mou = MouseGetPos()
                        ToolTip('Bet Set', $mou[0] + 50, $mou[1])
                        Sleep(500)
                        ToolTip('')
                    Else
                        MsgBox(64, 'Broke Ass', 'You got no funds!')
                    EndIf
                EndIf
            EndIf


        Case $r2
            $cat = GUICtrlRead($wager)
            $cat = Number($cat)

            If $cat = '' Then
                MsgBox(64, 'Betting Rules', 'You have to place a bet on every race sorry no free rides here buddy')
            Else
                If $Pos[0] > 0 Then
                    MsgBox(64, 'Betting line', 'You cannot bet till this race is over')
                Else
                    $currentg = IniRead($sDir & $tDir, @UserName, 'money', '')
                    $bett = GUICtrlRead($wager)
                    If $currentg > Number($bett - 1) Then
                        IniWrite($sDir & $zDir, @UserName, $Racer2, $bett)
                        Global $placeb = 1
                        GUICtrlSetData($wager, '')
                        GUICtrlSetState($wager, $GUI_DISABLE)
                        $mou = MouseGetPos()
                        ToolTip('Bet Set', $mou[0] + 50, $mou[1])
                        Sleep(500)
                        ToolTip('')
                    Else
                        MsgBox(64, 'Broke Ass', 'You got no funds!')
                    EndIf
                EndIf
            EndIf

        Case $r3
            $cat = GUICtrlRead($wager)
            $cat = Number($cat)

            If $cat = '' Then
                MsgBox(64, 'Betting Rules', 'You have to place a bet on every race sorry no free rides here buddy')
            Else
                If $Pos[0] > 0 Then
                    MsgBox(64, 'Betting line', 'You cannot bet till this race is over')
                Else
                    $currentg = IniRead($sDir & $tDir, @UserName, 'money', '')
                    $bett = GUICtrlRead($wager)
                    If $currentg > Number($bett - 1) Then
                        IniWrite($sDir & $zDir, @UserName, $Racer3, $bett)
                        Global $placeb = 1
                        GUICtrlSetData($wager, '')
                        GUICtrlSetState($wager, $GUI_DISABLE)
                        $mou = MouseGetPos()
                        ToolTip('Bet Set', $mou[0] + 50, $mou[1])
                        Sleep(500)
                        ToolTip('')
                    Else
                        MsgBox(64, 'Broke Ass', 'You got no funds!')
                    EndIf
                EndIf
            EndIf

        Case $r4
            $cat = GUICtrlRead($wager)
            $cat = Number($cat)

            If $cat = '' Then
                MsgBox(64, 'Betting Rules', 'You have to place a bet on every race sorry no free rides here buddy')
            Else
                If $Pos[0] > 0 Then
                    MsgBox(64, 'Betting line', 'You cannot bet till this race is over')
                Else
                    $currentg = IniRead($sDir & $tDir, @UserName, 'money', '')
                    $bett = GUICtrlRead($wager)
                    If $currentg > Number($bett - 1) Then
                        IniWrite($sDir & $zDir, @UserName, $Racer4, $bett)
                        Global $placeb = 1
                        GUICtrlSetData($wager, '')
                        GUICtrlSetState($wager, $GUI_DISABLE)
                        $mou = MouseGetPos()
                        ToolTip('Bet Set', $mou[0] + 50, $mou[1])
                        Sleep(500)
                        ToolTip('')
                    Else
                        MsgBox(64, 'Broke Ass', 'You got no funds!')
                    EndIf
                EndIf
            EndIf

        Case $rsh1
            MsgBox(64, 'Shoe Help', 'This upgrade lasts 3 races and boosts attributes + 0.2')
        Case $rsh2
            MsgBox(64, 'Steroid Help', 'This upgrade lasts 1 race and boosts attributes + 1.5')
        Case $rsh3
            MsgBox(64, 'Rock Help', 'This upgrade lasts 2 races and hits a racer with a rock to knocks them backwards, Can be used once per race' & @CRLF & 'You can hit riders by pressing 1,2,3 starting from top to bottom use wisely')
        Case $rsh4
            MsgBox(64, 'Training Help', 'This upgrade lasts until you turn off the game permantly boosts attributes + 1.0')
        Case $rs1
            $oMoney = IniRead($sDir & $tDir, @UserName, 'money', '')
            If $oMoney > 1900 Then
                $lmoney = Number($oMoney - 2000)
                IniWrite($sDir & $tDir, @UserName, 'money', $lmoney)
                GUICtrlSetData($monk, '')
                GUICtrlSetData($monk, $lmoney)
                Global $BonusD = 2
                Global $current = 1
                Global $Bonus = 0.2
                Global $lucko = 0
                lucko()
            Else
                MsgBox(64, 'Broke Ass', 'You got no funds!')
            EndIf
        Case $rs2
            $oMoney = IniRead($sDir & $tDir, @UserName, 'money', '')
            If $oMoney > 3999 Then
                $lmoney = Number($oMoney - 4000)
                IniWrite($sDir & $tDir, @UserName, 'money', $lmoney)
                GUICtrlSetData($monk, '')
                GUICtrlSetData($monk, $lmoney)
                Global $current = 2
                Global $Bonus = 1.5
                Global $BonusD = 0
                Global $lucko = 0
                lucko()
            Else
                MsgBox(64, 'Broke Ass', 'You got no funds!')
            EndIf

        Case $rs3
            $oMoney = IniRead($sDir & $tDir, @UserName, 'money', '')
            If $oMoney > 2999 Then
                $lmoney = Number($oMoney - 3000)
                IniWrite($sDir & $tDir, @UserName, 'money', $lmoney)
                GUICtrlSetData($monk, '')
                GUICtrlSetData($monk, $lmoney)
                Global $current = 3
                Global $BonusD = 1
                Global $lucko = 0
                HotKeySet('{1}', 'knock1')
                HotKeySet('{2}', 'knock2')
                HotKeySet('{3}', 'knock3')
                lucko()
            Else
                MsgBox(64, 'Broke Ass', 'You got no funds!')
            EndIf
        Case $rs4
            $oMoney = IniRead($sDir & $tDir, @UserName, 'money', '')
            If $oMoney > 9999 Then
                $lmoney = Number($oMoney - 10000)
                IniWrite($sDir & $tDir, @UserName, 'money', $lmoney)
                GUICtrlSetData($monk, '')
                GUICtrlSetData($monk, $lmoney)
                Global $Bonus = 1.0
                Global $current = 4
                Global $lucko = 0
                lucko()
            Else
                MsgBox(64, 'Broke Ass', 'You got no funds!')
            EndIf
        Case $gui_event_close
            Exit
    EndSwitch
WEnd


Func End()
    Exit
EndFunc   ;==>End

Func Timer()
    Global $Sec = @SEC
EndFunc   ;==>Timer

Func lucko()
    If $lucko = 0 Then
        GUICtrlSetState($rs1, $GUI_DISABLE)
        GUICtrlSetState($rs2, $GUI_DISABLE)
        GUICtrlSetState($rs3, $GUI_DISABLE)
        GUICtrlSetState($rs4, $GUI_DISABLE)
    Else
        GUICtrlSetState($rs1, $GUI_enABLE)
        GUICtrlSetState($rs2, $GUI_enABLE)
        GUICtrlSetState($rs3, $GUI_enABLE)
        GUICtrlSetState($rs4, $GUI_enABLE)
    EndIf
EndFunc   ;==>lucko

Func Race()

    Global $a = 0, $b = 0, $c = 0, $d = 0
    While ($a < 300) And ($b < 300) And ($c < 300) And ($d < 300)
        $mx = GUIGetMsg()
        $a = $a + Int(Random(0, 1) + $Sb1)
        $b = $b + Int(Random(0, 1) + $Sb2)
        $c = $c + Int(Random(0, 1) + $Sb3)
        ;$d = $d + Int(Random(0, 1) + $Sb4)

        If $mx = $GUI_EVENT_PRIMARYup Then
            rightStep()
        ElseIf $mx = $GUI_EVENT_SECONDARYUP Then
            rightStep()
        EndIf
        $randomove = Random(1, 3, 1)
        If $randomove = 1 Then
            GUICtrlSetPos($n1, $a, 20)
        ElseIf $randomove = 2 Then
            GUICtrlSetPos($n2, $b, 60)
        ElseIf $randomove = 3 Then
            GUICtrlSetPos($n3, $c, 100)
            ;ElseIf $randomove = 4 Then
            ;   GUICtrlSetPos($n4, $d, 140)
        EndIf
        Sleep(20)
    WEnd
    Sleep(1000)
    If $a > 299 Then
        Racer1Wins()
    ElseIf $b > 299 Then
        Racer2Wins()
    ElseIf $c > 299 Then
        Racer3Wins()
    ElseIf $d > 299 Then
        Racer4Wins()
    EndIf
    ;Debug()
    Opt("GUICoordMode", $iOt)
EndFunc   ;==>Race

Func Debug()
    MsgBox(0, '', $a)
    MsgBox(0, '', $b)
    MsgBox(0, '', $c)
    MsgBox(0, '', $d)
EndFunc   ;==>Debug

Func RightStep()
    $uOwn = StringRight(GUICtrlRead($Levi), 1)
    If $uOwn = 1 Then
        Global $uSpeed = $level1
    ElseIf $uOwn = 2 Then
        Global $uSpeed = $level2
    ElseIf $uOwn = 3 Then
        Global $uSpeed = $level3
    ElseIf $uOwn = 4 Then
        Global $uSpeed = $level4
    ElseIf $uOwn = 5 Then
        Global $uSpeed = $level5
    ElseIf $uOwn = 6 Then
        Global $uSpeed = $level6
    EndIf
    ;HotKeySet($LeftS, 'LeftStep')
    $d = $d + $uSpeed + $Bonus
    GUICtrlSetPos($n4, $d, 140)
    ;HotKeySet($RightS)
EndFunc   ;==>RightStep

Func Racer1Wins()
    $rock = 0
    If $d > 296 Then
        GUICtrlSetData($winnerbox, '')
        GUICtrlSetData($winnerbox, $WinnerMsg)
    ElseIf $b > 296 Then
        GUICtrlSetData($winnerbox, '')
        GUICtrlSetData($winnerbox, $WinnerMsg)
    ElseIf $c > 296 Then
        GUICtrlSetData($winnerbox, '')
        GUICtrlSetData($winnerbox, $WinnerMsg)
    EndIf
    $tSec = @SEC
    If $Sec > $tSec Then
        $nSec = 60 - $Sec
        $nSec = $nSec + $tSec
    Else
        $nSec = $tSec - $Sec
    EndIf
    MsgBox(64, 'And the Winner is!', 'The Winner is:' & @CRLF & $Racer1 & @CRLF & 'Time of :' & $nSec)

    ;;========================================
    $win = IniRead($sDir & $tDir, $Racer1, 'Win', '')
    GUICtrlSetData($aw, '')
    GUICtrlSetData($aw, $win + 1)
    IniWrite($sDir & $tDir, $Racer1, 'Win', $win + 1)
    $rtft = IniRead($sDir & $tDir, 'Best', 'Time', '')
    $rtt = StringLeft($rtft, 2)
    If $nSec < $rtt Then
        GUICtrlSetData($recTime, '')
        GUICtrlSetData($recTime, $nSec & ' By:' & $Racer1)
        IniWrite($sDir & $tDir, 'Best', 'Time', $nSec & ' By:' & $Racer1)
    EndIf
    GUICtrlSetData($recTime, $rtft)
    ;Money
    $var = IniReadSection($sDir & $zDir, @UserName)
    For $i = 1 To $var[0][0]
        If $var[$i][0] = $Racer1 Then
            $oMoney = IniRead($sDir & $tDir, @UserName, 'money', '')
            $lmoney = Number($oMoney + $var[$i][1])
            If GUICtrlRead($winnerbox) = '' Then
                GUICtrlSetData($monk, $lmoney)
                IniWrite($sDir & $tDir, @UserName, 'money', $lmoney)
                IniDelete($sDir & $zDir, @UserName)
            Else
                $bb = Number($var[$i][1] * 2)
                $lmoney = Number($lmoney + $bb)
                GUICtrlSetData($monk, $lmoney)
                IniWrite($sDir & $tDir, @UserName, 'money', $lmoney)
                IniDelete($sDir & $zDir, @UserName)
            EndIf
        Else
            $oMoney = IniRead($sDir & $tDir, @UserName, 'money', '')
            $lmoney = Number($oMoney - $var[$i][1])

            GUICtrlSetData($monk, $lmoney)
            IniWrite($sDir & $tDir, @UserName, 'money', $lmoney)

            IniDelete($sDir & $zDir, @UserName)
            If $lmoney = 0 Then
                gameover()
            EndIf
        EndIf
    Next
    Sleep(2000)
    GUICtrlSetState($wager, $GUI_enABLE)
    Global $placeb = 0
    Restart()


    If $BonusD = 0 Then
        Global $Bonus = 0
        Global $lucko = 1
        If $current = 4 Then
            Global $Bonus = 1.0
        EndIf
        HotKeySet('{1}')
        HotKeySet('{2}')
        HotKeySet('{3}')

    Else
        $BonusD = Number($BonusD - 1)
        If $current = 1 Then
            Global $Bonus = 0.2
        ElseIf $current = 2 Then
            Global $Bonus = 1.5
        ElseIf $current = 3 Then
            HotKeySet('{1}', 'knock1')
            HotKeySet('{2}', 'knock2')
            HotKeySet('{3}', 'knock3')

        ElseIf $current = 4 Then
            Global $Bonus = 1.0
        EndIf
    EndIf
    lucko()
EndFunc   ;==>Racer1Wins

Func Racer2Wins()
    $rock = 0
    If $d > 296 Then
        GUICtrlSetData($winnerbox, '')
        GUICtrlSetData($winnerbox, $WinnerMsg)
    ElseIf $a > 296 Then
        GUICtrlSetData($winnerbox, '')
        GUICtrlSetData($winnerbox, $WinnerMsg)
    ElseIf $c > 296 Then
        GUICtrlSetData($winnerbox, '')
        GUICtrlSetData($winnerbox, $WinnerMsg)
    EndIf
    $tSec = @SEC
    If $Sec > $tSec Then
        $nSec = 60 - $Sec
        $nSec = $nSec + $tSec
    Else
        $nSec = $tSec - $Sec
    EndIf
    MsgBox(64, 'And the Winner is!', 'The Winner is:' & @CRLF & $Racer2 & @CRLF & 'Time of :' & $nSec)
    ;;========================================
    $win = IniRead($sDir & $tDir, $Racer2, 'Win', '')
    GUICtrlSetData($bw, '')
    GUICtrlSetData($bw, $win + 1)
    IniWrite($sDir & $tDir, $Racer2, 'Win', $win + 1)
    $rtft = IniRead($sDir & $tDir, 'Best', 'Time', '')
    $rtt = StringLeft($rtft, 2)
    If $nSec < $rtt Then
        GUICtrlSetData($recTime, '')
        GUICtrlSetData($recTime, $nSec & ' By:' & $Racer2)
        IniWrite($sDir & $tDir, 'Best', 'Time', $nSec & ' By:' & $Racer2)
    EndIf
    $rtft = IniRead($sDir & $tDir, 'Best', 'Time', '')
    GUICtrlSetData($recTime, $rtft)
    ;Money
    $var = IniReadSection($sDir & $zDir, @UserName)
    For $i = 1 To $var[0][0]
        If $var[$i][0] = $Racer2 Then
            $oMoney = IniRead($sDir & $tDir, @UserName, 'money', '')
            $lmoney = Number($oMoney + $var[$i][1])
            If GUICtrlRead($winnerbox) = '' Then
                GUICtrlSetData($monk, $lmoney)
                IniWrite($sDir & $tDir, @UserName, 'money', $lmoney)
                IniDelete($sDir & $zDir, @UserName)
            Else
                $bb = Number($var[$i][1] * 2)
                $lmoney = Number($lmoney + $bb)
                GUICtrlSetData($monk, $lmoney)
                IniWrite($sDir & $tDir, @UserName, 'money', $lmoney)
                IniDelete($sDir & $zDir, @UserName)
            EndIf
        Else
            $oMoney = IniRead($sDir & $tDir, @UserName, 'money', '')
            $lmoney = Number($oMoney - $var[$i][1])

            GUICtrlSetData($monk, $lmoney)
            IniWrite($sDir & $tDir, @UserName, 'money', $lmoney)
            IniDelete($sDir & $zDir, @UserName)
            If $lmoney = 0 Then
                gameover()
            EndIf
        EndIf
    Next
    Sleep(2000)
    GUICtrlSetState($wager, $GUI_enABLE)

    Global $placeb = 0
    Restart()

    If $BonusD = 0 Then
        Global $Bonus = 0
        Global $lucko = 1
        If $current = 4 Then
            Global $Bonus = 1.0
        EndIf
        HotKeySet('{1}')
        HotKeySet('{2}')
        HotKeySet('{3}')

    Else
        $BonusD = Number($BonusD - 1)
        If $current = 1 Then
            Global $Bonus = 0.2
        ElseIf $current = 2 Then
            Global $Bonus = 1.5
        ElseIf $current = 3 Then
            HotKeySet('{1}', 'knock1')
            HotKeySet('{2}', 'knock2')
            HotKeySet('{3}', 'knock3')
        ElseIf $current = 4 Then
            Global $Bonus = 1.0
        EndIf
    EndIf
    lucko()
EndFunc   ;==>Racer2Wins

Func Racer3Wins()
    $rock = 0
    If $d > 296 Then
        GUICtrlSetData($winnerbox, '')
        GUICtrlSetData($winnerbox, $WinnerMsg)
    ElseIf $b > 296 Then
        GUICtrlSetData($winnerbox, '')
        GUICtrlSetData($winnerbox, $WinnerMsg)
    ElseIf $a > 296 Then
        GUICtrlSetData($winnerbox, '')
        GUICtrlSetData($winnerbox, $WinnerMsg)
    EndIf
    $tSec = @SEC
    If $Sec > $tSec Then
        $nSec = 60 - $Sec
        $nSec = $nSec + $tSec
    Else
        $nSec = $tSec - $Sec
    EndIf
    MsgBox(64, 'And the Winner is!', 'The Winner is:' & @CRLF & $Racer3 & @CRLF & 'Time of :' & $nSec)
    ;;========================================
    $win = IniRead($sDir & $tDir, $Racer3, 'Win', '')
    GUICtrlSetData($cw, '')
    GUICtrlSetData($cw, $win + 1)
    IniWrite($sDir & $tDir, $Racer3, 'Win', $win + 1)
    $rtft = IniRead($sDir & $tDir, 'Best', 'Time', '')
    $rtt = StringLeft($rtft, 2)
    If $nSec < $rtt Then
        GUICtrlSetData($recTime, '')
        GUICtrlSetData($recTime, $nSec & ' By:' & $Racer3)
        IniWrite($sDir & $tDir, 'Best', 'Time', $nSec & ' By:' & $Racer3)
    EndIf
    $rtft = IniRead($sDir & $tDir, 'Best', 'Time', '')
    GUICtrlSetData($recTime, $rtft)
    ;Money
    $var = IniReadSection($sDir & $zDir, @UserName)
    For $i = 1 To $var[0][0]
        If $var[$i][0] = $Racer3 Then
            $oMoney = IniRead($sDir & $tDir, @UserName, 'money', '')
            $lmoney = Number($oMoney + $var[$i][1])
            If GUICtrlRead($winnerbox) = '' Then
                GUICtrlSetData($monk, $lmoney)
                IniWrite($sDir & $tDir, @UserName, 'money', $lmoney)
                IniDelete($sDir & $zDir, @UserName)
            Else
                $bb = Number($var[$i][1] * 2)
                $lmoney = Number($lmoney + $bb)
                GUICtrlSetData($monk, $lmoney)
                IniWrite($sDir & $tDir, @UserName, 'money', $lmoney)
                IniDelete($sDir & $zDir, @UserName)
            EndIf
        Else
            $oMoney = IniRead($sDir & $tDir, @UserName, 'money', '')
            $lmoney = Number($oMoney - $var[$i][1])

            GUICtrlSetData($monk, $lmoney)
            IniWrite($sDir & $tDir, @UserName, 'money', $lmoney)
            IniDelete($sDir & $zDir, @UserName)
            If $lmoney = 0 Then
                gameover()
            EndIf
        EndIf
    Next
    Sleep(2000)
    GUICtrlSetState($wager, $GUI_enABLE)
    Global $placeb = 0
    Restart()

    If $BonusD = 0 Then
        Global $Bonus = 0
        Global $lucko = 1
        If $current = 4 Then
            Global $Bonus = 1.0
        EndIf
        HotKeySet('{1}')
        HotKeySet('{2}')
        HotKeySet('{3}')

    Else
        $BonusD = Number($BonusD - 1)
        If $current = 1 Then
            Global $Bonus = 0.2
        ElseIf $current = 2 Then
            Global $Bonus = 1.5
        ElseIf $current = 3 Then
            HotKeySet('{1}', 'knock1')
            HotKeySet('{2}', 'knock2')
            HotKeySet('{3}', 'knock3')

        ElseIf $current = 4 Then
            Global $Bonus = 1.0
        EndIf
    EndIf
    lucko()
EndFunc   ;==>Racer3Wins

Func Racer4Wins()
    $rock = 0
    If $a > 296 Then
        GUICtrlSetData($winnerbox, '')
        GUICtrlSetData($winnerbox, $WinnerMsg)
    ElseIf $b > 296 Then
        GUICtrlSetData($winnerbox, '')
        GUICtrlSetData($winnerbox, $WinnerMsg)
    ElseIf $c > 296 Then
        GUICtrlSetData($winnerbox, '')
        GUICtrlSetData($winnerbox, $WinnerMsg)
    EndIf
    $tSec = @SEC
    If $Sec > $tSec Then
        $nSec = 60 - $Sec
        $nSec = $nSec + $tSec
    Else
        $nSec = $tSec - $Sec
    EndIf
    MsgBox(64, 'And the Winner is!', 'The Winner is:' & @CRLF & $Racer4 & @CRLF & 'Time of :' & $nSec)
    ;;========================================
    $win = IniRead($sDir & $tDir, $Racer4, 'Win', '')
    GUICtrlSetData($dw, '')
    GUICtrlSetData($dw, $win + 1)
    IniWrite($sDir & $tDir, $Racer4, 'Win', $win + 1)
    $rtft = IniRead($sDir & $tDir, 'Best', 'Time', '')
    $rtt = StringLeft($rtft, 2)
    If $nSec < $rtt Then
        GUICtrlSetData($recTime, '')
        GUICtrlSetData($recTime, $nSec & ' By:' & $Racer4)
        IniWrite($sDir & $tDir, 'Best', 'Time', $nSec & ' By:' & $Racer4)
    EndIf
    $rtft = IniRead($sDir & $tDir, 'Best', 'Time', '')
    GUICtrlSetData($recTime, $rtft)
    ;Money
    $var = IniReadSection($sDir & $zDir, @UserName)
    For $i = 1 To $var[0][0]
        If $var[$i][0] = $Racer4 Then
            $oMoney = IniRead($sDir & $tDir, @UserName, 'money', '')
            $lmoney = Number($oMoney + $var[$i][1])
            If GUICtrlRead($winnerbox) = '' Then
                GUICtrlSetData($monk, $lmoney)
                IniWrite($sDir & $tDir, @UserName, 'money', $lmoney)
                IniDelete($sDir & $zDir, @UserName)
            Else
                $bb = Number($var[$i][1] * 2)
                $lmoney = Number($lmoney + $bb)
                GUICtrlSetData($monk, $lmoney)
                IniWrite($sDir & $tDir, @UserName, 'money', $lmoney)
                IniDelete($sDir & $zDir, @UserName)
            EndIf
        Else
            $oMoney = IniRead($sDir & $tDir, @UserName, 'money', '')
            $lmoney = Number($oMoney - $var[$i][1])

            GUICtrlSetData($monk, $lmoney)
            IniWrite($sDir & $tDir, @UserName, 'money', $lmoney)
            IniDelete($sDir & $zDir, @UserName)
            If $lmoney = 0 Then
                gameover()
            EndIf
        EndIf
    Next
    Sleep(2000)
    GUICtrlSetState($wager, $GUI_enABLE)
    Global $placeb = 0
    Restart()

    If $BonusD = 0 Then
        Global $Bonus = 0
        Global $lucko = 1
        If $current = 4 Then
            Global $Bonus = 1.0
        EndIf

        HotKeySet('{1}')
        HotKeySet('{2}')
        HotKeySet('{3}')


    Else
        $BonusD = Number($BonusD - 1)
        If $current = 1 Then
            Global $Bonus = 0.2
        ElseIf $current = 2 Then
            Global $Bonus = 1.5
        ElseIf $current = 3 Then
            HotKeySet('{1}', 'knock1')
            HotKeySet('{2}', 'knock2')
            HotKeySet('{3}', 'knock3')

        ElseIf $current = 4 Then
            Global $Bonus = 1.0
        EndIf
    EndIf
    $NextLevel = StringRight(GUICtrlRead($Levi), 1)
    If $NextLevel = 9 Then
        MsgBox(0, 'WOW', 'You won the game')
        Exit
    EndIf
    GUICtrlSetData($Levi, '')
    GUICtrlSetData($Levi, 'Level :' & Number($NextLevel + 1))
    lucko()
EndFunc   ;==>Racer4Wins

Func Restart()
    GUICtrlSetPos($n1, 0, 20)
    GUICtrlSetPos($n2, 0, 60)
    GUICtrlSetPos($n3, 0, 100)
    GUICtrlSetPos($n4, 0, 140)
EndFunc   ;==>Restart

Func knock1()
    $as = ControlGetPos('', '', $n1)
    If $as[0] = 0 Then
        GUICtrlSetData($wager, GUICtrlRead($wager) & 1)
    Else
        Global $a = Number($a - 20)
        GUICtrlSetPos($n1, $a, 20)
        HotKeySet('{1}')
        HotKeySet('{2}')
        HotKeySet('{3}')
    EndIf
EndFunc   ;==>knock1
Func knock2()
    $as = ControlGetPos('', '', $n2)
    If $as[0] = 0 Then
        GUICtrlSetData($wager, GUICtrlRead($wager) & 2)
    Else
        Global $b = Number($b - 20)
        GUICtrlSetPos($n2, $b, 60)
        HotKeySet('{1}')
        HotKeySet('{2}')
        HotKeySet('{3}')
    EndIf
EndFunc   ;==>knock2
Func knock3()
    $as = ControlGetPos('', '', $n3)
    If $as[0] = 0 Then
        GUICtrlSetData($wager, GUICtrlRead($wager) & 3)
    Else
        Global $c = Number($c - 20)
        GUICtrlSetPos($n3, $c, 100)
        HotKeySet('{1}')
        HotKeySet('{2}')
        HotKeySet('{3}')
    EndIf
EndFunc   ;==>knock3

Func gameover()
    FileDelete('C:\Users\' & @UserName & '\Documents\logs\trec2')
    FileDelete('C:\Users\' & @UserName & '\Documents\logs\trer2')
    MsgBox(64, 'Game Over', 'Game Over you ran out of money!')
    Exit
EndFunc   ;==>gameover

Func dbg()
    MsgBox(0, '', $Sb1)
EndFunc   ;==>dbg


Func cpuspeed()
    $uOwnq = StringRight(GUICtrlRead($Levi), 1)
    If $uOwnq = 1 Then
        Global $Sb1 = 0.5
        Global $Sb2 = 0.5
        Global $Sb3 = 0.5
    ElseIf $uOwnq = 2 Then
        Global $Sb1 = 0.6
        Global $Sb2 = 0.6
        Global $Sb3 = 0.6
    ElseIf $uOwnq = 3 Then
        Global $Sb1 = 0.7
        Global $Sb2 = 0.7
        Global $Sb3 = 0.7
    ElseIf $uOwnq = 4 Then
        Global $Sb1 = 0.8
        Global $Sb2 = 0.8
        Global $Sb3 = 0.8
    ElseIf $uOwnq = 5 Then
        Global $Sb1 = 0.9
        Global $Sb2 = 0.9
        Global $Sb3 = 0.9
    ElseIf $uOwnq = 6 Then
        Global $Sb1 = 1.0
        Global $Sb2 = 1.0
        Global $Sb3 = 1.0
    ElseIf $uOwnq = 7 Then
        Global $Sb1 = 1.3
        Global $Sb2 = 1.3
        Global $Sb3 = 1.3
    ElseIf $uOwnq = 8 Then
        Global $Sb1 = 1.6
        Global $Sb2 = 1.4
        Global $Sb3 = 1.4
    ElseIf $uOwnq = 9 Then
        Global $Sb1 = 1.6
        Global $Sb2 = 1.6
        Global $Sb3 = 1.6

    EndIf
EndFunc   ;==>cpuspeed
Func rules()
    MsgBox(64, 'Welcome', 'Welcome to Bored time racers 2' & @CRLF & 'The object of the game is to win 9 races in a row They will progressively get harder so there are bonuses you can buy to help you, for this you need money. To get money you must bet on racers yourself or maybe another racer. Racing bonus are handed out for close finishes You begin to run by aiming over the race track with your mouse and clicking your mouse left and right buttons so double click all you can!' & @CRLF & 'GOOD LUCK!!')
EndFunc   ;==>rules

the ZIP includes source .exe and icons or replace them with your own have fun. Welcome all comments.. PS I know the code is sloppy

Bored Time Racer.zip


[Cheeky]Comment[/Cheeky]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Mayby its just me but, I pressed like all buttons, nothing happens. Only things it says is that "The Race is not over." and "No slots left here buddie.".

Have no idea how to start.

Looks nice though.

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.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

@AlmarM Hey

First, you place a wager then select the racer you want to bet on. after that hit the start button, when it begins using your mouse over the gui start clicking the track to make your guy run fast.

Edited by lordicast

[Cheeky]Comment[/Cheeky]

Share this post


Link to post
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
Sign in to follow this  
Followers 0