[quote]…however, it eats a LOT of memory, and goes pretty slow on computers that are not top-end.
I’m not the greatest programmer, so I’m sure some of it is crappy/hard to read/done wrong…I’m looking for any help you can give, especially optimization.
[/quote]
I looked over your source and your right, it is hard to read, you have stuff scattered every where.
My advice? You have a working demo, now rewrite (almost) all the code from scratch, only this time thinking about what is going on from a bottom up or top down approach; redesign your objects so they more realistically represent the problem so you can properly localize you code. There are much more ‘elegant’ solutions than what you’ve found (I can’t believe I just used the word elegant in a sentance…)
Optimization and applets (Java in general): This can be a big topic. First you must define the target audience you want to use your applet. Do you want only people with high end hardware and the latest JRE to be able to click on your applet and see it or do you want to target Joe Lowend with his P2 266 and Microsoft VM in Internet Exp 5.0? (<-This is were the fun starts)
Generally here are a few things to get the best performance from your main loop;
-
Don’t create or destroy new objects within your main loop to avoid the gc kicking in.
-
Keep string manipulation to a minimum
-
Thread.sleep() gives erratic timing on almost all platforms (that I’ve tried at least), search these forums or the wiki for the hirestimer class code.
-
Remove any diagnostic System.out.println() you may have left in.