{{lfctrl.headTitleStep1}}

{{lfctrl.headCopyStep1}}

An Email Is Headed
Your Way

We've sent a message
so you can pick a new password.

Reset Your Password

Think of a password that is at least 6 characters long.

Success! You now have a new password.

Please be sure to memorize it or write it in a safe place.



Wait!

Are you sure you want to exit?
Your password will not be reset!

{{lfctrl.notice}}


Wait!

Are you sure you don't want to finish?
You're almost done!

We are missing your email address.

Please enter your or your parent's email address. We will only use your email address to reset your password should you forget it.

Sign Up for Free E-Newsletters

(Optional)

You're Signed up for {{nlctrl.form.newsletters.join(',')}}

The next newsletter will arrive in your inbox within a few weeks.

hey, {{userData.username}}!

Edit Your Profile

SORRY!

You can only put stickers
where you see the dotted
circles.

ADD MY STICKER

WAIT!

You have to sign in,
first!

ALL SERIES
HIDE
MAKE YOUR OWN GAME

Game Codes


 

As we go through the book, we’re going to build a 2D platform game. Below are examples of the code from the book for you to copy and paste — or change! Looking for code from a certain page in the book? Just find the page number in the list below.

IMPORTANT!

When you’re working with your HTML and CSS files, double-clicking them to open them may not work. For example, clicking the HTML file might just open up the web page in your browser, instead of letting you into the code. You might have to tell the computer which program to use. Try right-clicking the file instead and choosing “Open with…”, then picking your text or code editor.

p8 - First program

p31 - Code Sections

p34-35 - The First Lines

p36 - Drawing the World

p38 - Adding Gravity

p39 - Move the Nanonaut down every frame

p39 - Make your Nanonaut land on the ground

p40 - Accelerate your Nanonaut

p41 - Handling input

p42 - Check space key is pressed

p43 - Conditions and variables

p44 - Jumping Nanonaut

p45 - Jumping up and down

p46 - Adding movement

p47 - Going from world space to screen space

p48 - Scrolling background

p48 - Closing the gap

p49 - Fix Nanonaut position

p53 - Running Nanonaut

p54 - Animating the Nanonaut

p55 - Adding background elements

p59 - For loops

p63 - Better bush drawing

p64 - Updating the bushes

p65 - generateBushes ()

p66 - Random numbers

p66 - Random X coordinate

p67 - Generating more bushes

p68 - While command

p71 - Add a robot

p72 - Animated robots running right to left

p75 - Updating robots

p76 - Make new robots appear

p83 - Collision logic

p85 - Screen shake

p86 - Adding player health

p87 - Showing player health

p89 - Game over!

p90 - Scoring