Mercurial > hg > ristipolku
comparison 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 |
comparison
equal
deleted
inserted
replaced
23:0741dc117808 | 24:1be98362e5e9 |
---|---|
197 Thread animThread; | 197 Thread animThread; |
198 boolean animEnable = false; | 198 boolean animEnable = false; |
199 GameBoard lauta = null; | 199 GameBoard lauta = null; |
200 BufferedImage lautaBG = null, lautaBGScaled = null; | 200 BufferedImage lautaBG = null, lautaBGScaled = null; |
201 Dimension oldDim; | 201 Dimension oldDim; |
202 float clock; | 202 float clock, frames; |
203 | 203 |
204 SoundElement[] sounds; | 204 SoundElement[] sounds; |
205 public SoundElement snd(Sound snd) | 205 public SoundElement snd(Sound snd) |
206 { | 206 { |
207 return sounds[snd.ordinal()]; | 207 return sounds[snd.ordinal()]; |
214 | 214 |
215 System.out.print("Engine() constructor\n"); | 215 System.out.print("Engine() constructor\n"); |
216 | 216 |
217 try | 217 try |
218 { | 218 { |
219 ResourceLoader res = new ResourceLoader("graphics/board.png"); | 219 ResourceLoader res = new ResourceLoader("graphics/board.jpg"); |
220 lautaBG = ImageIO.read(res.getStream()); | 220 lautaBG = ImageIO.read(res.getStream()); |
221 | 221 |
222 sounds = new SoundElement[16]; | 222 sounds = new SoundElement[16]; |
223 for (Sound s : Sound.values()) | 223 for (Sound s : Sound.values()) |
224 { | 224 { |
359 { | 359 { |
360 clock++; | 360 clock++; |
361 | 361 |
362 lauta.animate(clock); | 362 lauta.animate(clock); |
363 | 363 |
364 if (clock % 2 == 1) | 364 if (clock % 3 == 1) |
365 { | |
365 repaint(); | 366 repaint(); |
367 frames++; | |
368 | |
369 if (frames % 10 == 1) | |
370 System.out.print("fps = "+ ((clock * 10) / frames) +"\n"); | |
371 } | |
366 | 372 |
367 try { | 373 try { |
368 Thread.sleep(10); | 374 Thread.sleep(10); |
369 } | 375 } |
370 | 376 |