Coder Social home page Coder Social logo

vaupunkt / rockpaperscissors Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 11 KB

Rock Paper Scissors Game for TheOdinProject - https://www.theodinproject.com/

Home Page: https://vaupunkt.github.io/rockpaperscissors/

HTML 17.76% JavaScript 55.41% CSS 26.82%
game html javascript rockpaperscissors theodinproject

rockpaperscissors's Introduction

rockpaperscissors

Welcome to my Rock Paper Scissors game! In this game, the user plays against the computer in a classic game of Rock Paper Scissors. In this README file, I will explain how I created the game, including the code and how to play.

To create this game, I followed the instructions provided in The Odin Project's "Foundations: Rock Paper Scissors" lesson. The instructions provided a basic outline of the game and required the use of JavaScript.

I started by creating a basic HTML file that included buttons for the user to select their choice of rock, paper, or scissors. I also created a JavaScript file that contained the functions necessary to run the game.

The first step was to create a function that randomly generates the computer's choice. I used the Math.random() function to generate a random number between 0 and 2, which corresponded to the computer's choice of rock, paper, or scissors.

Next, I created a function that determines the winner of the game. This function takes in both the user's choice and the computer's choice as parameters, compares them, and determines the winner. If the user chooses rock and the computer chooses scissors, the user wins, and so on. If both the user and the computer choose the same option, the game is a tie.

After creating the functions to generate the computer's choice and determine the winner, I added event listeners to the HTML buttons for the user to make their selection. Once the user has made their choice, the computer's choice is generated, and the winner is determined. The game then displays the winner and prompts the user to play again.

Finally, I added some additional features to the game to make it more interactive. For example, I added a score tracker to keep track of the user's wins and losses. I also added a reset button that allows the user to reset the game and start over.

Overall, creating this game was a fun and challenging project. It required the use of JavaScript to generate random numbers and compare user input to the computer's choice. With the addition of a CSS file, the game could be made more visually appealing and engaging.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.