Mercurial > jmeCapture
comparison src/com/aurellem/capture/IsoTimer.java @ 56:afc437f637bd
improved formating
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Dec 2011 19:25:27 -0600 |
parents | 6484a820e27d |
children | 5afa49c5a7d3 |
comparison
equal
deleted
inserted
replaced
55:b05f629fc296 | 56:afc437f637bd |
---|---|
10 * your wall, then the ball should have traveled exactly one | 10 * your wall, then the ball should have traveled exactly one |
11 * game-mile. In order to keep sync with the real world, the game | 11 * game-mile. In order to keep sync with the real world, the game |
12 * throttles its physics engine and graphics display. If the | 12 * throttles its physics engine and graphics display. If the |
13 * computations involved in running the game are too intense, then the | 13 * computations involved in running the game are too intense, then the |
14 * game will first skip frames, then sacrifice physics accuracy. If | 14 * game will first skip frames, then sacrifice physics accuracy. If |
15 * there are particularly demanding computations, then you may only get | 15 * there are particularly demanding computations, then you may only |
16 * 1 fps, and the ball may tunnel through the floor or obstacles due | 16 * get 1 fps, and the ball may tunnel through the floor or obstacles |
17 * to inaccurate physics simulation, but after the end of one | 17 * due to inaccurate physics simulation, but after the end of one |
18 * user-hour, that ball will have traveled one game-mile. | 18 * user-hour, that ball will have traveled one game-mile. |
19 * | 19 * |
20 * When we're recording video or audio, we don't care if the game-time | 20 * When we're recording video or audio, we don't care if the game-time |
21 * syncs with user-time, but instead whether the time in the recorded | 21 * syncs with user-time, but instead whether the time in the recorded |
22 * video (video-time) syncs with user-time. To continue the analogy, | 22 * video (video-time) syncs with user-time. To continue the analogy, |
34 * | 34 * |
35 */ | 35 */ |
36 | 36 |
37 public class IsoTimer extends Timer { | 37 public class IsoTimer extends Timer { |
38 | 38 |
39 private float framerate; | 39 private float framerate; |
40 private int ticks; | 40 private int ticks; |
41 | 41 |
42 public IsoTimer(float framerate){ | 42 public IsoTimer(float framerate){ |
43 this.framerate = framerate; | 43 this.framerate = framerate; |
44 this.ticks = 0; | 44 this.ticks = 0; |
45 } | 45 } |
46 | 46 |
47 public long getTime() { | 47 public long getTime() { |
48 return (long) (this.ticks / this.framerate); | 48 return (long) (this.ticks / this.framerate); |
49 } | 49 } |
50 | 50 |
51 public long getResolution() { | 51 public long getResolution() { |
52 return 1000000000L; | 52 return 1000000000L; |
53 } | 53 } |
54 | 54 |
55 public float getFrameRate() { | 55 public float getFrameRate() { |
56 return this.framerate; | 56 return this.framerate; |
57 } | 57 } |
58 | 58 |
59 public float getTimePerFrame() { | 59 public float getTimePerFrame() { |
60 return (float) (1.0f / this.framerate); | 60 return (float) (1.0f / this.framerate); |
61 } | 61 } |
62 | 62 |
63 public void update() {this.ticks++;} | 63 public void update() {this.ticks++;} |
64 | 64 |
65 public void reset() {this.ticks = 0;} | 65 public void reset() {this.ticks = 0;} |
66 | 66 |
67 } | 67 } |