Looking for assistance with my platformer applet..

Its doing pretty decently, aside from a few collision errors…however, it eats a LOT of memory, and goes pretty slow on computers that are not top-end.

I was wondering if anyone could give me a hand with this…its open source, and you can DL it here: http://www.paraduck.net/misterbob/src.rar

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. I’ve tried using a profiler, but I can’t figure out what exactly is causing the huge slowdown. Any constructive criticism is appreciated, but if you are just going to mock me/degrade my ability as a programmer, do me a favor and don’t download the source, thanks :slight_smile:

You could always post the profiler output here… Also try JMeter to help you understand its output, it works nicely: http://www.hp.com/products1/unix/java/hpjmeter/

http://www.paraduck.net/misterbob/monitor.html

[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;

  1. Don’t create or destroy new objects within your main loop to avoid the gc kicking in.

  2. Keep string manipulation to a minimum

  3. 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.

  4. Remove any diagnostic System.out.println() you may have left in.

Thanks. :slight_smile:

I’ve begun neatening things up and stuff, however I’m still stumped as to why my game goes so poorly on low end systems. I checked, and I don’t create any new objects during the game loop, and I don’t modify any strings… :frowning:

Maybe u should think about learning java programming ?? You can read a book or study it at a university ???

explaining all details of programming here is very hard and would take a lot of time.

Even OO Programming is a good way to learn java, i worked as a c, c++ teacher and i know its not easy to get started.

i have to pay my bills, so i have to be a good programmer or i get fired.

Get some GOOD code ( strict and clean coding is also part of programming ), document your code, learn to use cvs.

I looked at your code and it looks like a big bomb exploded anywhere, i am sorry but thats my teacher view.