## [HELP] Bouncing ball problem

Adam Bloom admanb at hotmail.com
Sun Oct 8 19:24:47 UTC 2000

```

>From: Joshua Channing Gargus <schwa at cc.gatech.edu>
>Reply-To: squeak at cs.uiuc.edu
>To: squeak at cs.uiuc.edu
>Subject: Re: [HELP] Bouncing ball problem
>Date: Sun, 8 Oct 2000 13:59:36 -0400

That worked, and I understand HOW it worked. Thanks all!

P.S. path and bounce are instance not local variables.

Adam

>Hi Adam,
>
>What Je77 is saying is that your line
>1 to: 5 do: ["stuff"]
>is not adding one bounce each time, as you expect it to.
>Instead, each loop iteration gives (2n + 1) bounces, where
>"n" is the number of bounces in the previous iteration.
>
>Try this instead:
>
>#TestMorph Method
>startAnimation
>     | path bounce |
>
>     path := OrderedCollection new.
>     bounce := OrderedCollection new.
>
>     0 to: 29 do: [:i | bounce add: self position + (0@(i squared / 5.0))].
>     bounce := bounce, bounce reversed.
>
>     5 timesRepeat: [path := path, bounce].
>     self startStepping.
>
>
>Good luck,
>Schwa
>
> > > > #TestMorph Method
> > > > startAnimation
> > > >     path := OrderedCOllection new.
> > > >     0 to: 5 do: "This is the part that is supposed to make it bounce
>5
> > > > times"
> > > >     [:h | 0 to: 29 do: [:i | path add: self position + (0@(i squared
>/
> > > > 5.0)))]. "This makes it go"
> > > >     path := path, path reversed]. "This makes it go up and down"
> > > >     self startStepping.
>
>
>On Sun, Oct 08, 2000 at 05:28:28PM +0000, Adam Bloom wrote:
> >
> >
> >
> > >From: "Jochen F. Rick" <nadja at cc.gatech.edu>
> > >Reply-To: squeak at cs.uiuc.edu
> > >To: squeak at cs.uiuc.edu
> > >Subject: Re: [HELP] Bouncing ball problem
> > >Date: Fri, 6 Oct 2000 17:01:13 -0400
> > >
> > >Hello Adam,
> > >
> > >I think it isn't infinite. It's just really long.
> > >The first time you do '0 to 29' thing, you get a half bounce. 'path :=
> > >path, path reversed' gives you a full bounce.
> >
> > Your right its not infinite.
> >
> > >You can fix this in several ways. One way to change this might be call
> > >the first full bounce just a bounce. Then, you could do
> > >
> > >  path := OrderedCollection new.
> > >  1 to: 5 do: [:i | path := path, bounce].
> >
> > Do you mean create bounce as a method? I tried that but it doesn't work.
> > (If you copy everything in from John Maloneys tutorial you can try it
> > yourself)
> >
> > Adam
> >
> > >
> > >On Fri, Oct 06, 2000 at 07:28:39PM +0000, Adam Bloom wrote:
> > > > This may seem like a elementary problem to most of you, however its
>not
> > >to
> > > > me, I'm working with the "TestMorph" that is created in John
>Maloney's
> > > > Morphic tutorial, I'm trying to make it bounce five times, however
>it
> > >just
> > > > bounces on forever, heres the code
> > > >
> > > > #TestMorph Method
> > > > startAnimation
> > > >     path := OrderedCOllection new.
> > > >     0 to: 5 do: "This is the part that is supposed to make it bounce
>5
> > > > times"
> > > >     [:h | 0 to: 29 do: [:i | path add: self position + (0@(i squared
>/
> > > > 5.0)))]. "This makes it go"
> > > >     path := path, path reversed]. "This makes it go up and down"
> > > >     self startStepping.
> > > >
> > > > Any help?
> > > >
> > > > Adam
> > > >
> >
> >_________________________________________________________________________
> > > > Get Your Private, Free E-mail from MSN Hotmail at
> > >http://www.hotmail.com.
> > > >
> > > > Share information about yourself, create your own public profile at
> > > > http://profiles.msn.com.
> > >
> >
> >
>_________________________________________________________________________
> > Get Your Private, Free E-mail from MSN Hotmail at
>http://www.hotmail.com.
> >
> > Share information about yourself, create your own public profile at
> > http://profiles.msn.com.
> >
>

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at
http://profiles.msn.com.

```

More information about the Squeak-dev mailing list