cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <html>

<head>
    <title>RPG GAME</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link href="https://fonts.googleapis.com/css?family=Bungee+Inline|Candal|Permanent+Marker|Raleway:500|Reem+Kufi" rel="stylesheet">
</head>

<body>
    <style type="text/css">
    body {
        background-color: teal;
    }
    
    h1,
    h2,
    p {
        font-family: 'Candal', sans-serif;
    }
    
    .jumbotron h1 {
        color: #ccc;
    }
    
    .jumbotron {
        background-color: transparent;
    }
    
    h2 {
        font-size: 25px;
        color: #ccc;
    }
    
    p {
        color: #ccc;
        font-size: 20px;
    }
    </style>
    <div class="jumbotron">
        <div class="container block-center">
            <h1> Welcome to the Rock, Paper, Scissors game!</h1>
            <hr>
            <h2>Press r, p or s to start playing</h2>
        </div>
    </div>
    <div class="container">
        <div id="game">
        </div>
    </div>
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">
    </script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    <script type="text/javascript">
    //sets the computer choices
    var computerChoices = ['r', 'p', 's'];

    //Declates the tallies to 0
    var wins = 0;
    var losses = 0;
    var ties = 0;


    // When the user presses the key it records the keypress and then sets it to userguess
    document.onkeyup = function(event) {
        var userGuess = String.fromCharCode(event.keyCode).toLowerCase();

        //This sets what the computer's guess is and it is equal to a random guess
        var computerGuess = computerChoices[Math.floor(Math.random() * computerChoices.length)];

        if ((userGuess === 'r') || (userGuess === 'p') || (userGuess === 's')) {

            // All win scenarios
            if ((userGuess === 'r') && (computerGuess === 's')) {
                wins++;
            } else if ((userGuess === 'p') && (computerGuess === 'r')) {
                wins++;
            } else if ((userGuess === 's') && (computerGuess === 'p')) {
                wins++;
            }
            // All of the losses
            else if ((userGuess === 'r') && (computerGuess === 'p')) {
                losses++;
            } else if ((userGuess === 'p') && (computerGuess === 's')) {
                losses++;
            } else if ((userGuess === 's') && (computerGuess === 'r')) {
                losses++;
            }
            // Tie scenarios
            else if (userGuess === computerGuess) {
                ties++;
            }
            // Taking the tallies and displaying them in HTML
            var html = "<p>wins: " +
                wins +
                "</p>" +
                "<p>losses: " +
                losses +
                "</p>" +
                "<p>ties: " +
                ties +
                "</p>";

            // Placing the html into the game ID
            document.querySelector('#game').innerHTML = html;

        }
    }
    </script>
</body>

</html>

            
          
!
999px
Loading ..................

Console