[Newbies] Re: Randomness + Pause/Delay?

michael rice nowgate at yahoo.com
Mon Apr 11 16:01:18 UTC 2011


Nice and clean compared to my "procedural" code (and variables). Would make it much simpler to add a third tower (same endgame conditions), while my code would require a complete rewrite.

I wasn't aware that the Etoys playfield has a timer. Perfect for taking turns.

Thanks.

Michael


--- On Mon, 4/11/11, Bert Freudenberg <bert at freudenbergs.de> wrote:

From: Bert Freudenberg <bert at freudenbergs.de>
Subject: Re: [Newbies] Re: Randomness + Pause/Delay?
To: "michael rice" <nowgate at yahoo.com>
Cc: "A friendly place to get answers to even the most basic questions about Squeak." <beginners at lists.squeakfoundation.org>
Date: Monday, April 11, 2011, 6:40 AM

On 09.04.2011, at 13:28, michael rice wrote:
Here's the Etoys app. Load and press Go button and it will continue game where two players take turns randomly selecting a tower on which to place a blue or red block, each game concluding when both towers are topped with block of the same color.

As you can see, redAction and blueAction appear to happen simultaneously. Ergo, the wish for a means to delay for a tick or two between the two actions.

Michael

The Etoys way would be to do the red and blue actions in alternating ticks. E.g.

However, the *real* Etoys way would be to let the Etoys objects do their work. Your approach is very procedural. It uses many variables and functions instead of objects. It even does the layout in code, calculating x,y coordinates etc.
I am attaching a project that does pretty much the same as yours, but does not need a single variable, and has only 3 simple scripts with about 3 lines each.
- Bert -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20110411/c7bbaa7c/attachment.htm


More information about the Beginners mailing list