15
Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)

Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)

Embed Size (px)

Citation preview

Page 1: Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)

Programming games

Examples.

Classwork: work and show something of your final project.

Homework: (finish…)

Page 2: Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)

States capitals game

• Demonstrate

Page 3: Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)

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

Page 4: Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)

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.

Page 5: Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)

skier

• Demonstrate

Page 6: Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)

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

Page 7: Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)

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) ….

Page 8: Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)

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!

Page 9: Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)

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.

Page 10: Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)

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 +

Page 11: Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)

Answer

• course = bos+num+"."+section;

Page 12: Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)

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

Page 13: Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)

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.

Page 14: Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)

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

Page 15: Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)

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.