Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)"— Presentation transcript:

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

2 States capitals game Demonstrate

3 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

4 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.

5 skier Demonstrate

6 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

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

8 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!

9 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.

10 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 +

11 Answer course = bos+num+"."+section;

12 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/as 30/simpleso.html

13 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.

14 Map program Request to have mouse move a hole/shadow over a Google Maps. http://faculty.purchase.edu/jeanine.meyer/ html5/mapshadow.htmlhttp://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

15 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.


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

Similar presentations


Ads by Google