0

Hi I have the following implemention of step in smalltalk

step
    |dx dy|

    [isPlaying]
    whileTrue:[
        speed := speed - 0.1.
        dx := speed / 15 * 4 * direction cos.
        dy := speed / 15 * 4 * direction sin.
        speed <= 0
        ifTrue:[isPlaying := false. self stopStepping.]
        ifFalse:[
                Transcript show:'(',dx,'@',dy,')';cr.
                whiteBall position: whiteBall position + (dx@dy).
                ].

        ].

    stepTime
        ^2.

and something very weird is happening when I open the transcript window and in the step method I have

Transcript show:'(',dx,'@',dy,')';cr.

the ball rectangle seems moving as an animation but if I close the transcript window and delete the line code

Transcript show:'(',dx,'@',dy,')';cr.

the ball rectangle seems to move right away from position A to position Y Please help why is it happening?

Thank you in advanced

Leandro Caniglia
  • 14,495
  • 4
  • 29
  • 51
user3132295
  • 288
  • 4
  • 23
  • 1
    The `Transcript` call is slowing down the process between each step so you see an animation. When you remove `Transcript`, the steps are done at a very fast rate with much less delay so you don't see animation. It happens too quickly. You'd need some kind of time delay between position changes to see animation. – lurker Jun 29 '16 at 19:06

1 Answers1

2

Ok I got it I just remove the while loop inside the step method and it's working!!!!

user3132295
  • 288
  • 4
  • 23