Code: Select all
SetWorkingDir %A_ScriptDir%
SetBatchLines -1
Gui Font, s9, Segoe UI
Gui Add, GroupBox, h70 w85, Starts
Gui Add, Radio, xm+5 ym+17 vStart Checked, Random
Gui Add, Radio, y+1, Player
Gui Add, Radio, y+1, Computer
Gui Add, Button, xm-1 y+13 w88 Default gStart, Start
Gui Show, , Window
p1_moves := ["x68 y17", "x106 y17", "x144 y17", "x182 y17", "x220 y17", "x258 y17", "x296 y17", "x296 y55"
, "x296 y93", "x258 y93", "x220 y93", "x182 y93", "x144 y93", "x106 y93", "x68 y93", "x30 y93", "x30 y131"
, "x30 y168", "x68 y168", "x106 y168", "x144 y168", "x182 y168", "x220 y168", "x258 y168", "x296 y168"]
p2_moves := ["x68 y33", "x106 y33", "x144 y33", "x182 y33", "x220 y33", "x258 y33", "x296 y33", "x296 y71"
, "x296 y109", "x258 y109", "x220 y109", "x182 y109", "x144 y109", "x106 y109", "x68 y109", "x30 y109", "x30 y147"
, "x30 y184", "x68 y184", "x106 y184", "x144 y184", "x182 y184", "x220 y184", "x258 y184", "x296 y184"]
return
GuiEscape:
GuiClose:
ExitApp
Start:
Gui, Submit
if (Start = 1)
Random, WhoStarts, 1, 2
else
WhoStarts := Start-1
Turn := WhoStarts
Gui, New
Gui, 2:Default
Gui, Add, Picture, , %A_Desktop%\Track.png
Gui, Add, Radio, w13 h13 x30 y17 ;+38
Gui, Add, Radio, w13 h13 x30 y33 ;+38
Gui, Add, Button, y220 xm gRoll, Roll Dice
Gui, Font, Bold
Gui, Add, Text, x+210 yp+3 +cWhite, Rolled: 0
GUi, Font
GuiControl, , Button%WhoStarts%, 1
Gui, Show, , AHK Tracks
if (Turn = 1)
Gui, Color, Red, White
else
{
Gui, Color, Blue, White
GuiControl, Disable, Button3
Goto, Roll
}
return
Roll:
GuiControl, , Static2, % "Rolled: " Rolled := Dice()
Loop, % Rolled
{
p%Turn% += 1
GuiControl, Move, Button%Turn%, % p%Turn%_moves[p%Turn%]
Sleep, 100
if (p%Turn% > 24)
{
if (Turn = 1)
Msgbox, You've won!
else
Msgbox, I've won!
MsgBox 0x24, , The game has finished. Play again?
ifMsgBox, Yes
Reload
else ifMsgBox, No
ExitApp
ExitApp
}
}
if (p%Turn% = 5 || p%Turn% = 10 || p%Turn% = 15 || p%Turn% = 20)
{
newplace := MysteryCard(p%Turn%)
p%Turn% := Round(newplace)
GuiControl, Move, Button%Turn%, % p%Turn%_moves[p%Turn%]
}
Turn := (Turn = 1) ? 2 : 1
if (Turn = 1)
{
Gui, Color, Red, White
GuiControl, Enable, Button3
}
else
{
Gui, Color, Blue, White
GuiControl, Disable, Button3
Sleep, 1500
Goto, Roll
}
return
Dice(Sides := 6) {
Random, DiceOutput, 1, %Sides%
return DiceOutput
}
MysteryCard(Place) {
Random, rand, 1, 15
Random, rand2, 1, 5
return ((A_Sec*1.18*3.141592/Place*1.5*rand/rand2) > 25) ? Place+Rand/Rand2 : (A_Sec*1.18*3.141592/Place*1.5*rand/rand2)
}