©2007 Felleisen, Proulx, et. al.
Pong Game
Work out the Pong Game problem in Lab 4.
Morphing a Polygon
Design the following methods for the classes that represent polygon data that you have defined in the previous two assignments:
Count the number of points in the polygon. (Method name
count
)
Produce a morphed polygon from two original ones, with the
given morphing factor (a number between 0.0and 1.0). Make sure
you follow the one task, one method rule. (Method name
morphPoly
)
Produce a polygon moved by the given distance dx
and dy
from the given polygon.
Draw the polygon on the Canvas c
. (Method name
drawPoly
) Use a sample
program that
uses the draw
library as a guide - or consult the
Help Desk.
Design the class that represents a World
that contains two
polygons (the start and the finish polygon) and keeps
track of the elapsed time.
Define the method currentPoly
that produces the
current polygon based on the elapsed time. This is a
follow up on an earlier homework problem.
Define the method draw
that draws the current image
of the world — i.e the current polygon.
Define the onTick
method for this world.
Define the onKeyEvent
method that responds to the
"up", "down", "left", and "right" key events by moving the
polygons 3 pixels in the indicated direction. Note: You
must move both the start and the finish polygons.
You can now run your world, using the World
’s
bigBang
method. It you do so, comment out the code
before submitting.