Hi All,
I am trying to implement a boss in my game, but for the life of me I can not figure how to kill it. So far I have this:
What do you guys think?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class miniBoss here. * * @author (your name) * @version (a version number or a date) */ public class miniBoss extends Enemies { private int Shield; private int Score; private int life; protected void takeLife() { this .life -= 1 ; if ( this .life <= 0 ) getWorld().removeObject( this ); } /** * Act - do whatever the miniBoss wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { this .Score = 10 ; this .life = 2 ; checkCollision(); } public void checkCollision() { Actor collided = getOneIntersectingObject(shipMissile. class ); if (collided != null ) { ((City) getWorld()).addScore( 20 ); getWorld().addObject( new explosionLarge(), getX(), getY()); getWorld().removeObject(collided); takeLife(); } } } |