[racket] WORLD manipulation doubt

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sun May 4 12:41:05 EDT 2014

You may wish to read the section in HtDP/2e on designing programs: 

 http://www.ccs.neu.edu/home/matthias/HtDP2e/part_one.html#%28part._ch~3ahtdp%29

especially 

 http://www.ccs.neu.edu/home/matthias/HtDP2e/part_one.html#%28part._.D.K._sec~3adesign-world%29

so that you can solve these problems systematically and on your own next time you encounter them. 

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. 

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? 

Now what does it mean to eat food: 
 -- the key handler must consume a state in which food is available 
 -- the key handler must be called when the eater gets close to the food 
 -- the key handler must produce a state where food has been consumed. 

If you are more of a copy-examples learner, see Realm of Racket. -- Matthias





On May 1, 2014, at 1:26 PM, Zee Ken wrote:

> Hi,
> 
> I am creating a game which runs in the below world.
> 
> (define-struct world (myself monster1 monster2 food1 food2))
> 
> The objective of the game is to move yourself in the world, not get hit by monsters and eat the food.
> 
> I am done with 
> 1) Keyboard manipulation of myself, 
> 2) Stopping the game when I hit any of the monsters (monsters move randomly in the world).
> 
> Question1: Placing the food is also an easy task. But, how do I modify the world when I eat the food?
> 
> 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.
> 
> Question2: Also, are there any timer events in racket where I can include a stop clock counting down from a number to zero?
> 
> I am a bit confused as to how I should tackle the idea.
> 
> 
> Best,
> Zeek
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140504/ffe7e866/attachment.html>

Posted on the users mailing list.