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
<canvas width="600" height="200"></canvas> | |
<script> | |
let cx = document.querySelector("canvas").getContext("2d"); | |
cx.clearRect(0, 0, 600, 200); | |
const drawTrapezoid = (cx, x, y, width, height, indent) => { | |
cx.beginPath(); | |
cx.moveTo(x + indent, y); | |
cx.lineTo(x - indent + width, y); | |
cx.lineTo(x + width, y + height); | |
cx.lineTo(x, y + height); |
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
<link rel="stylesheet" href="css/game.css"> | |
<style>.monster { background: purple }</style> | |
<body> | |
<script> | |
// Complete the constructor, update, and collide methods | |
class Monster { | |
constructor(pos, speed, chase) { | |
this.pos = pos; | |
this.speed = speed; |
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
<link rel="stylesheet" href="css/game.css"> | |
<body> | |
<script> | |
function trackKeys(keys) { | |
let down = Object.create(null); | |
function track(event) { | |
if (keys.includes(event.key)) { | |
down[event.key] = event.type == "keydown"; | |
event.preventDefault(); |
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
<link rel="stylesheet" href="css/game.css"> | |
<body> | |
<script> | |
// The old runGame function. Modify it... | |
async function runGame(plans, Display) { | |
let lives = 3; | |
for (let level = 0; level < plans.length;) { | |
console.log('lives:', lives); | |
let status = await runLevel(new Level(plans[level]), |
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
<style> | |
button { | |
background-color: whitesmoke; | |
} | |
.selected { | |
background-color: white; | |
} | |
</style> | |
<tab-panel> | |
<div data-tabname="one">Tab one</div> |
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
<style> | |
.trail { /* className for the trail elements */ | |
position: absolute; | |
height: 6px; width: 6px; | |
border-radius: 3px; | |
background: teal; | |
} | |
body { | |
height: 300px; | |
} |
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
<p>🎈</p> | |
<script> | |
let baloon = document.querySelector('p'); | |
let fontSize = 16; | |
let fontUnit = 'px'; | |
function increaseFontSizeOfElement(node, percentage) { | |
fontSize += fontSize * percentage; | |
node.style.fontSize = fontSize + fontUnit; | |
}; |
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
<style>body { min-height: 400px }</style> | |
<img src="img/cat.png" id="cat" style="position: absolute"> | |
<img src="img/hat.png" id="hat" style="position: absolute"> | |
<img src="img/hat.png" id="hat2" style="position: absolute"> | |
<script> | |
let cat = document.querySelector("#cat"); | |
let hat = document.querySelector("#hat"); | |
let angle = 0; |
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
<h1>Heading with a <span>span</span> element.</h1> | |
<p>A paragraph with <span>one</span>, <span>two</span> | |
spans.</p> | |
<script> | |
function byTagName(node, tagName) { | |
let nodes = []; | |
tagName = tagName.toLowerCase(); | |
function addMatchingChildNodes(node) { |
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
<h1>Mountains</h1> | |
<div id="mountains"></div> | |
<script> | |
const MOUNTAINS = [ | |
{name: "Kilimanjaro", height: 5895, place: "Tanzania"}, | |
{name: "Everest", height: 8848, place: "Nepal"}, | |
{name: "Mount Fuji", height: 3776, place: "Japan"}, | |
{name: "Vaalserberg", height: 323, place: "Netherlands"}, |