demonsc Posted January 25, 2008 Share Posted January 25, 2008 (edited) Ok well i tried to make a Rock Paper Scissor game but ive come along one problem.. This project is for school btw,, I set up 2 sets of keys for RPS... F1 F2 F3 and NUM1 NUm2 Num3 Looks like this Func rock() $rock = GUICtrlCreatePic(@ScriptDir&"\rock.gif", 220, 100, 67, 77) EndFunc Func paper() $paper = GUICtrlCreatePic(@ScriptDir&"\paper.gif", 220, 165, 67, 77) EndFunc Func scissors() $scissors = GUICtrlCreatePic(@ScriptDir&"\scissors.gif", 220, 235, 67, 77) EndFunc ;DIFFERENT SET OF FUNCTIONS FOR OTHER HAND Func rock1() $rock = GUICtrlCreatePic(@ScriptDir&"\rock.gif", 100, 100, 67, 77) EndFunc Func paper2() $paper = GUICtrlCreatePic(@ScriptDir&"\paper.gif", 100, 165, 67, 77) EndFunc Func scissors3() $scissors = GUICtrlCreatePic(@ScriptDir&"\scissors.gif", 100, 235, 67, 77) EndFunc $rock1 = HotKeySet("{F1}", "rock1") $paper1 = HotKeySet("{F2}", "paper2") $scissors1 = HotKeySet("{F3}", "scissors3") $rock2 = HotKeySet("{NUMPAD1}", "rock") $paper2 = HotKeySet("{NUMPAD2}", "paper") $scissors2 = HotKeySet("{NUMPAD3}", "scissors") I tried to dooo this If $msg = $rock1 and $rock2 Then MsgBox(1, "TIE", "TIE GAME!") EndIf But everytime i run the script the message box comes up with out me even clickin anything.. How do i get it so that If the 2 players push F1 and NUMPAD1 display TIE Game because, Rock can't defeat rock lol... Its driving me crazy! Heres my full source expandcollapse popup;=================================================================================================== == ;Written in AUTOIT ;=================================================================================================== == ;IMPORT STATEMENTS ;============================================ #include <GUIConstants.au3> ;============================================ ;GAME CONSOLE EXTENTIONS ;================================================= HotKeySet("{NUMPAD7}", "close") If WinExists("Game Console CES") = 1 Then MsgBox(1, "Please use Game Console CES", "Game must run with the Game Console before you can play! Run the patch if using source code.") Exit EndIf ;================================================ ;GUI COMPONENTS GuiCreate("RockPaperScissors (CES)", 400, 400) GuiSetState(true) GUISetBkColor(0xAAE771);SETS THE COLOR OF THE GUI TO BE A LIME COLOR GUICtrlCreateLabel("PLAYER 1", 100, 50) GUICtrlCreateLabel("PLAYER 2", 220, 50) $start = GuiCtrlCreateButton("Start", 10, 10) ;================================================ ;================================================ While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit EndIf If $msg = $start Then Game() EndIf WEnd ;FUNCTION LIST Func rock() $rock = GUICtrlCreatePic(@ScriptDir&"\rock.gif", 220, 100, 67, 77) EndFunc Func paper() $paper = GUICtrlCreatePic(@ScriptDir&"\paper.gif", 220, 165, 67, 77) EndFunc Func scissors() $scissors = GUICtrlCreatePic(@ScriptDir&"\scissors.gif", 220, 235, 67, 77) EndFunc ;DIFFERENT SET OF FUNCTIONS FOR OTHER HAND Func rock1() $rock = GUICtrlCreatePic(@ScriptDir&"\rock.gif", 100, 100, 67, 77) EndFunc Func paper2() $paper = GUICtrlCreatePic(@ScriptDir&"\paper.gif", 100, 165, 67, 77) EndFunc Func scissors3() $scissors = GUICtrlCreatePic(@ScriptDir&"\scissors.gif", 100, 235, 67, 77) EndFunc Func Game() $msg = GuiGetMsg() ;SET HotKeySet $rock1 = HotKeySet("{F1}", "rock1") $paper1 = HotKeySet("{F2}", "paper2") $scissors1 = HotKeySet("{F3}", "scissors3") $rock2 = HotKeySet("{NUMPAD1}", "rock") $paper2 = HotKeySet("{NUMPAD2}", "paper") $scissors2 = HotKeySet("{NUMPAD3}", "scissors") MsgBox(1, "Start", "Game Start Now!") EndFunc Func close() Exit EndFunc Edited January 25, 2008 by demonsc Link to comment Share on other sites More sharing options...
demonsc Posted January 25, 2008 Author Share Posted January 25, 2008 All i need to know is how to make a gui recognize that 2 keys are being pushed down?? Link to comment Share on other sites More sharing options...
weaponx Posted January 25, 2008 Share Posted January 25, 2008 (edited) Not trying to steal your show but this is how I would do it: expandcollapse popup#include <GUIConstants.au3> ;Define array with weapon name and element number of weapon it destroys Global $arrayWeapons[3][2] = [["Rock", 2],["Paper", 0],["Scissors", 1]] Global $player1, $player2, $player1complete, $player2Complete $rock1 = HotKeySet("{F1}", "rock1") $paper1 = HotKeySet("{F2}", "paper1") $scissors1 = HotKeySet("{F3}", "scissors1") $rock2 = HotKeySet("{NUMPAD1}", "rock2") $paper2 = HotKeySet("{NUMPAD2}", "paper2") $scissors2 = HotKeySet("{NUMPAD3}", "scissors2") GuiCreate("Rock, Paper, Scissors", 400, 300) GUISetState (@SW_SHOW) $reset = GuiCtrlCreateButton("Reset", 160, 260, 80, 20) ;Player 1 labels GUICtrlCreateLabel ("Player 1:", 30, 30, 160, 60) GUICtrlSetFont (-1,30) $player1status = GUICtrlCreateLabel ("Ready", 200, 30, 150, 60) GUICtrlSetFont (-1,30) ;Player 2 labels GUICtrlCreateLabel ("Player 2:", 30, 100, 160, 60) GUICtrlSetFont (-1,30) $player2status = GUICtrlCreateLabel ("Ready", 200, 100, 150, 60) GUICtrlSetFont (-1,30) ;Winner status label $winner = GUICtrlCreateLabel ("", 0, 200, 400, 60, $SS_CENTER) GUICtrlSetFont (-1,30) ;PLAYER 1 /////////////////////////////////// Func rock1() $player1 = 0 $player1complete = true GuiCtrlSetdata($player1status, "Done") EndFunc Func paper1() $player1 = 1 $player1complete = true GuiCtrlSetdata($player1status, "Done") EndFunc Func scissors1() $player1 = 2 $player1complete = true GuiCtrlSetdata($player1status, "Done") EndFunc ;PLAYER 1 /////////////////////////////////// ;PLAYER 2 /////////////////////////////////// Func rock2() $player2 = 0 $player2complete = true GuiCtrlSetdata($player2status, "Done") EndFunc Func paper2() $player2 = 1 $player2complete = true GuiCtrlSetdata($player2status, "Done") EndFunc Func scissors2() $player2 = 2 $player2complete = true GuiCtrlSetdata($player2status, "Done") EndFunc ;PLAYER 2 /////////////////////////////////// Do If $player1complete AND $player2complete Then ;Update status labels with player choices GuiCtrlSetdata($player1status, $arrayWeapons[$player1][0]) GuiCtrlSetdata($player2status, $arrayWeapons[$player2][0]) ;Tie If $player1 = $player2 Then GuiCtrlSetdata($winner, "TIE GAME") ;If player1 beats player2 ElseIf $arrayWeapons[$player1][1] = $player2 Then GuiCtrlSetdata($winner, "Player 1 Wins") ;If player2 beats player1 (Could just use Else) ElseIf $arrayWeapons[$player2][1] = $player1 Then GuiCtrlSetdata($winner, "Player 2 Wins") EndIf $player1complete = false $player2complete = false EndIf $msg = GUIGetMsg() If $msg = $reset Then GuiCtrlSetdata($player1status, "Ready") GuiCtrlSetdata($player2status, "Ready") GuiCtrlSetdata($winner, "") EndIf Until $msg = $GUI_EVENT_CLOSE Edited January 25, 2008 by weaponx 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