6.170 Laboratory in Software Engineering
Fall 2002
Final Project Amendment: Gizmopong

Handout F1


Contents:


Background

The 6.170 staff have enjoyed using your initial implementation, but the hoary old geezers recall the good old days when Atari made the premier gaming platform. They want to be able to create and play boards similar to the games of old, such as Pong and Arkanoid.

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

A paddle is a bumper gizmo, a bit like a flipper, which moves translationally back and forth within some fixed rectangular area. A paddle is shaped like a rectangle, but may have tapered or rounded edges.

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.

Physics

It may seem like paddle motion requires completely new physics capabilities, since a paddle is like a bumper with translational velocity (whereas a flipper has rotational velocity). However, this is not the case. All motion is relative: we can equally say that a paddle is moving towards a wall at 2L/s or that the wall is moving towards the paddle at 2L/s. You should be able to take advantage of an altered frame of reference to achieve correct physics for your paddle.

Collapsing Square

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.

Detailed Requirements

The Detailed Requirements (Appendix 1) section of the original specifications are amended as follows.

Paddle Gizmo

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:

Collapsing Square Bumper

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:

File Format

In order to accommodate the two new types of gizmos, the file format has also been amended. We introduce two new commands to allow the creation of paddles and collapsing squares, and add overloaded forms of the connect and keyconnect commands which can specify a certain action for a connection.

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:

Syntax Amendment

<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

Semantics Amendment

"CollapsingSquare" (IDENTIFIER name) (INTEGER x) (INTEGER y) (INTEGER triggers)
Creates a collapsing square with its upper left-corner at (x,y). The square will switch to its collapsed state after receiving triggers "inc" actions; triggers must be positive. Within the file, the name must be unique, and may be used later to refer to this specific gizmo.
"Paddle" (IDENTIFIER name) (INTEGER x1) (INTEGER y1) (INTEGER x2) (INTEGER y2) (INTEGER span)
Creates a paddle with the upper left-hand corner of its bounding box at (x1,y1) and the lower right-hand corner of its bounding box at (x2,y2). The second position must be at least 1L to the right of and at least 1L below the first position. Paddle motion is parallel to the longest axis (i.e., the x axis if x2-x1 is larger than y2-y1). The span (size) of the paddle along the axis of motion is given by span in L units, which must be positive but no greater than the length of the longest axis. The paddle-shaped bumper may be initially positioned anywhere within the bounding box, at your discretion. Within the file, the name must be unique, and may be used later to refer to this specific paddle.
"Connect" (IDENTIFIER producer) (IDENTIFIER consumer) (IDENTIFIER action)
Makes the gizmo named by consumer a consumer of the triggers produced by the gizmo described by producer, where the action is given by action. That is, every time a ball hits the producer, a specific action of the consumer will happen. Note that the original form of the Connect command is still allowed.
"KeyConnect" "key" (KEYNUM num) "down" (IDENTIFIER consumer) (IDENTIFIER action)
"KeyConnect" "key" (KEYNUM num) "up" (IDENTIFIER consumer) (IDENTIFIER action)
Makes the item named by consumer a consumer of the trigger produced when the key represented by num is pressed (or released, respectively). The specific action to be triggered is given by action; every time a key is pressed (or released), a specific action of the consumer will happen. Note that the original form of the KeyConnect command is still allowed.

Note that paddles, like absorbers, need not support the Rotate command.

Sample Boards

We provide sample boards (given in the standard file format) to illustrate two of the many possible configurations your clients expect to be able to create and play using these new features.

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.

Ambiguities

Parts of this amendment are vague and lacking in detail. It is up to you to decide what (if any) clarifications are necessary. You should include any changes to your Revised Specification documentation in your final submission on December 10.

Design Decisions

Spend some time thinking about the best way to incorporate this change into your design. In your final design write-up, be sure to discuss the changes to your initial design (and the relevant trade-offs). You will be graded on how easily your initial design can support the amendment, and how cleanly you incorporate the amendment into your design.


Change Log

This section will detail the changes made during revisions of this handout. 


For problems or questions regarding this page, contact: 6.170-webmaster@mit.edu.
$Id: amendment.html,v 1.1 2002/11/27 08:07:48 gdennis Exp $