A seemingly trivial task!

Andreas Raab andreas.raab
Mon May 5 08:53:40 PDT 2003


Hi Jim,

There are two problems with your script. One is that setting the heading to
180 will not make the ellipse "point back" to where it originally came from
- since you are using a random number in the first place you would have to
set the heading to the inverse (negative value) of the random number you
used to begin with. Secondly, the ellipse will only be redrawn when the
script is finished so you won't see the effect of each "forward by"
individually but rather the composite effect.

Try something like this instead:
	Ellipse's x <- 100 + random 10.
	Ellipse's y <- 100 + random 10.
This will make the ellipse jiggle by 10 pixels around 100,100.

Cheers,
  - Andreas

> -----Original Message-----
> From: owner-squeakland at squeakland.org 
> [mailto:owner-squeakland at squeakland.org] On Behalf Of Jim Ford
> Sent: Monday, April 21, 2003 3:34 PM
> To: Squeakland
> Subject: A seemingly trivial task!
> 
> 
> Hi,
> As a start to a simulation of the transition of states of 
> matter from solid
> to liquid to gas, I want to make an object (molecule) jiggle 
> about a given x
> y point. Using tiles, I've tried:
> 
> Ellipse heading Random 180 (I would expect Random 180 to 
> return an integer
>                            between 1 and 180, but it doesn't 
> - it returns
>                            -180 to +180, but it produces the 
> right effect!)
> Ellipse forward 10
> Ellipse heading 180 (to point back where it came from)
> Ellipse forward 10  (to return to the starting x y)
> 
> What actually happens is that the object rotates randomly (as 
> wanted) about
> a fixed point - but the 'Ellipse forward 10' statements don't 
> get executed
> at all. Is there some preprocessing going on that decides 
> that the net moves
> are nill, so the Ellipse is not moved at all (like curses 
> iirc)? If so, how
> do I get round it (using tiles), please? I've tried inserting 
> delay loops at
> strategic points to attempt to thwart this, also 'Ellipse 
> forward -10' instead
> of rotating it 180, but the preprocessor's smarter than I am!.
> 
> Regards: Jim Ford
> 




More information about the Squeakland mailing list