ok, so now the bullet hits the guardian, but there are two problems first the there is no change in the value of the guardian counter, and when the bullet disappears I get a nullpointer error so there must be an error with the order I have my bullet class in (so I will check that out). What I do not know is why the guardiancounter is not subtracting 1.
Here is my gun code
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Gun here. * * @author (BradH) * @version (a version number or a date) */ public class Gun extends Weapons { private Spacemarinemodel1 spacemarinemodel1; private SniperCounter snipercounter; public Gun(Spacemarinemodel1 spacemarinemodel1, SniperCounter pointSniperCounter) { this.spacemarinemodel1 = spacemarinemodel1; snipercounter = pointSniperCounter; } private GuardianCounter guardiancounter; //here so it knows the bullet1 public Gun(GuardianCounter pointGuardianCounter) { guardiancounter = pointGuardianCounter; } public void act() { if(Greenfoot.isKeyDown("l")) { if(getWorld().getObjects(Bullet1.class).size()< 1) fire(); } //switch weapon to Sniper if((Greenfoot.isKeyDown("2"))) getWorld().addObject(new Sniper(spacemarinemodel1, snipercounter), getX(), getY()); //remove the first weapon if((Greenfoot.isKeyDown("2"))) {getWorld().removeObject(this); } int spacemarinemodel1X = spacemarinemodel1.getX(); int spacemarinemodel1Y = spacemarinemodel1.getY(); // Modify the xOffset and // yOffset to make the gun // appear in the correct // position. int xOffset = 27; int yOffset = -8; int x = spacemarinemodel1X + xOffset; int y = spacemarinemodel1Y + yOffset; setLocation(x, y); } /** * fire the gun */ private void fire() { GuardianCounter guardiancounter; guardiancounter = new GuardianCounter(); Ammo Bullet1 = new Bullet1(guardiancounter); getWorld().addObject(Bullet1, getX() , getY()); Bullet1.move(45); } }