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

Started by
0 comments, last by Kentaro 21 years, 3 months ago
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
Over the centuries, mankind has tried many ways of combating the forces of evil...prayer,fasting, good works and so on. Up until Doom, no one seemed to have thought about thedouble-barrel shotgun. Eat leaden death, demon... -- Terry Pratchett
Advertisement
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.
Star Dart - Java Multiplayer Space Combat at http://www.stardart.net/

This topic is closed to new replies.

Advertisement