Sorry for late reply. I've been busy.
I see... But problem is, addObject does not work in static methods. Any solutions? (Other than making the method non-static)
I'm beginning to think that I should just make a simple randomiser... one that does not change the odds when something doesn't go the player's way...
(In other words, I think I should give up on this complex randomiser. It's not a requirement and I'm making things more complicated than they have to be. Seems to be a habit of mine)
Powerups
BreakBlock
danpost wrote...
You create objects in each part of the if-else-else... in your spawnPowerup method of the Powerups class; but, nothing is done with them. public void spawnPowerup(int X, int Y){
randChance = Greenfoot.getRandomNumber(100);
if (randChance >= 0 && randChance < bombUpChance){
getWorld().addObject(new BombUp(X, Y));
}
else if (randChance >= bombUpChance && randChance < explodeRadiusChance){
getWorld().addObject(new ExplodeRadius(X, Y));
}
else if (randChance >= explodeRadiusChance && randChance < oneUpChance){
getWorld().addObject(new OneUp(X, Y));
}
else if (randChance >= oneUpChance && randChance < skateChance){
getWorld().addObject(new Skate(X, Y));
}
} powerupChance = 6;
BombExplode explosion = (BombExplode) getOneIntersectingObject(BombExplode.class);
if (explosion != null){
randChance = Greenfoot.getRandomNumber(powerupChance);
if (randChance >= (powerupChance-1)){
Powerups pUp = new Powerups();
pUp.spawnPowerup(getX(), getY());
}
getWorld().removeObject(this);
}

