Advertisement
Filipinex

CFood

Mar 19th, 2024
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. import greenfoot.*;
  2.  
  3. public class CFood extends CInterFish
  4. {
  5.     public CFood(int size)
  6.     {
  7.         super(size);
  8.         this.getImage().scale(25, 10);
  9.         this.getImage().mirrorHorizontally();
  10.     }
  11.    
  12.     public void act()
  13.     {
  14.         MoveAround();
  15.     }
  16.    
  17.     public void MoveAround()
  18.     {
  19.         this.move(1);
  20.        
  21.         if (this.isAtEdge()) //ak sa dotyka steny
  22.         {
  23.             this.getWorld().removeObject(this); //zmizme
  24.         }
  25.     }
  26.    
  27.     public void InteractWithFish(CFish fish)
  28.     {
  29.         fish.Eat(this);
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement