Resources
- //HTML: Converting to unicode characters
- //INPUT: Read element positions
- //INPUT: Reading keypresses
-
//PROCESS:
if...else
conditionals - //OUTPUT: Changing an element's position
- //OUTPUT: Changing an image
- //STYLE: Use descriptive variable names
- More image resources here.
- - http://drapak.ca/cpg/img/link-up.png
- - http://drapak.ca/cpg/img/link-down.png
- - http://drapak.ca/cpg/img/link-left.png
- - http://drapak.ca/cpg/img/link-right.png
Hint: you will start with one image of link, and then change the
.src
to make it face a new direction.
Saving your work
Use Save as...
to save the
empty template as
"2.09H-KeyboardMotionControl-LastName.html
"
in your Computer Programming 12 directory.
The assignment
Create a program that allows moves an image around the screen and changes the image using the keyboard. Check out the example below. Or check out a vehicle counter. Or a pacman shooter.
Hint:
Remember NOT to use .offsetBottom
or .offsetRight
.
Evaluation
-
___/10 INPUT: including ANY FOUR of:
- make things happen when you click on them
- make things happen an input changes
- listen for keypresses
- read which key is pressed
- read current top position
- read current left position
-
___/10 PROCESS: including ANY FOUR of:
- declaring a variable
- finding the integer or floating decimal of a string
- use math to determine positions
- use
if...else
statements to control flow of code - use string addition to combine things
- have up and down movement working correctly
- have left and right movement working correctly
-
___/10 OUTPUT: including ANY FOUR of:
- set the position mode so things can move
- change the left position of something
- change the top position of something
- change a image
- output information with innerHTML
-
___/10 STYLE:
- add your name to the filename
- write your name as the author
- update the change log
- correctly indent everything
- use lowercase for all your HTML tags
- use camelCase for all your ids and classes
- avoid lines greater than 96 characters in length
- restrict your style code to the head of your HTML file
- space out your mathematical operators
- write comments for your if statements
- use descriptive variable names
For example
W ↑ | ||
← A | Let's move link around! | D → |
S ↓ |