Created
February 24, 2019 20:12
-
-
Save bashbaugh/6a84f4306b83f36d751dbe6e6d6e3066 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>JavaScript Game</title> | |
| </head> | |
| <body onload="init()"> | |
| <h1>JavaScript Game</h1> | |
| <p>Here is a simple JavaScript game:</p> | |
| <canvas id="c" width="400" height="400"></canvas> | |
| <script> | |
| console.log("Starting the script!"); | |
| let canvas_element = document.getElementById("c"); | |
| let canvas = canvas_element.getContext("2d"); | |
| function init() | |
| { | |
| draw_background(); | |
| canvas.fillStyle = "#FFFFFF"; | |
| canvas.font = "25px Arial"; | |
| canvas.fillText("Press the up arrow to start", 40, 200); | |
| } | |
| function draw_background() | |
| { | |
| canvas.clearRect(0, 0, canvas_element.width, canvas_element.height); | |
| canvas.fillStyle = "#1EBA00"; | |
| canvas.fillRect(0, 0, canvas_element.width, canvas_element.height); | |
| } | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment