changeset 24:1be98362e5e9

FPS measurement.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 01 Feb 2011 16:22:46 +0200
parents 0741dc117808
children bbac3e4a4b9b
files Makefile game/Engine.java
diffstat 2 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Tue Feb 01 09:55:09 2011 +0200
+++ b/Makefile	Tue Feb 01 16:22:46 2011 +0200
@@ -1,7 +1,7 @@
 # Settings, directories
 RUN=Ristipolku.class
 
-RESOURCES=graphics/board.png sounds/*.wav
+RESOURCES=graphics/*.png graphics/*.jpg sounds/*.wav
 
 CLASSES=game/Piece.java game/PieceType.java game/Engine.java game/Interpolate.java game/ResourceLoader.java
 
--- 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);