Skip to main content

Part 1: Setting up the Layout

Game Flowโ€‹

The game flow should be:

  1. Web page loads with a form for the user to enter their name.
    • input is required, users cannot proceed without providing their name.
  2. After the user submits their name, a new form appears with an input for Rock, Paper, or Scissors.
    • You can use:
      • select/dropdown
      • OR buttons
      • clickable text (but why would you do that!)
  3. User submits the form with their selection (
    • input is required, they cannot submit it without a selection
  4. CPU Player (Behind the scenes), would:
    • generate a (random) response to play against the user.
    • Compare the selections to determine the winner.
    • Keep a log of selections and winners for each round.
  5. Web page would display the winner.
  6. Show the game log
  7. Reset the form after each round
  8. User should be able to start a new game.

Layout Setupโ€‹

Structure summaryโ€‹

This tree diagram summarizes the body part of the HTML page structure and nesting. Below it, you'll find more details about the different elements.

body
โ””โ”€โ”€ div .container
โ”œโ”€โ”€ h1
โ”œโ”€โ”€ div #welcome-screen
โ”‚ โ”œโ”€โ”€ form #name-form
โ”‚ โ”‚ โ”œโ”€โ”€ div
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ label [for="username"]
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ input #username [name="username"]
โ”‚ โ”‚ โ””โ”€โ”€ button #start-game-button
โ””โ”€โ”€ div #game-screen
โ”œโ”€โ”€ div #score-tally
โ”‚ โ”œโ”€โ”€ p #score
โ””โ”€โ”€ form #game-form
โ”œโ”€โ”€ div
โ”‚ โ”œโ”€โ”€ label [for="user-selection"]
โ”‚ โ”œโ”€โ”€ select #user-selection [name="user-selection"]
โ”‚ โ”‚ โ”œโ”€โ”€ option "Rock"
โ”‚ โ”‚ โ”œโ”€โ”€ option "Paper"
โ”‚ โ”‚ โ””โ”€โ”€ option "Scissors"
โ”œโ”€โ”€ button #go-button
โ””โ”€โ”€ p #game-history
  • Change the web page HTML title to Rock Paper Scissors

  • Inside the <div class="container">, create the following elements nested as follows:

    • <h1> - with a title of Rock Paper Scissors.

    • 2 <div>s with IDs of welcome-screen & game-screen.

    • Inside <div id="welcome-screen">, create the following elements nested as follows:

      • <form> - with an id of name-form

        • <div>

          • <label> - with:
          • <input> - with:
            • placeholder text of Enter Name Here....
            • id of username
            • name property of username
        • <button> - with:

          • the text of Start Game!.
          • id of start-game-button
    • Inside <div id="game-screen">, create the following elements nested as follows:

      • <div> - with an id of score-tally.
        • <p> - with id of score and text of User: 0 v CPU: 0
          • Tip: Emmet abbreviation for a div with an id of score-tally and a paragraph with id of score is #score-tally>p#score.
      • <form> - with an id of game-form
        • <div>
          • <label> - with:
          • <select> - with:
            • id of user-selection
            • name of user-selection
            • 3 <option>s for Rock, Paper, & Scissors
            • Tip: use the Emmet abbreviation: select#user-selection>option*3
        • <button> - with:
          • the text of Go!.
          • id of go-button
      • <p> - with an id of game-history

Checkpointโ€‹

It should now look like this.

initial look

I think We can do a little better.