Hi,

Please help me, this is my activity the Rock, Paper and Scissors Game, I need codes for this game. Like the game the program should determine the winner. In my output (please see attached), the Player1 and Player 2 should choose each a hand gestures in commands buttons: rock, paper and scissors and when we click the command button “Let’s fight” the winner should appear in the Label Results in lower part of the form.

Please help me with the codes.

Many thanks and God bless.

:)

Recommended Answers

All 4 Replies

Hmmm... The choice of game you have decided upon gives me great concern but after reading what you wrote I understand that this is more of an excercise for you than an actual project. So with that said, all you need to do is to build a decision tree that test the values of each players input to decide the winner...

Good Luck

Hmmm, thanks for the rply... but I need a codes... Can you help me with this one.. Thanks....

No I cannot help you by giving you code but I can help you define your problem so you know what code to write!!!

Okay, you have two players and two sets of controls. So what you will need is two variables. One each for each player. Then you will need to set each variables value in the click event of one or the other set of controls. Meaning Variable one's value will be set with group one's controls and variable two's value will be set with the other group's controls.

something like this pseudo code...

in player1's rock button click event...
v1=1
or in player2's rock button click event...
v2 = 1
and so on for both in paper (v1/v2=2) and scissors (v1/v2=3)

Then of course you will need to evaluate who won the battle but instead of creating the same code in each players buttons click event, you would want to create a seperate procedure to do the evaluation and call it from each click event, which also means that player1 and player2 variables need to be declare in the general declaration section of the form so that they are visible throughout the form.

Okay, so the procedure you need to create could go something like this pseudo code...

if v1=v2 then
'tie
msgbox "Tie, try again!"
v1=0 'reset variables
v2=0
elseif v1=1 and v2=2 '1=rock, 2=paper
notify here
reset here
elseif v1=1 and v2=3 '1=rock, 2=scissors
notify here
reset here
elseif v1=2 and v2=1 '1=paper, 2=rock
notify here
reset here
...
else
'do nothing as v1 might equal value from 1 to 3 while player2 has not yet made their choice and so v2=0 presently or vise-a-versa


Good Luck

ok thx.... sorry for the late reply... thx a lot, it such a big help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.