Archived

This topic is now archived and is closed to further replies.

Kentaro

[java] Is this timing idea practical...?

Recommended Posts

I recently coded a quick and dirty pong game. My game loop was logic processing followed by a call to repaint() for the graphics stuff (of course, I''d overridden the protected paintComponent(Graphics g) method myself). To slow the loop down, I implemented a "sleep" timer class I''d heard about on the web. I put my game loop in a run() method followed by a synchronized block that tells the game logic thread to wait for notification from the "sleep" timer thread. The timer wakes up 30 times every second (or however many times I want) and notifies the game logic thread. This timer idea worked well for pong, but is it practical for other types of games? This isn''''t life in the fast lane, it''''s life in the oncoming traffic. -- Terry Pratchett

Share this post


Link to post
Share on other sites
This doesn''t directly answer your question, but one thing you will run into is that in almost all game development situations, you are going to need to use active rendering rather than passive (calling repaint()). The tutorial at java.sun.com/books/tutorial touches on this in it''s fullscreen section, but if you search google or the forums at javagaming.org I''m sure you''ll turn up some pertinent information.

Share this post


Link to post
Share on other sites