Hey,
I've been working on game for a computer science class and I've figured out most of my game apart from the issue of my victory condition not being able to work.
I have four classes which are concerned here: Player, Bandit, Bullet and Character. All of which are sub-classes of Character (apart from Character of course). This is the way in which I had been trying to work the victory condition:
WITHIN CHARACTER:
WITHIN BANDIT (The bullet doesn't kill the bandit, it is the bandit that removes the bullet and then itself, therefore there is no code within bullet apart from the code that removes it at world edge)
The bullet is spawned by the player, but there is no code within Player that relates to any of this, but it is what the player plays as.
The amount of each class within the world:
BANDIT = 16
PLAYER = 1
CHARACTER = 1
BULLET = INFINITE AMOUNT
Any help would be greatly appreciated as the game is pretty much finished apart from the victory condition.
Euan.
public int banditsKilled = 0; public void act() { checkForWin(); } public void checkForWin() { if (banditsKilled == 16) { banditsKilled = 0; //Artic is just another subclass of world that I'm switching to for the second level, but it's not that important. Greenfoot.setWorld(new Artic()); } } public void addToBanditsKilled() { banditsKilled++; }
public void act() { move(5); worldEdgeTurn(); checkForBullet(); } public void checkForBullet() { if(canSee(Bullet.class)) { addToBanditsKilled(); kill(Bullet.class); randomCrateDrop(); getWorld().removeObject(this); } }