I've got a method called moveBomb() called when a Player throws a bomb into the world.
After many unlucky tries i wanted to ask for help converting this method in a non-delay one. The problem now is that i can't move or anything when i drop a bomb for quite a time. I saw videos solving this issue with a clock counting up with help of the act method. The movement was designed to look realistic - the bomb is quickly when thrown, then slows down until it "lands" (done by for loop with function with counting variable).
Could anyone explain me how to implement the clock so that i can replace the Greenfoot.delay(10) in the for loops?
Would be really awesome!
public void moveBomb(Bomb playerBomb, Player summoner) {
Player playerOne;
Player playerTwo;
GameWorld bombWorld = (GameWorld)getWorld();
int a = 0;
int b = 0;
int playerRotation;
switch(summoner.getRotation()) {
case 0:
a = 1;
b = 0;
case 90:
a = 0;
b = 1;
case 180:
a = -1;
b = 0;
case 270:
a = 0;
b = -1;
}
for(int x=1;x<101;x++) {
newBombX = bombX + a * 10/x;
newBombY = bombY + b * 10/x;
this.setLocation(newBombX, newBombY);
bombX = newBombX;
bombY = newBombY;
Greenfoot.delay(10);
}
}