C# - Create Rock Paper Scissors Game

How To Make a Rock Paper Scissors Game In C#

C# Rock Paper Scissors Game Source Code




in this C# tutorial we will see how to design and code a Rock Paper Scissors game using csharp programming language .

tools:
- c# programming language.
- microsoft visual studio express 2013.
- pixabay.com ( to get the images).

Watch This Full Demo



- The Project Source Code


using System;
using System.Collections;
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 rock_paper_scissors_game
{
    public partial class Game_Form : Form
    {
        public Game_Form()
        {
            InitializeComponent();
        }

        // images
        Bitmap rock = Properties.Resources.rock;
        Bitmap paper = Properties.Resources.paper;
        Bitmap scissors = Properties.Resources.scissors;
        Bitmap random_picture;

        // wins
        int player_wins = 0, computer_wins = 0;
        // a list of images
        ArrayList list = new ArrayList();
        // random to get a random image
        Random random = new Random();

        private void Game_Form_Load(object sender, EventArgs e)
        {
            pictureBoxRock.Image = Properties.Resources.rock;
            pictureBoxPaper.Image = Properties.Resources.paper;
            pictureBoxScissors.Image = Properties.Resources.scissors;

            // add images to the list
            list.Add(rock);
            list.Add(paper);
            list.Add(scissors);
        }

        private void pictureBoxRock_Click(object sender, EventArgs e)
        {
            // display rock image
            pictureBox_player.Image = rock;
            // get random image
            random_picture = (Bitmap)list[random.Next(list.Count)];
            // display the random image
            pictureBox_computer.Image = random_picture;
            // get the winner
            getWinner(rock, random_picture);
        }

        private void pictureBoxPaper_Click(object sender, EventArgs e)
        {
            // display paper image
            pictureBox_player.Image = paper;
            // get random image
            random_picture = (Bitmap)list[random.Next(list.Count)];
            // display the random image
            pictureBox_computer.Image = random_picture;
            // get the winner
            getWinner(paper, random_picture);
        }

        private void pictureBoxScissors_Click(object sender, EventArgs e)
        {
            // display rock image
            pictureBox_player.Image = scissors;
            // get random image
            random_picture = (Bitmap)list[random.Next(list.Count)];
            // display the random image
            pictureBox_computer.Image = random_picture;
            // get the winner
            getWinner(scissors, random_picture);
        }


        // create a function to get the winner
        public void getWinner(Bitmap player, Bitmap computer)
        {
            if(player.Equals(computer))
            {
                // it's a draw - the same image
            }
            else if(player.Equals(rock))
            {
                if(computer.Equals(scissors))
                {
                    player_wins++;
                    label_PlayerWins.Text = player_wins.ToString();
                }
                else
                {
                    computer_wins++;
                    label_ComputerWins.Text = computer_wins.ToString();
                }
            }
            else if(player.Equals(paper))
            {
                if(computer.Equals(rock))
                {
                    player_wins++;
                    label_PlayerWins.Text = player_wins.ToString();
                }
                else
                {
                    computer_wins++;
                    label_ComputerWins.Text = computer_wins.ToString();
                }
            }
            else if(player.Equals(scissors))
            {
                if(computer.Equals(paper))
                {
                    player_wins++;
                    label_PlayerWins.Text = player_wins.ToString();
                }
                else
                {
                    computer_wins++;
                    label_ComputerWins.Text = computer_wins.ToString();
                }
            }

        }

    }
}


OUTPUT:

Rock Paper Scissors Game In C#







Free VB.Net Projects Source Code

Download 9 VB.Net Project Source Code

Download VB.Net Project Source Code



here's a list of free vb.net projects source code + video tutorial / demo.

this list contains vb.net games, mini apps, form designs.

if you want to get premium vb.net projects source code click HERE .


 1 - VB.Net Quiz App Project Source Code 

VB.Net Quiz App Project Source Code

How to Make a Simple Quiz App Using Using WindowsForm, Panel, Button and RadioButtons In Visual Basic.Net Programming Language.


 2 - VB.Net Calculator Project Source Code 

VB.Net Calculator Project Source Code

How To Make A Simple Windows Form Calculator Application With Swith  To Do The Basic Operations (+, -, /, *) Using Visual Basic.Net In Visual Studio Editor.


 3 - VB.Net Login And Register Form Design In One Window Source Code 

VB.Net Login And Register Form Design In One Window Source Code

How to Design a Login and Register Form in One windowForm Using VB.Net Programming Language .


 4 - VB.Net Tic Tac Toe Game Source Code 

VB.Net Tic Tac Toe Game Source Code

How To Build A Tic-Tac-Toe Game With Replay And Get The Winner And Change Winning Boxes Color Using VB.Net Programming Language.


 5 - VB.Net Rock Paper Scissors Game Source Code 

VB.Net Rock Paper Scissors Game Source Code

How To Make a Rock Paper Scissors Game Project Using Visual Basic .Net.


 6 - VB.Net Login & Register Form With MySQL DataBase Source Code 

VB.Net Login & Register Form With MySQL DataBase Source Code

How to Create Login and Register Form in Visual Basic.Net with MySQL Database.


 7 - VB.Net Glass Bridge Game From Squid Game Source Code 

VB.Net Glass Bridge Game From Squid Game Source Code

How To Make The Glass Bridge Game From Squid Game In Visual Basic .Net Using Panels and PictureBoxes.


 8 - VB.Net Mini Project With MySQL Database 

VB.Net Mini Project With MySQL Database

VB.Net Mini Project - How To Insert Update Delete Search Display Images In SQL Database .


 9 - VB.Net Guess The Word Game Source Code 

VB.Net Guess The Word Game Source Code

How to Make a Simple Word Guessing Game App In VB.Net Programming Language..








if you want to download Premium VB.Net Projects source code, click on the download button below




Free Java Projects Source Code

Download 12 Java Project Source Code

Free Java Projects Source Code

here's a list of free java projects source code + video tutorial.

this list contains java games, mini apps, form designs.

if you want to get premium java projects source code click HERE .


 1 - JAVA Quiz App Project Source Code 

JAVA Quiz App Project Source Code

How to Make a Simple Quiz App Using  Jframe JPanels and JRadioButtons In Java NetBeans.


 2 - Java Calculator Project Source Code 

Java Calculator Project Source Code

How To Make A Calculator With Swith  To Do The Basic Operations (+, -, /, *) Using Java And Netbeans Editor.


 3 - Java Login And Register Form Design In One Window Source Code 

Java Login And Register Form Design In One Window Source Code

How To Design A Login Form And A Register Form In One Jframe Using JPanels In Java NetBeans .


 4 - Java Tic Tac Toe Game Source Code 

Java Tic Tac Toe Game Source Code

How To Build A Tic-Tac-Toe Game With Replay And Get The Winner And Change Winning Boxes Color Using Java And Netbeans Editor.


 5 - Java Design Login And Dashboard Form 

Java Design Login And Dashboard Form

How To Design A Login Form And A Dashboard Form In Java NetBeans.


 6 - Java Rock Paper Scissors Game Source Code 

Java Rock Paper Scissors Game Source Code

How to Make a Simple Rock, Paper, Scissors Game Using Jframe JPanels and Jlabels In Java NetBeans.


 7 - Java Login & Register Form With MySQL DataBase Source Code 

Java Login & Register Form With MySQL DataBase Source Code

How To Make a Design a Login Form And a Register Form, plus how to connect those two form with mysql database so the user can signup and signin.


 8 - Java Glass Bridge Game From Squid Game Source Code 

Java Glass Bridge Game From Squid Game Source Code

How to Make The Glass Stepping Stones Game or the glass bridge game From Squid Game Using JPanels and Jlabels In Java NetBeans .


 9 - Java Login & Menu Form Design Source Code 

Java Login & Menu Form Design Source Code

How To Design A Login Form And A Drop-Down Menu Form In Java NetBeans .


 10 - Java Guess The Word Game Source Code 

Java Guess The Word Game Source Code

How to Make a Simple Word Guessing Game App In Java NetBeans..


 11 - Java Login & Register Form Design Source Code (2) 

Java Login & Register Form Design Source Code (2)

how to design a login and register form in java netbeans and connect these two forms with mysql database.


 12 - Java Login & Register Form With Text File Source Code 

Java Login & Register Form With Text File Source Code

How To Design a Login And Register Form + how to use those two form with a text file so the user can signup and signin.






if you want to download Premium Java Projects source code, click on the download button below