Skip to content

Instantly share code, notes, and snippets.

@bashbaugh
Created February 24, 2019 20:12
Show Gist options
  • Select an option

  • Save bashbaugh/6a84f4306b83f36d751dbe6e6d6e3066 to your computer and use it in GitHub Desktop.

Select an option

Save bashbaugh/6a84f4306b83f36d751dbe6e6d6e3066 to your computer and use it in GitHub Desktop.
<!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