<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>You may wish to read the section in HtDP/2e on designing programs: </div><div><br></div><div> <a href="http://www.ccs.neu.edu/home/matthias/HtDP2e/part_one.html#%28part._ch~3ahtdp%29">http://www.ccs.neu.edu/home/matthias/HtDP2e/part_one.html#%28part._ch~3ahtdp%29</a></div><div><br></div><div>especially </div><div><br></div><div> <a href="http://www.ccs.neu.edu/home/matthias/HtDP2e/part_one.html#%28part._.D.K._sec~3adesign-world%29">http://www.ccs.neu.edu/home/matthias/HtDP2e/part_one.html#%28part._.D.K._sec~3adesign-world%29</a></div><div><br></div><div>so that you can solve these problems systematically and on your own next time you encounter them. </div><div><br></div><div>The key is to decide which actions in the 'real' game to assign to which computational transitions (key events, mouse events, time events, etc). Then you know that the corresponding handler must take care of it. </div><div><br></div><div>At the same time, you need to figure out how to represent items and states of the game from the 'real' world into data representations. What does the world representation look like when someone has eaten food? </div><div><br></div><div>Now what does it mean to eat food: </div><div> -- the key handler must consume a state in which food is available </div><div> -- the key handler must be called when the eater gets close to the food </div><div> -- the key handler must produce a state where food has been consumed. </div><div><br></div><div>If you are more of a copy-examples learner, see Realm of Racket. -- Matthias</div><div><br></div><div><br></div><div><br></div><div><br></div><br><div><div>On May 1, 2014, at 1:26 PM, Zee Ken wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div>Hi,<br><br>I am creating a game which runs in the below world.<br><br><span style="font-family:courier new,monospace">(define-struct world (myself monster1 monster2 food1 food2))</span><br></div><div><br>
</div><div>The objective of the game is to move yourself in the world, not get hit by monsters and eat the food.<br><br></div><div>I am done with <br>1) Keyboard manipulation of <span style="font-family:courier new,monospace"><b>myself</b></span>, <br>
2) Stopping the game when I hit any of the monsters (monsters move randomly in the world).<br><br></div><div><u>Question1:</u> Placing the food is also an easy task. But, how do I modify the world when I eat the food?<br>
<br></div><div>I am thinking of writing a procedure that checks if the user hit a SPACE button and is also near the food. If both of these are true, then that particular food image at the location should disappear and the game should continue.<br>
<u><br></u></div><div><u>Question2:</u> Also, are there any timer events in racket where I can include a stop clock counting down from a number to zero?<br></div><div><br></div><div>I am a bit confused as to how I should tackle the idea.<br>
<br></div><div><br></div><div>Best,<br></div><div>Zeek<br></div></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>