Mercurial > hg > ristipolku
diff game/Engine.java @ 24:1be98362e5e9
FPS measurement.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 01 Feb 2011 16:22:46 +0200 |
parents | 0741dc117808 |
children | bbac3e4a4b9b |
line wrap: on
line diff
--- a/game/Engine.java Tue Feb 01 09:55:09 2011 +0200 +++ b/game/Engine.java Tue Feb 01 16:22:46 2011 +0200 @@ -199,7 +199,7 @@ GameBoard lauta = null; BufferedImage lautaBG = null, lautaBGScaled = null; Dimension oldDim; - float clock; + float clock, frames; SoundElement[] sounds; public SoundElement snd(Sound snd) @@ -216,7 +216,7 @@ try { - ResourceLoader res = new ResourceLoader("graphics/board.png"); + ResourceLoader res = new ResourceLoader("graphics/board.jpg"); lautaBG = ImageIO.read(res.getStream()); sounds = new SoundElement[16]; @@ -361,8 +361,14 @@ lauta.animate(clock); - if (clock % 2 == 1) + if (clock % 3 == 1) + { repaint(); + frames++; + + if (frames % 10 == 1) + System.out.print("fps = "+ ((clock * 10) / frames) +"\n"); + } try { Thread.sleep(10);