<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>This is all wrong even though 'it works' :-) [[see my homepage]]</div><div><br></div><div>1. You need to agree on one set of possible worlds? What states can the world be in? What kind of data describes these states? </div><div><br></div><div>Call this set of data WORLD. </div><div><br></div><div>2. Then you need to design three functions with the following signatures: </div><div><br></div><div> gauge : WORLD -> IMAGE :: renders the world state as an image </div><div> tock: WORLD -> WORLD :: handles a clock event, receives world and produces new world depending on what clock ticks mean</div><div> toets: WORLD KeyEvent -> WORLD :: handles a keyevent, received world plus key event and produced new world depending on what key strokes mean </div><div><br></div><div><br></div><div><br></div><br><div><div>On Mar 18, 2012, at 4:12 PM, ROELOF WOBBEN wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: 'Times New Roman'; font-size: 16px;">Hello, <br _moz_dirty=""><br _moz_dirty="">I have this programm : <br _moz_dirty=""><br _moz_dirty="">; WorldState -> WorldState<br _moz_dirty="">; the clock ticked; decrease the gauge with 0.1<br _moz_dirty="">; example:<br _moz_dirty="">; given: 20, expected 19.9<br _moz_dirty="">; given: 78, expected 77.9<br _moz_dirty="">(define (tock ws) <br _moz_dirty=""> (if (> ws 0) (- ws 0.1)0 ))<br _moz_dirty=""><br _moz_dirty="">; GaugeState -> Gaugestate. <br _moz_dirty="">; display the gauge.<br _moz_dirty="">(define (gauge ws)<br _moz_dirty=""> (overlay/xy (rectangle 100 20 "outline" "black") 0 0 (rectangle ws 20 "solid" "red")))<br _moz_dirty=""><br _moz_dirty=""><br _moz_dirty="">; World -> World <br _moz_dirty="">; adjust the gauge when the user uses the up or down key.<br _moz_dirty="">; given 20 and the down-key expected 20.5<br _moz_dirty="">; given 78 and the up-key expected 78,3 <br _moz_dirty="">(define (toets ws input)<br _moz_dirty=""> (cond<br _moz_dirty=""> [ (key=? input "down") (+ ws 0.3)]<br _moz_dirty=""> [ (key=? input "up") (+ ws 0.5)]<br _moz_dirty=""> [ else ws]<br _moz_dirty=""> ))<br _moz_dirty=""><br _moz_dirty="">(define (main ws)<br _moz_dirty=""> (big-bang ws (on-tick tock) (to-draw gauge) (on-key toets)))<br _moz_dirty=""><br _moz_dirty=""><br _moz_dirty=""><br _moz_dirty="">It runs perfectly but do I understand it right that the variable ws is the same as world.<br _moz_dirty=""><br _moz_dirty="">Roelof<br _moz_dirty=""><br></div>
____________________<br> Racket Users list:<br> <a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br></blockquote></div><br></body></html>