[Newbies] Animation question

Chris Cunningham cunningham.cb at gmail.com
Thu Oct 12 23:09:55 UTC 2017


Hi Lawson,

Actually smooth animation in Squeak is possible.  The best I've seen is at:
http://www.zogotounga.net/comp/saucers.htm
This is pure squeak/morphic, using stepping.

This isn't to say there aren't issue lurking about, of course.

-cbc

On Thu, Oct 12, 2017 at 3:41 PM, LEnglish <LEnglish5 at cox.net> wrote:

>
>
>
> Because of garbage collection issues, smooth animation in Squeak isn’t
> really possible.
>
> My little OpenGL spaceship firing a missile animation had this annoying
> pause every so-often, as the GC activated and froze the screen.
>
> Was hoping that Craig Latta would release a minimal Spoon image that
> allowed me to load the OpenGL plugin code, because the GC in the minimal
> image took about 1/50th (or less) of the time that the complete image
> takes, but he got sidetracked with his Caffeine project.
>
> Lawson
>
> "Debugging is twice as hard as writing the code in the first place.
>
> Therefore, if you write the code as cleverly as possible, you are,
>
> by definition, not smart enough to debug it."
>
> -Brian Kernighan
>
>
>
>
> On Oct 12, 2017, at 11:18, Bert Freudenberg <bert at freudenbergs.de> wrote:
>
> No, you have to put that test in the step method, because it has to be
> checked every time the position changes.
>
> Or you have to wait until the animation is done before doing the test - it
> does work in your first example with my "hack". It does not work in the
> second example because the forked code is executed after that test (plus
> forking is bad for this anyways).
>
> - Bert -
>
> On Thu, Oct 12, 2017 at 7:39 PM, obrienj <obrienj at protonmail.com> wrote:
>
>> The problem is that I want use something like (self position) >= (120 at 100)
>> ifTrue: [self color: Color yellow] outside of the step method. Even though
>> the morph moves, it's position remains unchanged and the boolean tests
>> false. Hope this makes sense.
>>
>>
>>
>> -------- Original Message --------
>> Subject: Re: [Newbies] Animation question
>> Local Time: October 12, 2017 10:25 AM
>> UTC Time: October 12, 2017 5:25 PM
>> From: bert at freudenbergs.de
>> To: obrienj <obrienj at protonmail.com>, A friendly place to get answers to
>> even the most basic questions about Squeak. <
>> beginners at lists.squeakfoundation.org>
>>
>> On Thu, Oct 12, 2017 at 6:24 PM, obrienj <obrienj at protonmail.com> wrote:
>>
>>> I am having difficulty getting the following example to work using
>>> either delay or step:
>>>
>>> aMorph := Morph new.
>>> aMorph position: (100 at 100).
>>> aMorph openInWorld.
>>> 30 timesRepeat: [aMorph position: aMorph position +(1 at 0). Transcript
>>> show: 'test '; cr.].
>>> (aMorph position) >= (120 at 100) ifTrue: [aMorph color: Color yellow].
>>> Transcript show: 'position: ', aMorph position; cr.
>>>
>>> For example:
>>>
>>> aMorph := Morph new.
>>> aMorph position: (100 at 100).
>>> aMorph openInWorld.
>>> delay := Delay forMilliseconds: 20.
>>> [30 timesRepeat: [aMorph position: aMorph position +(1 at 0). delay
>>> wait.].] fork.
>>> (aMorph position) >= (110 at 100) ifTrue: [aMorph color: Color yellow].
>>> Transcript show: 'position: ', aMorph position; cr.
>>>
>>> In the first example the morph moves, changes color, and the Transcript
>>> shows its final position. However, in the second example the morph moves
>>> but does not change color and the Transcript shows its starting position.
>>>
>>
>> Morphic animation is based on stepping. That means, you don't move a
>> Morph repeatedly in a loop, but Morphic tells your morph to update its
>> position repeatedly.
>>
>> You need to make your own Morph subclass and implement a "step" method.
>> Whenever that method is called, it moves the morph by a little. For
>> example, you could use an existing method called" translateBy:"
>>
>> | aMorph |
>> aMorph := Morph new openInWorld.
>> aMorph startStepping: #transformedBy: at: Time millisecondClockValue
>> arguments: {MorphicTransform offset: -3 @ -3} stepTime: 200.
>>
>> However, it's unlikely no existing method does your specific animation,
>> so you indeed need to implement it, eg
>>
>> step
>>     self position: self position + (1 at 0).
>>     (self position) >= (120 at 100) ifTrue: [self color: Color yellow].
>>
>> So this is the Right Way. Without bad hacks you cannot do meaningful
>> animation from a workspace. There is a hack however: If you insert "World
>> doOneCycle" in the while loop of your first example, it will actually work,
>> because it will redraw the world in each loop. However, this would prevent
>> two objects animating independently, that's why the design calls for the
>> "step" method approach.
>>
>> - Bert -
>>
>>
>>
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/beginners/attachments/20171012/8bc808dd/attachment-0001.html>


More information about the Beginners mailing list