1 / 8

Exercises for Explosion and Reuse

Exercises for Explosion and Reuse. Bubbles. 1. Make the bubbles have random sizes . 2. Make the bubbles translucent ( semi-transparent ). 3. Automatically add bubbles to the World. Transparency. You can set the transparency of a GreenfootImage: image. setTranparency ( int value ).

bunny
Download Presentation

Exercises for Explosion and Reuse

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Exercises for Explosion and Reuse

  2. Bubbles 1. Make the bubbles have random sizes. 2. Make the bubbles translucent (semi-transparent). 3. Automatically add bubbles to the World.

  3. Transparency You can set the transparency of a GreenfootImage: image.setTranparency( int value ) opaque setTransparency(255) setTransparency(200) setTransparency(150) invisible setTransparency(100) setTransparency(50) setTransparency(0)

  4. Add Mines to Crabgame • Add a Mine that floats down from top. • If Mine intersects a Crab or Lobster, explode! Explodes when it hits a Crab, Lobster, or Rock. Kills Animals close by.

  5. Hint for Exercise • You can create a "DepthCharge" as subclass of of SmoothMover. • But, SmoothMover "wraps around" the edge of the world. X You get too many depth charges. Solution: remove DepthCharge when it gets to bottom of the world.

  6. Hint for Exercise act: check if we intersect an actor if hit another actor then create explosion explode! else if y >= height of world - 2 remove me from world remove from world

  7. Optional: Better Shockwave Advanced In the Shockwave class, explodeOthers( ) sometimes explodes (or kills) other objects that the shockwave doesn't touch! Why? explodeOthers( ) uses getIntersectingObjects( ) to look for stuff to explode. It is "true" if the images overlap. But the image of an Actor may be larger than the visible image. getIntersectingObjects( ) is true because images overlap.

  8. Optional: Better Shockwave (2) Advanced Use getObjectsInRange(radius, clss) instead of getIntersectingObjects(). The Javadoc says: List list = getObjectsInRange(int radius, Class cls) Return all objects within range radius around this object.An object is within range if the distance between its center and this object's center is less than or equal to radius.

More Related