I have a collision method implemented through the use of slick2d. When ever the snake collides with the apple, it causes the apple to be rendered in multiple places before the snake moves further along.
if(checkCollision() == true){
x -= 1;
snakes.add(new Point(x, y));
locateApple();
}
And heres the locate method to move the apple in a random position:
public void locateApple() {
int r = (int) (Math.random() * RAND_POS);
applePoint.setX((r * DOT_SIZE));
applePoint.setY((r * DOT_SIZE));
}
This is in my update() method, which is probably causing the problem, how can I run this code only once? SO that once it collides, it moves the apple in a new position with out executing multiple times.