O'Reilly logo

Killer Game Programming in Java by Andrew Davison

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Commands Panel

CommandsPanel creates the panel at the bottom of the GUI containing the text field and Reset button. Much of the code deals with the parsing of the input from the text field, which takes two forms. A limb command has the following format:

    ( <limbName> | <limbNo> ) (fwd | f | turn | t | side | s) [ angleChg ]

A figure command has this format:

    (fwd | f | back | b | left | l | right | r | up | u | down | d | clock | c | cclock | cc)

Each moveable limb is assigned a name and number, and either one can be used to refer to the limb. As a convenience, the name/number mappings are printed to standard output when Mover3D is started.

The principal difference between the limb and figure commands is that a limb command needs to refer to a particular limb, and a figure command applies to the entire figure. A limb command can include a rotation value (angleChg).

The rotation operations refer to the three axes:

fwd (or f )

Rotation around x-axis

turn (or t )

Rotation around y-axis

side (or s )

Rotation around z-axis

Tip

If an angleChg value isn't included, a rotation of +5 degrees will be carried out.

Each limb has a predefined maximum positive and negative rotation, and a rotation command will only move a limb to the prescribed limit.

An advantage of text field input is the ability to group several limb and/or figure commands together, separated by commas. These are processed before the figure is redrawn. By pressing Enter, a complex sequence of commands is repeated. This can be seen ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required