EllipseMorph subclass: #ExerciseBouncingDot
    instanceVariableNames: 'velocity'
    classVariableNames: '' poolDictionaries: ''
    category: 'LearnSqueak-Exercises'.
(Smalltalk at: #ExerciseBouncingDot) compile: 'initialize
    super initialize.
    self color: Color orange; extent: 26@26.
    velocity := 5@3'.
(Smalltalk at: #ExerciseBouncingDot) compile: 'velocity
    ^ velocity'.
(Smalltalk at: #ExerciseBouncingDot) compile: 'velocity: aPoint
    velocity := aPoint'.
(Smalltalk at: #ExerciseBouncingDot) compile: 'stepTime
    ^ 30'.
(Smalltalk at: #ExerciseBouncingDot) compile: 'step
    | next dx dy low high |
    self owner ifNil: [^ self].
    low := self owner position.
    high := self owner bottomRight - self extent.
    next := self position + velocity.
    dx := velocity x. dy := velocity y.
    (next x < low x or: [next x > high x]) ifTrue: [dx := dx negated].
    (next y < low y or: [next y > high y]) ifTrue: [dy := dy negated].
    self position: ((next x max: low x) min: high x)
        @ ((next y max: low y) min: high y).
    velocity := dx@dy'.

[| arena ball |
arena := Morph new color: (Color r: 0.08 g: 0.13 b: 0.22); extent: 400@220.
ball := ExerciseBouncingDot new.
arena addMorph: ball.
ball position: arena position + (30@40).
arena openInWorld.
ball stopStepping.
{arena. ball}] value
