Web Games Development · HTML5 Foundations · ~150 minutes
<!DOCTYPE html>, <html>, <head>, <title>, <body>.<img>) and links (<a>).src, href, width and alt.<script> element and a click handler.Create a folder named Week1 on your PC. For each file below, create it in your editor and copy the
code provided into it, then work through the files in order. Save each file
(Ctrl+S), then refresh the browser. Tick each checkpoint as you go. Copy the image files
from the class website into your Week1 folder.
On your own PC — do this once before starting.
Week1 on your PC.Week1 folder in VS Code or Sublime Text.frog.gif, frogface.gif,
flappingBird.png, purchaseMathCS.png, avivasmugmug.png,
apressshot.png) into your Week1 folder.Week1\
starter.html
simple.html
second.html
third.html
favoriteSites.html
secondSpacedOut.html
myGamePage.html
frog.gif frogface.gif flappingBird.png
purchaseMathCS.png avivasmugmug.png apressshot.png
Week1\starter.html — a complete interactive page to explore first.
starter.html file and open it in your editor.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>My First Web Game Page</title>
</head>
<body>
</body>
</html>
<body>.
<h1>Click the Frog!</h1>
<p>Press the button to score a point.</p>
<div id="score">0</div>
<button onclick="score()">Click me</button>
<br />
<img src="frog.gif" alt="a friendly frog" />
<p>Things I will learn this week:</p>
<ul style="display:inline-block;text-align:left;">
<li>HTML document structure</li>
<li>Elements and attributes</li>
<li>Images and links</li>
<li>A little CSS and JavaScript</li>
</ul>
<style> block in <head>.
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f1e8;
color: #2b2b2b;
text-align: center;
padding: 30px;
}
h1 { color: #1b6b4a; }
#score {
font-size: 64px;
font-weight: bold;
color: #c0392b;
margin: 10px 0;
}
button {
font-size: 18px;
padding: 12px 26px;
border: none;
border-radius: 8px;
background: #1b6b4a;
color: white;
cursor: pointer;
}
button:hover { background: #145238; }
img { margin-top: 18px; }
</style>
<script> with the counter.
<script>
var points = 0;
function score() {
points = points + 1;
document.getElementById("score").textContent = points;
}
</script>
<title>, <h1>, <style> and <script>.Week1\simple.html — the smallest valid page.
simple.html file and notice how little it contains.
<html>
<head>
<title>Very simple example</title>
</head>
<body>
This will appear as is.
</body>
</html>
<!DOCTYPE html> as the first line and lang="en" to <html>.
<!DOCTYPE html>
<html lang="en">
<h1> and a <p> inside <body>.
<h1>Hello</h1>
<p>This will appear as is.</p>
<!-- my first page -->.
<!-- my first page -->
<h1> and <p> appear as a heading and a paragraph.Week1\second.html — images, links and attributes.
second.html and add this scaffold code.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Second example</title>
</head>
<body>
This will appear as is.
</body>
</html>
src and alt.
<img src="frog.gif" alt="a friendly frog" />
width attribute.
<img src="frog.gif" alt="a big frog" width="200" />
href.
<a href="http://www.purchase.edu">Purchase College/SUNY</a>
<a>).
<a href="https://www.purchase.edu/academics/mathematics-computer-science/">
<img src="purchaseMathCS.png" alt="math and computer science" width="300" />
</a>
src, refresh to see the alt text, then fix it.Week1\third.html — embedded CSS and semantic tags.
third.html and add this scaffold code.
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS example</title>
</head>
<body>
</body>
</html>
<style> block and style the body.
<style>
body {
background-color: tan;
color: #660000;
text-align: center;
font-size: 22px;
}
</style>
section rule.
section {
width: 85%;
border: 4px #00FF63 solid;
text-align: left;
padding: 5px;
margin: 10px;
background-color: white;
}
p and aside rules.
p {
width: 75%;
}
aside {
font-style: italic;
}
<section> with an image.
The background here is tan and the text is the totally arbitrary
RED GREEN BLUE value #660000. <br/>
<section>
This section has text--this sentence--and then a paragraph with an image, and text.
<p>
<img src="frogface.gif" alt="frogface model" /> The frogface model can be made to move its jaw.
</p>
</section>
<section> with an image and an <aside> with links.
<section>
As you may have noticed, I like origami.
<p> The next image is a photo of the Flapping Bird, in action.
<br/>
<img src="flappingbird.png" alt="flapping bird" width="200" /> </p>
<aside>
There are many books and websites to learn how to fold the Flapping Bird.
Here is a plug for one of my origami books
<a href="https://origamiusa.org/catalog/products/origami-explanations">Origami with Explanations</a>
... Visit my
<a href="https://www.amazon.com/Jeanine-Meyer/e/B001JPA5SC">Jeanine Meyer Author page</a>.
</aside>
</section>
Week1\favoriteSites.html — articles, styling and a script.
favoriteSites.html and add this scaffold code.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Annotated links</title>
</head>
<body>
<h3>Favorite Sites</h3>
</body>
</html>
<style> block with the article and img rules.
<style>
article {
width: 60%;
text-align: left;
margin: 10px;
border: 2px green double;
padding: 2px;
display: block;
}
img { display: block; }
</style>
<script> that writes the date.
<script>
document.write(Date());
</script>
<article> with a link.
<article>
The <a href="http://www.purchase.edu/">website for Purchase College/State University of New York</a>.
</article>
<article> with a link and a screenshot image.
<article>
The <a href="https://avivameyer.smugmug.com/">Aviva Meyer's photographs</a> site is a collection of photographs.
<img src="avivasmugmug.png" alt="Aviva Meyer's photographs" width="400" />
</article>
<article> with a link and a screenshot image.
<article>
<a href="http://apress.com">Apress publishers</a> is the site for the publishers of this book. <br/>
<img src="apressshot.png" alt="Apress screenshot" width="400" />
</article>
Week1\secondSpacedOut.html — structure vs presentation.
secondSpacedOut.html file and add the messy markup below.
<html>
<head>
<title>Second example Spaced Out</title>
</head>
<body>
This will appear as is. <br/>
<img src="frog.gif"/>
<img src="frog.gif" width="200"/> <br/>
<a href=http://www.purchase.edu>Purchase College/SUNY</a><br/> <br/>
<a href=https://www.purchase.edu/academics/mathematics-computer-science/><img src="purchaseMathCS.png" width="500"/></a>
</body>
</html>
second.html.<!DOCTYPE html> and lang="en".
<!DOCTYPE html>
<html lang="en">
alt on the images.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Second example Spaced Out</title>
</head>
<body>
This will appear as is. <br/>
<img src="frog.gif" alt="frog" />
<img src="frog.gif" alt="big frog" width="200" /> <br/>
<a href="http://www.purchase.edu">Purchase College/SUNY</a><br/><br/>
<a href="https://www.purchase.edu/academics/mathematics-computer-science/">
<img src="purchaseMathCS.png" alt="math and computer science" width="500" />
</a>
</body>
</html>
<!-- Indentation does not change the page: the browser collapses whitespace. -->
Week1\myGamePage.html — copy it, rename it, then build your own page.
myGamePage_yourname.html file (or copy myGamePage.html and rename it) and add the page skeleton.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>My Game</title>
</head>
<body>
</body>
</html>
<title>, and add an <h1>, an intro <p>, an <img> and a link.
<h1>My Game</h1>
<p>This is my first web game page.</p>
<img src="frog.gif" alt="a friendly frog" width="150" />
<p><a href="https://www.w3schools.com/html/" target="_blank">Learn more about HTML</a></p>
.card div with a <ul> of features.
<div class="card">
<h2>Features</h2>
<ul>
<li>Fast</li>
<li>Fun</li>
<li>Free</li>
</ul>
</div>
.card div with an <ol> of steps.
<div class="card">
<h2>How to play</h2>
<ol>
<li>Press start</li>
<li>Score points</li>
<li>Beat the high score</li>
</ol>
</div>
.card) and an id (#score) selector.
<style>
body { background: #0f1420; color: #e8edf7; font-family: Arial, sans-serif; text-align: center; padding: 30px; }
h1 { color: #4f8cff; font-size: 40px; }
#score { font-size: 64px; font-weight: bold; color: #22d3a6; }
.card { background: #1b2436; border: 1px solid #2b3852; border-radius: 12px; padding: 16px; margin: 14px auto; width: 60%; }
</style>
<script> that increases #score.
<div id="score">0</div>
<button id="btn">Click me</button>
<script>
var points = 0;
function score() {
points = points + 1;
document.getElementById("score").textContent = points;
if (points === 10) { alert("Well done, 10 points!"); }
}
document.getElementById("btn").addEventListener("click", score);
</script>
| Criterion | Points | Score |
|---|---|---|
| Valid skeleton (DOCTYPE, html, head, title, body) | 2 | |
| Headings, paragraphs, ul / ol used correctly | 2 | |
| Image and link with src / href / width / alt | 2 | |
| Embedded CSS with element, class and id selectors | 3 | |
| Working click handler / counter | 3 | |
| Content-vs-presentation answers | 2 | |
| Runs with no console errors, named correctly | 1 | |
| Total | 15 |
score as the function name.Progress and quiz scores are also tracked on the Week 1 lab page in the class website.