Abstract:
You will be writing a simple class, FormFun, that
draws a form in the middle of the squeak window and shows a simple
animation in that form.
Details:
We will run your program using:
f := FormFun new.
After executing the above code, the following should happen:
f draw.
A blue rectangle should be drawn with a center in the middle of your
squeak screen and a width and height equal to 1/2 the size of your squeak
window. Hint: Look at the class Display In this square, your
program will animate a yellow circle. Give your circle a radius of 15.
The circle will begin in the center of the square and begin with a
vertical and horizontal velocity of 1. (This means the circle will begin
heading toward the bottom right of your screen because the upper left
corner of your squeak window is 0@0) Each time through your loop you will
update your circles center by it's current velocity. When your circle
encounters any edge of the square, it must "bounce" off. (by negating the
correct velocity)
Your program must run in an infinte loop ([true]whileTrue:...). We will
terminate your program using ctrl-break.
You may write any other classes you feel are neccessary for this lab, as
long as you turn them in with your fileout.
More hints:
Here are some classes to look at:
If you find your circle is animating too fast, you may want to include a
delay in your loop. You can do this using:
(Delay forMilliseconds: 10) wait.
When calculating the location of your circle relative to the squares
borders, you may want to use computeBoundingBox. It is
probably a good idea to fill in your circle using a Pen and setting the
size of the Pen tip using roundNib:.
Click here for a
screen shot of what your program should look like.