Re: Requesting tips, comments for an EDT thread-safe game architecture
- From: "Oliver Wong" <owong@xxxxxxxxxxxxxx>
- Date: Thu, 22 Mar 2007 12:03:00 -0400
"Oliver Wong" <owong@xxxxxxxxxxxxxx> wrote in message
news:soxMh.490$NM.6958@xxxxxxxxxxxxxxxxxxxxxxx
[most of the code snipped]
/*
* This while loop is the main game loop. It basically iterates through
* 3 stages forever: getting the player input, reacting to it, and
* drawing the results on screen.
*/
while (!timeToQuit) {
getPlayerInput();
processGameLogic();
EventQueue.invokeAndWait(new Runnable() {
@Override
public void run() {
if (mainWindow != null) {
BufferStrategy strategy = mainWindow
.getBufferStrategy();
Graphics2D g = (Graphics2D) strategy.getDrawGraphics();
Insets insets = mainWindow.getInsets();
g.translate(insets.left, insets.top);
g.setTransform(AffineTransform
.getScaleInstance(
(double) (mainWindow.getWidth() - insets.right)
/ (double) DEFAULT_RENDERING_WIDTH,
(double) (mainWindow
.getHeight() - insets.bottom)
/ (double) DEFAULT_RENDERING_HEIGHT));
updateScreen(g);
Oops, I should probably call g.dispose() here.
strategy.show();
}
}
});
Thread.sleep(1);
}
- Oliver
.
- Follow-Ups:
- Re: Requesting tips, comments for an EDT thread-safe game architecture
- From: Knute Johnson
- Re: Requesting tips, comments for an EDT thread-safe game architecture
- References:
- Requesting tips, comments for an EDT thread-safe game architecture
- From: Oliver Wong
- Re: Requesting tips, comments for an EDT thread-safe game architecture
- From: Knute Johnson
- Re: Requesting tips, comments for an EDT thread-safe game architecture
- From: Daniel Pitts
- Re: Requesting tips, comments for an EDT thread-safe game architecture
- From: Oliver Wong
- Requesting tips, comments for an EDT thread-safe game architecture
- Prev by Date: How do you set an Icon into a JButton?
- Next by Date: Re: How do you set an Icon into a JButton?
- Previous by thread: Re: Requesting tips, comments for an EDT thread-safe game architecture
- Next by thread: Re: Requesting tips, comments for an EDT thread-safe game architecture
- Index(es):