public void main ( ) {
|
| |
// Copyright 2007, R.G.Baldwin |
| // Demonstrates world-level methods with parameters. |
| // Set the stage, could make invisible. |
| doTogether { . . . . . . } |
| |
// Position the camera. |
| doTogether { . . . . . . } |
| |
camera .setPointOfView( world ); duration = 0 seconds |
| camera .turn( LEFT , 0.5 revolutions ); duration = 0 seconds |
| camera .move( BACKWARD , 10 meters ); duration = 0 seconds |
| camera .move( UP , 2 meters ); duration = 0 seconds |
| camera .move( RIGHT , 4 meters ); duration = 0 seconds |
| camera .pointAt( penguin2.head ); duration = 0 seconds |
| } |
| // Position the penguins. |
| doTogether { . . . . . } |
| |
penguin1 .setPointOfView( world ); duration = 0 seconds |
| penguin2 .setPointOfView( world ); duration = 0 seconds |
| penguin3 .setPointOfView( world ); duration = 0 seconds |
| penguin1 .move( RIGHT , 1 meter ); duration = 0 seconds |
| penguin3 .move( LEFT , 1 meter ); duration = 0 seconds |
| } |
| // Resize and position the cows. |
| doTogether { . . . . . . . . . . . } |
| |
cow1 .resize( 0.8 ); duration = 0 seconds |
| cow2 .resize( 0.8 ); duration = 0 seconds |
| cow3 .resize( 0.8 ); duration = 0 seconds |
| cow1 .setPointOfView( world ); duration = 0 seconds |
| cow2 .setPointOfView( world ); duration = 0 seconds |
| cow3 .setPointOfView( world ); duration = 0 seconds |
| cow1 .move( RIGHT , 1 meter ); duration = 0 seconds |
| cow3 .move( LEFT , 1 meter ); duration = 0 seconds |
| cow1 .move( BACKWARD , 2 meters ); duration = 0 seconds |
| cow2 .move( BACKWARD , 2 meters ); duration = 0 seconds |
| cow3 .move( BACKWARD , 2 meters ); duration = 0 seconds |
| } |
| } |
| // Do the drill. |
| doInOrder { . . } |
| |
wait( 1 second ); |
| doTogether { . . . . . . } |
| |
world.closeOrderDrill ( theObject = penguin1 ); |
| world.closeOrderDrill ( theObject = penguin2 ); |
| world.closeOrderDrill ( theObject = penguin3 ); |
| world.closeOrderDrill ( theObject = cow1 ); |
| world.closeOrderDrill ( theObject = cow2 ); |
| world.closeOrderDrill ( theObject = cow3 ); |
| } |
| } |
| } |
public void closeOrderDrill ( Object theObject) {
|
| |
// Demonstrates world-level method with parameter. |
| // Note: Custom methods like penguin.walk not available. |
| // Do same movement four times in succession. |
| // Note: Haven't studied the use of loops yet. |
| doInOrder { . . } |
| |
theObject .turn( LEFT , 0.25 revolutions ); |
| theObject .move( FORWARD , 1 meter ); |
| } |
| doInOrder { . . } |
| |
theObject .turn( LEFT , 0.25 revolutions ); |
| theObject .move( FORWARD , 1 meter ); |
| } |
| doInOrder { . . } |
| |
theObject .turn( LEFT , 0.25 revolutions ); |
| theObject .move( FORWARD , 1 meter ); |
| } |
| doInOrder { . . } |
| |
theObject .turn( LEFT , 0.25 revolutions ); |
| theObject .move( FORWARD , 1 meter ); |
| } |
| } |