Shark_Attack

Created by Barbara Lerner

You need to download Java software in order to view this Alice world. Please visit this page: http://www.alice.org/applet/requirements/

Created with Alice, the easy-to-learn programming system. Provided free as a public service by Carnegie Mellon University


If you don't see 3d graphics on this page, click for help.

Shark_Attack's Code

Created by:

world

Events

When the world starts
Do:
world.my first method ( );


Methods

  public void my_first_method ( ) {
    Object[] schoolOfFish = ;
       doTogether {
       for (int index=0; index< 8 times ; index++) {
       For all schoolOfFish , every item_from_schoolOfFish together {
       world.swim ( whichFish = item_from_schoolOfFish );
  }
  }
  world.sharkEatFish ( );
  }
  }


  public void swim ( Object whichFish) {
    Object fishTail = <None> ;
       fishTail .set( value , ( whichFish .partNamed( tail ) ) );
  doTogether {
       doInOrder {
       fishTail .turn( LEFT , 0.12 revolutions ); duration = 0.5 seconds style = BEGIN_ABRUPTLY_AND_END_GENTLY
  fishTail .turn( RIGHT , 0.25 revolutions );
  fishTail .turn( LEFT , 0.12 revolutions ); duration = 0.5 seconds style = BEGIN_GENTLY_AND_END_ABRUPTLY
  }
  whichFish .move( FORWARD , 0.5 meters ); duration = 2 seconds style = BEGIN_AND_END_ABRUPTLY
  }
  }


  public void sharkEatFish ( ) {
    
       doTogether {
       shark .moveToward( target = goldfish3.tail , amount = 3 meters ); duration = 8 seconds
  doInOrder {
       wait( 6 seconds );
  shark.jaw .turn( FORWARD , 0.1 revolutions );
  }
  }
  goldfish3 .set( opacity , 0 (0%) );
  shark.jaw .turn( BACKWARD , 0.1 revolutions );
  }