I've followed a video about how to implement a score counter but the counter doesn't update when i hit the enemies.
Here is the world code
Bullet code
No errors are showing up so i don't know what's wrong with it.
{ public static int score= 0; HealthBar healthBar = new HealthBar(); public BackGround() { super(560, 534, 1); prepare(); } public HealthBar getHealthBar() { return healthBar; } private void prepare() { addObject (healthBar, 200, 40); showText("Score: " + score, 50, 25); SlimyBoi slimyBoi = new SlimyBoi(); addObject(slimyBoi,350,181); SlimeBoolet slimeBoolet = new SlimeBoolet(); addObject(slimeBoolet,260,223); slimeBoolet.setLocation(392,197); RadishLad radishLad = new RadishLad(); addObject(radishLad,285,241); radishLad.setLocation(132,382); slimyBoi.setLocation(128,255); removeObject(slimeBoolet); addObject(radishLad,183,218); radishLad.setLocation(108,203); addObject(slimyBoi,110,301); slimyBoi.setLocation(107,313); a a = new a(); addObject(a,280,267); a.setLocation(232,410); a.setLocation(202,399); a.setLocation(202,399); a.setLocation(498,324); a.setLocation(-3,454); a.setLocation(204,4); a.setLocation(196,267); a a2 = new a(); addObject(a2,196,267); a.setLocation(414,220); a2.setLocation(11,366); a.setLocation(62,0); a.setLocation(370,0); a a3 = new a(); addObject(a3,186,318); slimyBoi.setLocation(0,168); a2.setLocation(234,420); a2.setLocation(186,460); removeObject(a2); a3.setLocation(0,462); a3.setLocation(1,447); a.setLocation(313,318); a.setLocation(294,446); a.setLocation(287,434); removeObject(a); slimyBoi.setLocation(117,291); slimyBoi.setLocation(118,346); slimyBoi.setLocation(67,286); a3.setLocation(459,354); slimyBoi.setLocation(118,334); a3.setLocation(200,188); a3.setLocation(4,176); slimyBoi.setLocation(88,313); slimyBoi.setLocation(100,301); } }
public class SlimeBoolet extends Actor { public SlimeBoolet() { GreenfootImage myImage = getImage(); int myNewHeight = (int)myImage.getHeight()/18; int myNewWidth = (int)myImage.getWidth()/18; myImage.scale(myNewWidth, myNewHeight); } BackGround thisGame; public void act() { World w = getWorld(); move (5); if (isAtEdge()) { w.removeObject(this); } else if(isTouching(Bad.class)) { thisGame.score++; removeTouching (Bad.class); w.removeObject(this); } } }