Hi, nice tutorial but there is 1 logical error, and i cant figure out how to fix it lol. Game lets you still play 4th round, but dont record score. I mean after 3rd round should be message box that player or cpu won game, but it lets you play 4th round, score didnt count ant then pops message box
I was wondering if you could help me because this is the project i have been given its similar to this but different Design a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows: (1) When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (2) The user enters his or her choice of “rock,” “paper,” or “scissors” at the keyboard. (3) The computer’s choice is displayed. (4) The program should display a message indicating whether the user or the computer was the winner. If both players make the same choice, the game must be played again to determine the winner.
Hey moo, game is fantastic, I really appreciate your effort to learn us(beginners) how C# works. But, there is a problem which I want to slove. Result in the last turn (3rd), program wont count, for example if it is tied in wins - 1:1, the very last one, no matter who won, CPU or I, result still stay drawn. How to avoid that? Last one is the most important for the final score.
Hi Marko, im really glad you found this tutorial useful. As for your question find this line in the code If( rounds > 1) { checkGame(); } Else.... Etc Change the 1 to a 0 and run the game. See if that fixes the issues with the rounds.
@@mooict Moo, sure it is useful! Thank you for your help, I already tried it (switched 1 with 0), but then I got one more round - fourth (but then one of the players surely wins, without draw, which is good). But, I wish the last round to be a decisive and I like draws, too. For example, if it is 1:1 after 2 rounds, who won the last one, it should be a winner, or it should be a draw if both players got the same sign/simbol. Below is the code, it should work, you have all 3 possible options: 1) player win, 2) draw and 3) CPU win. I wish you all the best.
Do you know how to make when the winner is written in Message box, AI image doesn't open but stays image with question mark.How to make when we declare winner only opens message box without doing it like its a round when round is 0?Thank you
you are using these two lines inputPlayer = Console.ReadLine(); inputPlayer = inputPlayer.ToUpper(); But you can use only one: inputPlayer = Console.Readline().ToUpper();
Hello I appreciate your video I followed it but don't know what I did wrong because no matter the outcome it will always say draw and won't count or change the round. All I get is draw as the result no matter if I have rock and the computer has paper.
It could be the if statements which is checking the choices between the player and the CPU. Check the source from the link in description of this video see if you code matches with that.
Download this project here github.com/mooict/Rock-paper-scissors-game-in-windows-form
Thank you!
Hi, nice tutorial but there is 1 logical error, and i cant figure out how to fix it lol. Game lets you still play 4th round, but dont record score. I mean after 3rd round should be message box that player or cpu won game, but it lets you play 4th round, score didnt count ant then pops message box
I was wondering if you could help me because this is the project i have been given its similar to this but different
Design a program that lets the user play the game of Rock, Paper, Scissors against the
computer. The program should work as follows:
(1) When the program begins, a random number in the range of 1 through 3 is generated.
If the number is 1, then the computer has chosen rock. If the number is 2, then the
computer has chosen paper. If the number is 3, then the computer has chosen scissors.
(2) The user enters his or her choice of “rock,” “paper,” or “scissors” at the
keyboard.
(3) The computer’s choice is displayed.
(4) The program should display a message indicating whether the user or the computer
was the winner. If both players make the same choice, the game must be played again to
determine the winner.
I can give you a hand.
Can you help me fix my draw because everytime i do any of the 3 sometimes it will say draw when their not the same
i did the code for the pls make a choice message box and it just keeps showing that box, and wont let me make an actual choice
did you find a fix?
@@crumbshimself5755 sadly no
42:00 - 45:00 [FULL code]
Hey moo, game is fantastic, I really appreciate your effort to learn us(beginners) how C# works. But, there is a problem which I want to slove. Result in the last turn (3rd), program wont count, for example if it is tied in wins - 1:1, the very last one, no matter who won, CPU or I, result still stay drawn. How to avoid that? Last one is the most important for the final score.
Hi Marko, im really glad you found this tutorial useful. As for your question find this line in the code
If( rounds > 1)
{
checkGame();
} Else.... Etc
Change the 1 to a 0 and run the game. See if that fixes the issues with the rounds.
@@mooict Moo, sure it is useful! Thank you for your help, I already tried it (switched 1 with 0), but then I got one more round - fourth (but then one of the players surely wins, without draw, which is good). But, I wish the last round to be a decisive and I like draws, too. For example, if it is 1:1 after 2 rounds, who won the last one, it should be a winner, or it should be a draw if both players got the same sign/simbol. Below is the code, it should work, you have all 3 possible options: 1) player win, 2) draw and 3) CPU win. I wish you all the best.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace rockpaperscissor
{
public partial class Form1 : Form
{
public int rounds = 3;
public int timePerRound = 6;
string[] AIchoice = { "rock", "paper", "scissor", "rock", "scissor", "paper" };
public int randomNumber;
string command;
Random rnd = new Random();
string playerChoice;
int playerWins = 0;
int AIwins = 0;
public Form1()
{
InitializeComponent();
timer1.Enabled = true;
playerChoice = "none";
}
private void timer1_Tick(object sender, EventArgs e)
{
label6.Text = Convert.ToString(rounds);
timePerRound--;
label4.Text = Convert.ToString(timePerRound);
if (timePerRound < 1)
{
timer1.Enabled = false;
timePerRound = 6;
randomNumber = rnd.Next(0, 5);
command = AIchoice[randomNumber];
switch (command)
{
case "rock":
pictureBox2.Image = Properties.Resources.rock;
break;
case "paper":
pictureBox2.Image = Properties.Resources.paper;
break;
case "scissor":
pictureBox2.Image = Properties.Resources.scissors;
break;
default:
break;
}
if (rounds > 1)
{
checkGame();
}
else
{
decisionEngine();
}
}
}
private void checkGame()
{
if (playerChoice == "rock" && command == "paper")
{
MessageBox.Show("CPU Wins, paper covers rock");
AIwins++;
rounds--;
nextRound();
}
else if (playerChoice == "paper" && command == "rock")
{
MessageBox.Show("Player Wins, paper covers rock");
playerWins++;
rounds--;
nextRound();
}
else if (playerChoice == "paper" && command == "scissor")
{
MessageBox.Show("CPU Wins, scissor cuts paper");
AIwins++;
rounds--;
nextRound();
}
else if (playerChoice == "scissor" && command == "paper")
{
MessageBox.Show("Player Wins, scissor cuts paper");
playerWins++;
rounds--;
nextRound();
}
else if (playerChoice == "scissor" && command == "rock")
{
MessageBox.Show("CPU Wins, rock breaks scissor");
AIwins++;
rounds--;
nextRound();
}
else if (playerChoice == "rock" && command == "scissor")
{
MessageBox.Show("Player Wins, rock breaks scissor");
playerWins++;
rounds--;
nextRound();
}
else if (playerChoice == "none")
{
MessageBox.Show(label1.Text + " make a choice, please!");
nextRound();
}
else
{
MessageBox.Show("Draw");
nextRound();
}
}
private void decisionEngine()
{
if (playerWins > AIwins)
{
label3.Text = "Woo hoo " + label1.Text + " won the game!!! :)";
}
else if(playerWins == AIwins && playerChoice == command)
{
label3.Text = "It's a draw. -_-";
}
else if (playerWins == AIwins && playerChoice == "rock" && command == "scissor")
{
label3.Text = "Woo hoo " + label1.Text + " won the game!!! :)";
}
else if (playerWins == AIwins && playerChoice == "scissor" && command == "paper")
{
label3.Text = "Woo hoo " + label1.Text + " won the game!!! :)";
}
else if (playerWins == AIwins && playerChoice == "paper" && command == "rock")
{
label3.Text = "Woo hoo " + label1.Text + " won the game!!! :)";
}
else
{
label3.Text = "CPU Won the game :(";
}
}
private void nextRound()
{
playerChoice = "none";
pictureBox1.Image = Properties.Resources.qq;
timer1.Enabled = true;
pictureBox2.Image = Properties.Resources.qq;
}
private void button1_Click(object sender, EventArgs e)
{
playerChoice = "rock";
pictureBox1.Image = Properties.Resources.rock;
}
private void button2_Click(object sender, EventArgs e)
{
playerChoice = "paper";
pictureBox1.Image = Properties.Resources.paper;
}
private void button3_Click(object sender, EventArgs e)
{
playerChoice = "scissor";
pictureBox1.Image = Properties.Resources.scissors;
}
private void button4_Click(object sender, EventArgs e)
{
helpScreen help = new helpScreen();
help.Show();
}
}
}
Hey! Can you please tell me how to get the live window for Mac OS? since I can't open a console app with the live window please help me with this :)
unfortunately this format of apps is not supported on Mac operating systems. .Net Framework applications can only be executed on Windows OS.
@@mooict But is it posbile to make on .NET Core which can run on MAC aswell ?
Do you know how to make when the winner is written in Message box, AI image doesn't open but stays image with question mark.How to make when we declare winner only opens message box without doing it like its a round when round is 0?Thank you
Hi, I'm getting same problem. Did you manage to solve it? If so, how did you?
you are using these two lines
inputPlayer = Console.ReadLine();
inputPlayer = inputPlayer.ToUpper();
But you can use only one:
inputPlayer = Console.Readline().ToUpper();
Ah didn't think of that, thank you
ty, made one with avatar
Nice. Well done.
Hello I appreciate your video I followed it but don't know what I did wrong because no matter the outcome it will always say draw and won't count or change the round. All I get is draw as the result no matter if I have rock and the computer has paper.
It could be the if statements which is checking the choices between the player and the CPU. Check the source from the link in description of this video see if you code matches with that.
I had the same issue. Change the last else on the checkGame method to
else if (playerChoice == cpuChoice)
{
MessageBox.Show(“Draw”);
}
the countdown must stop when the round reaches zero.😒