Upload
camilla-martin
View
212
Download
0
Embed Size (px)
Citation preview
Programming games
Examples.
Classwork: work and show something of your final project.
Homework: (finish…)
States capitals game
• Demonstrate
States capitals • This could be countries.• Find a map. Divide it up into individual
instances. NOTE: don't change the origin/registration point of any state. So most states will have origin NOT on/in the state.
• Set up parallel arrays holding– State name– Capital name– neighbors
States capitals
• Use radio buttons for questions.
• Design interface—think about mouse clicks and text area.
• Set up functions for asking question and functions can handling the event of the answer being given.
• Check out tutorial.
skier
• Demonstrate
skier
• Mountain moves. The skier does not move down the mountain.
• Use of arrow moves skier left and right.• Place gates
– Determine how to see if skier misses a gate
• Design decision: stop game immediately or keep score.
• See tutorial.• See source code for iterative design: skier1, skier2,
skier3, skier4
String methods• How do you examine a part of a string?• Suppose you have a variable, course,
coursename, holding something like MAT1420.45 or NME3440.45
• course.substr(0,3) will return "MAT" or "NME"
• Course.substr(3,1) will return "1" or "3"
Is this an upper-level course?
if (Number(course.substr(3,1))>2) ….
substr, continued
• I used this in the radio button video play.
• This worked (only) because I named the buttons according to a pattern (THAT I MADE UP) so that I/my code can detect and use something from the names!
String methods
• There are many, some consistency across different languages.
• There is substr and substring.
• QUIZ: do search to find out difference between these two string methods.
How do you combine strings?
• If variable bos holds "MAT", "NME", etc. and num holds "1420", "3440", etc. and section holds "20", "45", etc. then the full name of a course is ?????
• Answer: use +
Answer
• course = bos+num+"."+section;
SharedObject
• Reprise: a version of cookies. Persistent data on the client computer.– Browser specific.– Used for behavioral marketing.
• Demonstrate.
http://faculty.purchase.edu/jeanine.meyer/as30/simpleso.html
SharedObject
• Store name-value pair
• For complex data, need to do calculations to create one long string– split – Join
• do search to find how these work. They are string methods.
Map program
• Request to have mouse move a hole/shadow over a Google Maps.
• http://faculty.purchase.edu/jeanine.meyer/html5/mapshadow.html
• Issues: – how to put canvas on top of div where the
map goes– how to draw the mask (hint: use
"rgba(r,b,g,.5)"; – how to manage events
Homework
• [Show projects]• [Make proposal for your project]• SHOW YOUR PROJECT
• Study guide to final and come to my office with questions and come to class with questions.