Hello guys, I am programming the Space Invaders game and I created a Counter class to add score each time my player kills an Alien.
Anyway I have three kind of aliens and I want to add a different number of score to any of my aliens
Example : Alien 1 ; +20, Alien 2 ; + 30 etcc..
Here's my code Counter Class
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Counter here. * * @author (your name) * @version (a version number or a date) */ public class Counter extends Actor { int score = 0; /** * Act - do whatever the Counter wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public Counter() { setImage(new GreenfootImage("Score : " + score, 30, Color.WHITE, Color.BLACK)); } public void act() { setImage(new GreenfootImage("Score : " + score, 30, Color.WHITE, Color.BLACK)); } public void addScore() { score++; } }