// Tree Class // Tree.java // Imports import java.awt.*; import java.applet.Applet; import java.util.BitSet; public class Tree extends Sprite { public static Image[] image; /**Constructor*/ public Tree(Component comp, int i, Point pos) { super(comp, // Component image, // Image to use i, // Current Frame 1, // Frame Increment 3, // Frame Delay pos, // Current Location new Point(0, 1), // Velocity 40, // Z-Order Sprite.BA_WRAP); // Bounds Action // Direction } public static void initResources(Applet app, MediaTracker tracker, int id) { image = new Image[2]; for (int i = 0; i < 2; i++) { image[i] = app.getImage(app.getCodeBase(), "Res/Tree" + i + ".gif"); tracker.addImage(image[i], id); } } protected void setCollision() { collision = new Rectangle(position.x + 25, position.y + 25, position.width - 50, position.height - 50); } public BitSet update() { if (WarMan.badcount <= 10) velocity.x = velocity.y = 0; // Call parent's update() BitSet action = super.update(); return action; } }