[CS111 Home Page]
[Syllabus]
[Students]
[Lecture Notes]
[Assignments]
[Programs]
[Documentation]
[Software Installation]
[FAQ]
[CS Dept.]
[CWIS]
CS111 Lab #10: State Variables
You do not need to turn in this lab.
1. Kinetic Sculpture
Last week in lecture you were introduced to state variables, which allow
you to change the state of a particular object. State variables are useful
in any situation in which you need to keep track of a value and update it
at different times. One such situation occurs with animation. To move
an object, you need to keep track of its current position and then update
that position with each time step. Here is an example of some types of
animation you can do by updating different state variables. This
particular example has several bouncing balls, rotating disks, chameleon
squares and pulsating disks.
Kinetic Sculpture:
Creating your own animated figures.
Download the Kinetic folder from the CS111 download folder.
This contains the project file KineticSculpture.proj. Open the
project file, and open the KineticSculpture.java file. This has the
source code for the four types of figures shown above. We will
discuss in lab how each of these figures is updated at each time-step.
The KineticSculpture.java file also contains three dummy
classes:
- Bubble: A circle that rises to the top of the screen, while expanding. When it reaches the top, it starts again at the bottom at the original size.
- SpinningDisk: This figure starts out as a circle, then narrows until it becomes
a single line. It then changes color and expands out to the original size. It repeats
process.
- WrappingBall: This is like the bouncing ball, except when it reaches on edge of the picture it reappears on the opposite edge.
We will implement these three figures in lab. At the end, you should be able
to construct a kinetic sculpture that looks as follows:
You do not need to turn in this lab.