Bradness Posted August 25, 2007 Share Posted August 25, 2007 (edited) Hey guys. Just made this neat little script, thought it would amuse someone. Ive never seen a Rock Paper Scissors script, so have fun! expandcollapse popup#include <GUIConstants.au3> #include <GuiConstants.au3> Global $GuiX, $GuiY, $GuiW $GuiH, $NewPlayerScore, $NewCPUScore Global $CPUScore = 0 Global $PlayerScore = 0 Dim $Choose, $Rock, $Paper, $Scissors, $Random, $User, $RPSWords, $RPS $Choose = GUICreate("Rock, Paper, Scissors...", 300, 325) $About = GUICtrlCreateButton("?", 100, 300, 30, 25) $Rock = GUICtrlCreateButton("Rock", 0, 0, 200, 100) $Paper = GUICtrlCreateButton("Paper", 0, 100, 200, 100) $Scissors = GUICtrlCreateButton("Scissors", 0, 200, 200, 100) $Random = GUICtrlCreateButton("Random", 200, 0, 100, 300) $PlayerScoreLabel = GUICtrlCreateLabel("Player Score:" & $PlayerScore, 0, 310) $CPUScoreLabel = GUICtrlCreateLabel("CPU Score:" & $CPUScore, 150, 310) GUICtrlSetOnEvent($Rock, "_Rock") GUICtrlSetOnEvent($Paper, "_Paper") GUICtrlSetOnEvent($Scissors, "_Scissors") GUICtrlSetOnEvent($Random, "_Random") GUICtrlSetOnEvent($About, "_About") GUISetState() While 1 $MSG = GUIGetMsg() Select Case $MSG = $GUI_EVENT_CLOSE _RollUpGui($Choose, 10) Case $MSG = $Rock _Rock() Case $MSG = $Paper _Paper() Case $MSG = $Scissors _Scissors() Case $MSG = $Random _Random() Case $MSG = $About _About() EndSelect WEnd Func _About() MsgBox(0, "About", "Created by Bradness of the AutoIt Forums.") EndFunc ;==>_About Func _Rock() _RPS("Rock") EndFunc ;==>_Rock Func _Paper() _RPS("Paper") EndFunc ;==>_Paper Func _Scissors() _RPS("Scissors") EndFunc ;==>_Scissors Func _RPS($userchoice) Local $anR[16] = ['', 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3] Local $aRPSWords[4] = ['', 'Rock', 'Paper', 'Scisors' ] Return MsgBox(0, "Rock, Paper, Scissors... Shoot!", "Your Choice: " & $userchoice & @CRLF & "Computers Choice: " & $aRPSWords[$anR[Random(1, 15, 1) ]]) If $userchoice = "Rock" Then If $RPSWords = "Rock" Then MsgBox(0, "Rock, Paper, Scissors... Shoot!", "Tie. No Score added to either user.") GUICtrlSetData($CPUScoreLabel, "CPU Score:" & $CPUScore) GUICtrlSetData($PlayerScoreLabel, "Player Score:" & $PlayerScore) ElseIf $RPSWords = "Paper" Then MsgBox(0, "Rock, Paper, Scissors... Shoot!", "CPU Wins.") _Score("C") GUICtrlSetData($CPUScoreLabel, "CPU Score:" & $CPUScore) GUICtrlSetData($PlayerScoreLabel, "Player Score:" & $PlayerScore) ElseIf $RPSWords = "Scissors" Then MsgBox(0, "Rock, Paper, Scissors... Shoot!", "You Win!") _Score("P") GUICtrlSetData($CPUScoreLabel, "CPU Score:" & $CPUScore) GUICtrlSetData($PlayerScoreLabel, "Player Score:" & $PlayerScore) EndIf ElseIf $userchoice = "Paper" Then If $RPSWords = "Paper" Then MsgBox(0, "Rock, Paper, Scissors... Shoot!", "Tie. No Score added to either user.") GUICtrlSetData($CPUScoreLabel, "CPU Score:" & $CPUScore) GUICtrlSetData($PlayerScoreLabel, "Player Score:" & $PlayerScore) ElseIf $RPSWords = "Scissors" Then MsgBox(0, "Rock, Paper, Scissors... Shoot!", "CPU Wins.") _Score("C") GUICtrlSetData($CPUScoreLabel, "CPU Score:" & $CPUScore) GUICtrlSetData($PlayerScoreLabel, "Player Score:" & $PlayerScore) ElseIf $RPSWords = "Rock" Then MsgBox(0, "Rock, Paper, Scissors... Shoot!", "You Win!") _Score("P") GUICtrlSetData($CPUScoreLabel, "CPU Score:" & $CPUScore) GUICtrlSetData($PlayerScoreLabel, "Player Score:" & $PlayerScore) EndIf ElseIf $userchoice = "Scissors" Then If $RPSWords = "Scissors" Then MsgBox(0, "Rock, Paper, Scissors... Shoot!", "Tie. No Score added to either user.") GUICtrlSetData($CPUScoreLabel, "CPU Score:" & $CPUScore) GUICtrlSetData($PlayerScoreLabel, "Player Score:" & $PlayerScore) ElseIf $RPSWords = "Rock" Then MsgBox(0, "Rock, Paper, Scissors... Shoot!", "CPU Wins.") _Score("C") GUICtrlSetData($CPUScoreLabel, "CPU Score:" & $CPUScore) GUICtrlSetData($PlayerScoreLabel, "Player Score:" & $PlayerScore) ElseIf $RPSWords = "Paper" Then MsgBox(0, "Rock, Paper, Scissors... Shoot!", "You Win!") _Score("P") GUICtrlSetData($CPUScoreLabel, "CPU Score:" & $CPUScore) GUICtrlSetData($PlayerScoreLabel, "Player Score:" & $PlayerScore) EndIf EndIf EndFunc ;==>_RPS Func _Random() $UserRPS = Random(1, 15, 1) Switch $UserRPS Case 1 $User = "Rock" Case 2 $User = "Paper" Case 3 $User = "Scissors" Case 4 $User = "Rock" Case 5 $User = "Paper" Case 6 $User = "Scissors" Case 7 $User = "Rock" Case 8 $User = "Paper" Case 9 $User = "Scissors" Case 10 $User = "Rock" Case 11 $User = "Paper" Case 12 $User = "Scissors" Case 13 $User = "Rock" Case 14 $User = "Paper" Case 15 $User = "Scissors" EndSwitch _RPS($User) EndFunc ;==>_Random Func _Score($Who) If $Who = "C" Then $NewCPUScore = $CPUScore + 1 $CPUScore = $NewCPUScore $NewCPUScore = "" ElseIf $Who = "P" Then $NewPlayerScore = $PlayerScore + 1 $PlayerScore = $NewPlayerScore $NewPlayerScore = "" EndIf EndFunc ;==>_Score Func _RollUpGui($hWnd, $step, $delay = "default") Local $GuiClientH, $MinH $GuiClientSize = WinGetClientSize($hWnd) $GuiClientH = $GuiClientSize[1] _GuiGetPos($hWnd) $MinH = $GuiH - $GuiClientH WinMove($hWnd, "", $GuiX, $GuiY, $GuiW, $GuiH) If $delay = "default" Then $delay = ($step * 2) + ($step / 2) Sleep($delay) WEnd For $i = 250 To 0 Step - 10 WinSetTrans($hWnd, "", $i) Sleep(50) Next EndFunc ;==>_RollUpGui Func _GuiGetPos($hWnd) $GuiPos = WinGetPos($hWnd) EndFunc ;==>_GuiGetPos Edited October 29, 2007 by Bradness My Programs:Rock Paper ScissorsMy UDFs:NONE Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted August 25, 2007 Share Posted August 25, 2007 Interesting script! Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
James Posted August 25, 2007 Share Posted August 25, 2007 Add a function which tells you who won. Rock beats scissors Scissors beats paper Paper beats rock Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 25, 2007 Moderators Share Posted August 25, 2007 Some food for thought (you could do this with the other function as well), I'm assuming you are going Random(1,15,1) (to 15) for more of a random option... You could shrink that down (more than this, but I was too lazy to write out the Rock,Paper,Scissors 5 times each).Thisexpandcollapse popupFunc _RPS($userchoice) $RPS = Random( 1, 15, 1 ) Switch $RPS Case 1 $RPSWords = "Rock" Case 2 $RPSWords = "Paper" Case 3 $RPSWords = "Scissors" Case 4 $RPSWords = "Rock" Case 5 $RPSWords = "Paper" Case 6 $RPSWords = "Scissors" Case 7 $RPSWords = "Rock" Case 8 $RPSWords = "Paper" Case 9 $RPSWords = "Scissors" Case 10 $RPSWords = "Rock" Case 11 $RPSWords = "Paper" Case 12 $RPSWords = "Scissors" Case 13 $RPSWords = "Rock" Case 14 $RPSWords = "Paper" Case 15 $RPSWords = "Scissors" EndSwitch MsgBox( 0, "Rock, Paper, Scissors... Shoot!", "Your Choice: " & $userchoice & @CRLF & "Computers Choice: " & $RPSWords ) EndFuncoÝ÷ Ùj.ÖÞrjëh×6Func _RPS($userchoice) Local $anR[16] = ['',1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3] Local $aRPSWords[4] = ['','Rock','Paper','Scisors'] Return MsgBox( 0, "Rock, Paper, Scissors... Shoot!", "Your Choice: " & $userchoice & @CRLF & "Computers Choice: " & $aRPSWords[$anR[Random(1,15,1)]]) EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
martin Posted August 25, 2007 Share Posted August 25, 2007 Hey guys. Just made this neat little script, thought it would amuse someone. Ive never seen a Rock Paper Scissors script, so have fun!Why do you have Random(1,15,1)? I mean why not Random(1,3,1)? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
martin Posted August 25, 2007 Share Posted August 25, 2007 I'm assuming you are going Random(1,15,1) (to 15) for more of a random option..Please tell me you're joking SmOke_N? As a long time admirer of yours, don't do this to me. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
qazwsx Posted August 25, 2007 Share Posted August 25, 2007 I'm assuming you are going Random(1,15,1) (to 15) for more of a random option..That could make sense because autoit does not generate truly random numbers Link to comment Share on other sites More sharing options...
martin Posted August 25, 2007 Share Posted August 25, 2007 (edited) That could make sense because autoit does not generate truly random numbersLooks like I'm getting out-numbered. How does it make sense? Edited August 25, 2007 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 25, 2007 Moderators Share Posted August 25, 2007 Looks like I'm getting out-numbered. How does it make sense?I never said it made sense... just made an assumption on what the OP was thinking.@sccrstvn93Might want to take a look at the source again... Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Bradness Posted August 25, 2007 Author Share Posted August 25, 2007 (edited) UPDATED:Added Score FeaturesAdded AboutCheck First Post! Edited August 25, 2007 by Bradness My Programs:Rock Paper ScissorsMy UDFs:NONE Link to comment Share on other sites More sharing options...
JustinReno Posted August 25, 2007 Share Posted August 25, 2007 you used the roll up gui, thats nice, i included it in my swb Link to comment Share on other sites More sharing options...
Bradness Posted August 26, 2007 Author Share Posted August 26, 2007 Thanks for all the great comments, suprised everyone liked it. ~Brad My Programs:Rock Paper ScissorsMy UDFs:NONE Link to comment Share on other sites More sharing options...
AutoItKing Posted August 26, 2007 Share Posted August 26, 2007 I made something similar to this a few years back. Nice job though! http://www.autoitking.co.nr Site is DOWN | My deviantART | No Topic Topic - Don't do it!-------------------- UDF's/Scripts:AutoIt: [BenEditor 3.6] [_ShutDown()]PHP: [CommentScript]Web Based AutoIt: [MemStats] [HTML to AU3] [User LogIn and SignUp script] Link to comment Share on other sites More sharing options...
Bradness Posted October 28, 2007 Author Share Posted October 28, 2007 (edited) UPDATED:Back with lifeWill TRY to be updated more oftenWorking on updaterTook SmOkE_N's Advice, changed thatCheck first post! Edited October 28, 2007 by Bradness My Programs:Rock Paper ScissorsMy UDFs:NONE Link to comment Share on other sites More sharing options...
Achilles Posted October 28, 2007 Share Posted October 28, 2007 UPDATED:Back with lifeWill TRY to be updated more oftenWorking on updaterTook SmOkE_N's Advice, changed thatCheck first post!It doesn't work for me... I get an error whenever I click on "Paper" "Rock or "Scissors" My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Bradness Posted October 28, 2007 Author Share Posted October 28, 2007 Fixed, but score doesnt work. My Programs:Rock Paper ScissorsMy UDFs:NONE Link to comment Share on other sites More sharing options...
Achilles Posted October 28, 2007 Share Posted October 28, 2007 Fixed, but score doesnt work.I noticed a few things that should be improved:-- Your script doesn't exit (the _RolUpGUI() function needs an Exit statement at the end)-- You have several functions listed as GuiCtrlSetOnEvent(). Those are not doing anything because you need the correct Opt(). My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
zBrad Posted October 28, 2007 Share Posted October 28, 2007 To clear up confusion: Im Bradness. My account got hacked by an old friend... I think, so now I use this account. Link to comment Share on other sites More sharing options...
Bradness Posted October 28, 2007 Author Share Posted October 28, 2007 zBrad is a fraud. im the real bradness! My Programs:Rock Paper ScissorsMy UDFs:NONE Link to comment Share on other sites More sharing options...
Achilles Posted October 28, 2007 Share Posted October 28, 2007 Hmmm... this should prove interesting considering neither of you (if there are indeed two of you) have any proof. Maybe the Mods could check IP's if they get bored enough to.... My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now