<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' :-) &nbsp;[[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?&nbsp;</div><div><br></div><div>Call this set of data WORLD.&nbsp;</div><div><br></div><div>2. Then you need to design three functions with the following signatures:&nbsp;</div><div><br></div><div>&nbsp;gauge : WORLD -&gt; IMAGE &nbsp;:: renders the world state as an image&nbsp;</div><div>&nbsp;tock: &nbsp; &nbsp; WORLD -&gt; WORLD :: handles a clock event, receives world and produces new world depending on what clock ticks mean</div><div>&nbsp;toets: &nbsp; &nbsp;WORLD KeyEvent -&gt; WORLD :: handles a keyevent, received world plus key event and produced new world depending on what key strokes mean&nbsp;</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 -&gt; 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="">&nbsp; (if (&gt; ws 0) (- ws 0.1)0 ))<br _moz_dirty=""><br _moz_dirty="">; GaugeState -&gt; Gaugestate. <br _moz_dirty="">; display the gauge.<br _moz_dirty="">(define (gauge ws)<br _moz_dirty="">&nbsp; (overlay/xy (rectangle&nbsp; 100 20 "outline" "black") 0 0 (rectangle ws 20 "solid" "red")))<br _moz_dirty=""><br _moz_dirty=""><br _moz_dirty="">; World -&gt; 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="">&nbsp; (cond<br _moz_dirty="">&nbsp;&nbsp;&nbsp; [ (key=? input "down") (+ ws 0.3)]<br _moz_dirty="">&nbsp;&nbsp;&nbsp; [ (key=? input "up") (+ ws 0.5)]<br _moz_dirty="">&nbsp;&nbsp;&nbsp; [ else ws]<br _moz_dirty="">&nbsp;&nbsp;&nbsp; ))<br _moz_dirty=""><br _moz_dirty="">(define (main ws)<br _moz_dirty="">&nbsp;&nbsp; (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> &nbsp;Racket Users list:<br> &nbsp;<a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br></blockquote></div><br></body></html>