Programming Games - PowerPoint PPT Presentation

About This Presentation
Title:

Programming Games

Description:

... // conversion done Timed events JavaScript provides functions for setting up ... Continue uploading projects to your site Read tutorial, examine code ... – PowerPoint PPT presentation

Number of Views:86
Avg rating:3.0/5.0
Slides: 12
Provided by: Jeani228
Category:

less

Transcript and Presenter's Notes

Title: Programming Games


1
Programming Games
  • Work / finish and show dice game. Extras. Timed
    events.
  • ftp. index file.
  • Homework Catch up and do slide show.

2
Dice game additions
  • Score keeping for dice game can be done using the
    notion of a bankroll, kept as internal variable
    and displayed as part of form.
  • Initial starting amount, sayvar bankr 100
  • On every first moveif (bankrgt10) bankr -
    10 else
  • On every win bankr 20NOTE nothing happens
    when there is a loss.
  • Also need to displaydocument.f.bank.value
    bankr // conversion done

3
Timed events
  • JavaScript provides functions for setting up
    timed events
  • setInterval ('moveit(dx,dy)',500)tid
    setInterval('change()',800)setInterval(change,80
    0)setTimeout(finish,2000) //just happens
    oncetid setInterval(finish,2000)
    clearInterval(tid)

4
Timed events
  • The coding is different, but the underlying
    concept is the same as other events
  • set up handling for event do something,
    generally invoke a function, when something
    happens
  • write the event handler function
  • event can be stopped, for the timing event, that
    means a call to clearInterval using the value set
    by the call to setInterval or setTimeout.

5
Exercises
  • Set up a timed event to be a call to
    "stopgame()" to happen once in 10 seconds? one
    and one half seconds?
  • What do you think stopgame is?
  • Set up timed events to be a call to
    "moveit(dx,dy)" to happen 10 times/second until
    your code stops it?

6
Slide show
  • Use form buttons to start and stop the slide
    show.
  • Starting the slide show is done by a function
    that contains a call to setInterval.
  • Stopping the slide show is done by a function
    that contains a call to clearInterval.
  • The change function advances the slide show using
    a variable sn and then incrementing sn. The sn
    variable is reset back to zero when it reaches
    the endpointing past the end of the array
    holding the names of the slide image files.

7
Reprise Your server site
  • students.purchase.edu
  • Use what is termed an ftp (file transfer
    protocol) program to upload and download files.
  • Filezilla, others
  • If you are or anticipate taking other computer
    classes, make a folder games or pg

8
Server site, cont.
  • Create an index.html file
  • The action by the browser to an incomplete
    address will be to look for an index.html file
  • http//faculty.purchase.edu/jeanine.meyergoes to
    my index.html file.
  • Your index.html files can be simple. Use ltbrgt or
    ltpgt and lt/pgt or ltolgtltligt lt/ligt lt/olgt etc.

9
index.html
  • lthtmlgtltheadgtlttitlegtJeanine's games
    lt/titlegtlt/headgtltbodygtltulgtltligtlta
    href"favoritesites.html"gtMy favorite sites lt/agt
    lt/ligtltligtlta href"cointoss.html"gtCoin
    tosslt/agtlt/ligtlt/ulgtlt/bodygtlt/htmlgt

10
Upload
  • index.html
  • all files for each of your games
  • Make sure they are in the correct folder.
  • NOTE you don't use the web in the address.
  • TEST to see if you get to the index file and then
    if the link to each game works and the game works!

11
Homework
  • finish dice game
  • Continue uploading projects to your site
  • Read tutorial, examine code, acquire image files,
    and complete slide show.
Write a Comment
User Comments (0)
About PowerShow.com