Hello! I'm working on my first game which is similar to pac man. The goal is for Patrick to collect shamrocks in order to earn a keg of beer. I have a counter which counts shamrocks and am trying to add one keg of beer for every 10 shamrocks that are collected. I've used an if statement which adds a keg when ten shamrocks have been collected, but I think it keeps adding kegs until the counter reaches 11. The kegs are placed on top of each other, so it is not apparent until you manually move a keg and find several underneath it. Here is the code I have so far:
/**
* Create a new Keg for every 10 shamrocks collected .
*/
private void createNewKeg()
{
if (counter.getValue() == 10 )
{
getWorld().addObject(new Keg(), 130, 455);
}
// if (counter.getValue() ==20 )
// {
// getWorld().addObject(new Keg(), 130, 455);
// }
//
// if (counter.getValue() == 30 )
// {
// getWorld().addObject(new Keg(), 160, 455);
// }
Any help would be greatly appreciated. Thanks!
Roz

