Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void createApples(int max) {
- int loop = 0;
- int appleX;
- int appleY;
- Element apple;
- boolean exists;
- int index;
- for (loop = 0; loop < max; loop++) {
- exists = false;
- do {
- appleX =
- new Random().nextInt(bounds.width / SNAKE_SIZE) *
- SNAKE_SIZE + SNAKE_SIZE / 2;
- appleY =
- new Random().nextInt(bounds.height / SNAKE_SIZE) *
- SNAKE_SIZE + SNAKE_SIZE / 2;
- index = 0;
- while (index < apples.size() && !exists) {
- exists = apples.get(index).equal(appleX, appleY);
- index++;
- }
- if (!exists)
- exists = player.contains(appleX, appleY);
- else if(mode == MODE_HOTSEAT)
- if (!exists)
- exists = player.contains(appleX, appleY);
- if (!exists)
- exists = player2.contains(appleX, appleY);
- }
- while (exists);
- apple = new Element(appleX, appleY, SNAKE_SIZE, Color.white, bounds);
- apples.add(apple);
- }
- }
- //This is the section where i made the apples respawable aso.. i quess the problem should be somewhere here. Also, shoud i post the hole export for you?
Add Comment
Please, Sign In to add comment