![]() |
![]() |
|
home—info—lectures—exams—hws—archive
Date: Wed, 4 Mar 2009 14:07:22 -0500 To: "Barland, Ian" Subject: Last min questions I was wondering if you could possible go a little more in detail about what the last few things we need to add. for instance kind of laying out what an airplane entails of as well as defining what the world should do or help setting it up. again sorry for being so late on this.
I’ll let people turn hw04 in through next week. (a) The short answer is “write the methods as indicated, on the page describing the game” [eg “write a function process-keys, which takes in ... and returns ...”] (b) Here’s how the ‘big-bang’ simulator works: set W to the initial world you pass in repeat forever: call draw-world(W) wait 1/60th of a second if no key has been pressed, set W to update-world(W) else set W to process-keys(W) (c) We see as a corollary: The only thing that the simulator keeps track of is the single ‘current-world’. So if you want to keep track of three things, your world should better be a struct with three fields. And one of those fields will presumably be a list-of-fires (which contains ‘fire’ structs which in turn each contain their own information). Is that what you’re looking for? --Ian P.S. Here’s the same algorithm sketched as tail recursion, instead of a list: (define (big-bang w) ; I’m ignoring the other args and event handlers (begin (set-display! (draw-world w)) (sleep 1/60) ; Now loop back (tail recursion): (big-bang (if (not (key-press-occurred?)) (update-world w) ; Actually, we call whatever function was given to ‘on-tick-event’ (process-keys w (get-key-event))))) ; Actually, call whatever function was given to ‘on-key-event’ (where I have made up the names ‘set-display!’, ‘sleep’, and ‘key-press-occurred?’; I am not sure what the exact underlying system names are for those functions.)
home—info—lectures—exams—hws—archive
©2009, Ian Barland, Radford University Last modified 2009.Apr.04 (Sat) |
Please mail any suggestions (incl. typos, broken links) to ibarland ![]() |
![]() |