tags:

views:

665

answers:

1

I want to write a very simple game in Java to demonstrate a wireless controller I've built. I thought of something like Breakout or Pong. Currently, I have a prototype Pong implementation that does all animation directly using the AWT functionality. However, this is somewhat awkward to program and also a major CPU hog.

My question:

Can someone recommend a library for Java to display simple 2D animations? What have you used for similar projects? The library should be easy and straight-forward to use -- I'm not looking for something like Java3D. Integrated collision detection would be a pro.

+1  A: 

This question relates to comparisons of Java 2D frameworks and may be of use.

I'm interested as to why your original implementation is a CPU hog. Is that just whilst it's drawing, or is it consuming CPU resource all the time ? If the latter, it may point to a problem wrt. how you're querying/polling your controllers.

Brian Agnew
Thanks for the link to the post. I guess my application is a CPU hog because I re-draw the screen every 30 ms from a Thread using a double buffer. It's not controller related -- I took the controller-polling out and it still consumes a lot of CPU.I will look into JGame now, as it was suggested in the link you mentioned.
rodion
A dumb question, but do you need to redraw the screen every 30ms ? Or only when a controller/ball moves ? Or perhaps only redraw part of the screen ? Anyway,best of luck!
Brian Agnew
@Brian Agnew/rodian. My guess is that he wants smooth animation of a continuously moving ball... hence redraw every 30ms will give you a nice smooth refresh rate (FPS) of 33.333 (anything above 24 is good in my opinion because 24 is used in movie theatres).
Trevor Boyd Smith
Makes sense. I meant to say 'redraw the *whole* screen every 30ms'
Brian Agnew
Yes, I should have re-drawn the screen in a smarter way, but I was too lazy. I now re-wrote the game using JGame, a framework mentioned in the link you posted, Brian. Thanks for pointing me to the question.
rodion
No problem. Glad it worked out
Brian Agnew