I'm getting this error occasionally and it points me to two different areas of the same piece of code each time..
for (int i = bullet.size() - 1; i >= 0; i--) {
boolean remove = false;
bullet.get(i).run();
for (int j = enemy.size() - 1; j >= 0; j--) {
if (enemy.get(j).pointInside(bullet.get(i).x, bullet.get(i).y)) {
bullet.remove(i);
enemy.remove(j);
score += 100;
}
}
if (bullet.get(i).y <= 0) {
bullet.remove(i);
}
}
sometimes it points to line 8 and others line 18, I'm guessing that when the object at position 'i' is removed the other line of code still tries to use it and throws an error because it's missing but I don't know how to resolve it. I tried to use a boolean variable that would switch to true if either of the conditions were true and would then in turn call for it to be removed but that didn't work either.
Can anyone point me in the right direction please? =]
I've gone through the code for about half an hour now and as far as I can tell there are no extraneous parentheses, spelling mistakes or undeclared variables so I'm at a loss for a solution so I'm hoping someone here can see what I'm missing.
I wasn't sure whether to post this in the other topic I made earlier but as it's a different problem I decided to make a new one. The problem I'm having is that when the animation moves the previous one is still there until the background is redrawn making it look like it has a clone following it, I solved this by drawing a new background each time the key is pressed to move the animation however when this happens it draws over the stars that are scrolling in the background making them disappear for a split second and causing them to flash. How can I get round this so that the stars are permanent and there is no clone following the animation?
Star [] starCollection = new Star [200];
Animation aniFly, aniTurnL, aniTurnR;
float xpos = 500;
float ypos = 500;
void setup() {
size(1000,600);
frameRate(60);
aniFly = new Animation("sprite_shipm2_fly",4);
aniTurnL = new Animation("sprite_shipm2_turnL", 3);
aniTurnR = new Animation("sprite_shipm2_turnR", 3);
hi, I'm relatively new to processing and I'm struggling with a game that I'm making as part of a university project. I'm planning on making a vertical scrolling shooter where you control a spaceship, What I want to happen is that by default the ship is using a flying animation but when the left and right key are pressed the ship moves in that direction and the animation changes to a turning animation until the key is released where it returns to the flying animation. I've been playing around with it for a few hours and not got anywhere. Obviously since this is a university assignment I'd rather not have the work done for me but if you guys could offer suggestions and point me in the right direction I would be very grateful.