Slow, choppy, shouldn't be

I am new here, not to programming or programming games, but here and programming games in java, which i enjoy.
Not exactly sure where to stick this so ill put it here.

K my game isnt that big, 2d and the graphics are simple, yet if i have more than 7 or so firebats (enemies that drop bombs) it becomes a slow nightmare. It stops collision detecting right, half thet ime i can walk through a hailstorm of the little balls of fire the bats drop and not hit a single one.

I am going to guess that the problem is that my update method handles too much, and i need to make more methods that the update delegates tasks too.

Check out the 4th level, that is the one where it shows how terrible the game is written. Its not that difficult, this is a computer that could render halo 1 max settings perfectly in the day, so really, i must be a bad coder…

http://rapidshare.de/files/22152393/Game.jar.html

As a sidenote you might want to just open the jar right away, and swap maps 4 and 1, so you can see what im talking about, since it is ridiculously hard, or so i am told by everyone who tested it.

why not webstart it ? :stuck_out_tongue:

well I have played it and it wasn’t choppy at all… but I have very strong pc (athlon64 3000+, radeon x800gto). Put in a fps counter so we can report resoults.
The difficulity was excellent, a nice challange, but if you’re aiming for children make it easier a lot.

Yea i took it out a while back, ill put it back and see what i get, i stuck a println that counts the number of active sprites, and when i am getting massive lag it is only 16-17 critters in the map.getSprites linked list.

http://rapidshare.de/files/22370526/Game.jar.html

OK i am getting 30-50 FPS on the levels where collision detection goes out the window. when i played it i could not collide with enemies on level 4 or 5, but on level 5 the bats clump up even though they are moving at the same speed, they seem to teleport a little bit after each bomb they drop, i also made it log smack if you are hit. And when i jumped through the clump of 7 bats it didn’t even get hit once.

Something in the updatePlaying method and it’s series of collision detection methods is screwy.

Edit: i figured out the inviniciblity problem, if you have your shield on and switch levels, the shieldOn variable stays true between levels but the turnShieldOff method is called so it stops drawing, but you cant be killed.
As for the bats its running at 45 fps while they are jerking around. So it must be something in the bomb creating algorithm that makes them skip, since the same number of normal bats does not do that.

Edit Edit:

Iterator i = map.getSprites();
        while (i.hasNext()) {
            Sprite sprite = (Sprite)i.next();
			if (sprite instanceof Critter)	{
				Critter critter = (Critter)sprite;
				if (critter.getVelocityX() == 0)	{
					critter.setVelocityX(critter.getMaxSpeed());
				}
				updateCritter(critter, elapsedTime, i);
				if ((critter instanceof BomberBat))	{
					BomberBat bomber = (BomberBat)critter;
					if (bomber.timeToDropBomb() == true)	{
						Bomb bomb = new Bomb(resourceManager.getAnim(7));
						bomb.setX(bomber.getX());
						bomb.setY(bomber.getY());
						map.addSprite(bomb);
						i = map.getSprites();
						bomber.dropedBomb();
					}
				}
			}

Now that i stare at this for the 1345th time, its seems that the first bat will get updated and if it drops a bomb, it will get updated again, since i am reseting my iterator. Is that the problem? How can i work around that?

Maybe later when I have time I will add a linked list of bombs to be added, and add them to the sprite list after all updating is over. So they dont get updated in the same frame as the bat drops them. Will that work?

YAY! I got it to work, i made a list of things to be added and added them at the end of the update method. Can i see some code that shows how other people handle adding and removing projectiles?