My game is lagging so badly

Hello,
http://members.surfeu.fi/redapple/MyJavaStuff/ and click -> Attack Maniacs v1.0 while playing it lows down to FPS about 3-5. Maybe part of the reason is because I create lots of new object than using it again? It’s strange because first it works fine and suddenly slows down when there is a more stuff.

Second problem: I want to use some gif animation on this applett, but when I replace some of a non-animated gis’s by animated gifs my appletts freaks out. Some bug or what.

third problem: How can I make it show some animation while loading all images and sounds into memory. I use Mediatracker for images and for music Suns Soundloader and Soundlist classes.

And sorry my language.

I’m getting a constant 62 fps throughout the whole game, which seems kinda weird since it neves changes at all.

it seems quite fixed yes, also here it was 15 fps to level 5 or so and at level 6 or so I noticed it was 32 and there where certainly more items out there. So as Jeff said bottlenecks are almost never caused by the factor you first of figured would be desicive.

I just tried with opera and on level 6 it slows down to 3-6 FPS, but playing it on NetBeans appletviewer it works fine FPS about 66 all the time. This fps method is like

      
        endFPS= System.currentTimeMillis();
  
        if(  endFPS - beginFPS  != 0 ) differenceFPS = endFPS - beginFPS ;
        big.drawString("FPS "+ 1000 / ( differenceFPS ), leveys - 100, 30);   
        

so it change it only if difference is more than zero, I dont know right way to do FPS thing.


private long lastCheck = System.currentTimeMillis();
private int counter = 0;

public void render()
{
    // do your stuff

    long now = System.currentTimeMillis();

   if(now - lastCheck > 1000)
   {
       System.out.println("FPS: "+counter);

       lastCheck += 1000;
       counter = 0;
   }

   counter ++;
}

I update that FPS thing (and fix few bugs) now it makes sense, because sleep is 100ms and now FPS is about 10. And would you say what I have to do next/ how to improve this lowsy game or if you notice a bugs so tell me and if you bother give a glue of solution. thanks for help :wink:

try displaying the score for a while at the end of the game

Thanks for the tips, I tried to do what you said. Give me your opinions of the game in my opinion the whole idea behind this game is boring. What I should do next? Did you found a bugs?

And a question. I want to put there a background image, waht is best way to do that. replace fillRect by drawimage?

not any that I could detect by playing it normally. The game reminded me of paratroopers oow nostalgy.

you could like paratroopers make the dudes stack(seen the movie starship troopers?) but if you want to fundamently change the game I’d would just start off from scratch and only take with you what you have learned from creatign this one.