| 6.170 | Laboratory in Software Engineering Fall 2002 Final Project Amendment: Gizmopong |
Contents:
Your task is to extend Gizmoball to support two new types of gizmos -- a paddle and a collapsing square -- and to support multiple actions for a given gizmo.
Paddles are either horizontal paddles or vertical paddles. A horizontal paddle has a bounding box which is wider than it is tall, and moves left and right. A vertical paddle has a bounding box which is taller than it is wide, and moves up and down.
A paddle, like a bumper, generates a trigger when it is hit by the ball. However, the paddle supports multiple triggerable actions. The required actions are "left", "right", and "stop".
When the "left" action is triggered, the paddle starts moving in the negative direction (left for a horizontal paddle; up for a vertical paddle). If the paddle was already moving in that direction, no further change takes place.
When the "right" action is triggered, the paddle starts moving in the positive direction (right for a horizontal paddle; down for a vertical paddle). If the paddle was already moving in that direction, no further change takes place.
When the "stop" action is triggered, the paddle stops moving. If the paddle was already stopped, no further change takes place.
Paddles move at a default speed of 10L/sec. when loaded from a standard file, but may move at other speeds (which could be configured in the editor, or specified by additional syntax in the file).
If a paddle is in motion and reaches the end of its bounding box, it reverses direction. That is, if a paddle receives only one trigger in its lifetime, and that trigger causes the "left" action, the "left" action starts the paddle moving left, but the paddle continually bounces back and forth within its bounding box.
Like an absorber, a paddle cannot be rotated.
A collapsing square is similar to a square bumper, but may sink down into the board (and thus not affect ball motion) or rise up again (and thus again affect ball motion). The collapsing squares provide a defense wall in the Gizmopong sample and the disappearing blocks in the Arkanoid sample.
In the spirit of Gizmoball, the collapsing of a square is specified via a trigger-action mechanism. When a collapsing square is hit by the ball, it will generate a trigger; this is the same behavior as the square gizmo. However, a collapsing square has two actions. The "inc" action increments an internal count, and the "reset" action resets it to zero. The count is initialized to zero.
If the count reaches some threshold, the square collapses. When in a collapsed state, the square no longer reflects the ball or generates triggers. Once in a collapsed state, the square remains that way as long as the count remains at or above the threshold. When the count is reset, the square should rise back up and resume its role as a bumper.
You should consider what happens when a square rises up beneath a ball. The ball must not become trapped within the square. Reasonable actions include knocking the ball away in another direction (as if it was hit on the way up) or delaying the rise (as if the ball was blocking the action).
The square should look noticeably different when collapsed. It might change to a darker color, or disappear from view entirely. You might also consider giving a visual indication of the count of the gizmo, so the player receives visual feedback about the progress of the square toward collapsing.
A generally rectangular translating shape with a fixed width (perhaps 0.5L) and an arbitrary integer length. The shape is surrounded by a rectangular bounding box which is larger than the shape itself, and whose major axis is parallel to the length of the paddle. The shape moves within the bounding box, and changes direction when it reaches the side of the box.
Trigger: generated whenever the ball hits it
Coefficient of reflection: 1.5
Action:
A square shaped bumper with edge length 1L. The bumper maintins a count; when the count is above a given threshold, the bumper is in a collapsed state and no longer interacts with balls.
Trigger: generated whenever the ball hits it
Coefficient of reflection: 1.0 (when not collapsed)
Action:
Paddle gizmos are created using the Paddle command,
which is similar to the Absorber command, except for an
additional parameter giving the span of the paddle. Collapsing squares
are created using the CollapsingSquare command, which is
similar to the Square command, except for the addition of a
trigger count. A specific action may be selected for a connection by
giving a third argument to the Connect command.
Formally, the syntax and semantics of the file format is amended as follows:
<command> ::= ... // same as before, but with the addition of:
CollapsingSquare <name> <int-pair> <int> |
Paddle <name> <int-pair> <int-pair> <int> |
Connect <name> <name> <action> |
KeyConnect <keyid> <name> <action>
<int> ::= INTEGER
<action> ::= IDENTIFIER
"CollapsingSquare" (IDENTIFIER name) (INTEGER x) (INTEGER y) (INTEGER triggers)
"Paddle" (IDENTIFIER name) (INTEGER x1) (INTEGER y1) (INTEGER x2) (INTEGER y2) (INTEGER span)
"Connect" (IDENTIFIER producer) (IDENTIFIER consumer) (IDENTIFIER action)
"KeyConnect" "key" (KEYNUM num) "down" (IDENTIFIER consumer) (IDENTIFIER action)
"KeyConnect" "key" (KEYNUM num) "up" (IDENTIFIER consumer) (IDENTIFIER action)
Note that paddles, like absorbers, need not support the Rotate command.
Gizmopong is one board configuration which is similar to Pong, but with a few added twists. The file is available at gizmopong-example.txt. The key bindings are as follows: left player uses Q A Z X C; right player uses P : > < M. The keys flip the flippers (Q P), move the vertical paddles (AZ :>), and move the horizonal paddles (XC <M).
Gizmonoid is one board configuration which is similar to arkanoid, but with a few added twists. The file is available at arkanoid-example.txt. The key bindings are G to move left and H to move right.
This section will detail the changes made during revisions of this handout.