i want to make my space invaders have more "HP" so the last row takes 3 shots to kill and the 2nd row 2 shots and so on but i cant seem to get it no matter what i try plz help


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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Space here. * * @author (your name) * @version (a version number or a date) */ public class Space extends World { /** * Constructor for objects of class Space. * */ public Space() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super ( 1000 , 600 , 1 ); Rocket myrocket; myrocket = new Rocket(); invader myinvader; myinvader = new invader(); invader myinvader1; myinvader1 = new invader(); invader myinvader2; myinvader2 = new invader(); invader myinvader3; myinvader3 = new invader(); invader myinvader4; myinvader4 = new invader(); invader myinvader5; myinvader5 = new invader(); invader myinvader6; myinvader6 = new invader(); invader myinvader7; myinvader7 = new invader(); invader myinvader8; myinvader8 = new invader(); addObject(myrocket, 55 , 300 ); addObject(myinvader, 980 , 50 ); addObject(myinvader2, 980 , 115 ); addObject(myinvader3, 980 , 180 ); addObject(myinvader4, 980 , 240 ); addObject(myinvader5, 980 , 300 ); addObject(myinvader6, 980 , 360 ); addObject(myinvader7, 980 , 420 ); addObject(myinvader8, 980 , 480 ); addObject(myinvader1, 980 , 540 ); } } |
1 | int acts = 0 ; |
1 2 | if (acts% 10 == 0 ) setLocation(getX()- 1 , getY()); acts = (acts+ 1 )% 10 ; // cycles act counter from 0 through 9 |
1 | int acts = 0 ; |
1 2 | if (acts% 10 == 0 ) setLocation(getX()- 1 , getY()); acts = (acts+ 1 )% 10 ; // cycles act counter from 0 through 9 |
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 | public class invader extends Actor { /** * Act - do whatever the invader wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ int acts = 0 ; int count = 3 ; public void act() { if (acts% 10 == 0 ) { setLocation(getX()- 1 , getY()); acts = (acts+ 1 )% 50 ; // cycles act counter from 0 through 9 } Actor a = getOneIntersectingObject(bullet. class ); if (a != null ) { count = count - 1 ; getWorld().removeObject(a); } if (count == 0 ) { getWorld().removeObject(a); getWorld().removeObject( this ); return ; } if (getX() < 1 ) { getWorld().removeObject( this ); Greenfoot.stop(); } } } |