Mercurial > jmeCapture
comparison src/com/aurellem/capture/RatchetTimer.java @ 73:877ae4b2993c tip
merge laptop changes.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 10 Mar 2014 18:58:08 -0400 |
parents | ddb300c5335f |
children |
comparison
equal
deleted
inserted
replaced
72:dd97f65f940c | 73:877ae4b2993c |
---|---|
9 * | 9 * |
10 * @author normenhansen, Robert McIntyre | 10 * @author normenhansen, Robert McIntyre |
11 */ | 11 */ |
12 | 12 |
13 public class RatchetTimer extends Timer{ | 13 public class RatchetTimer extends Timer{ |
14 private float framerate; | 14 private long framerate; |
15 private int ticks; | 15 private int ticks; |
16 private long lastTime = 0; | 16 private long lastTime = 0; |
17 | 17 |
18 public RatchetTimer(float framerate) { | 18 public RatchetTimer(float framerate) { |
19 this.framerate = framerate; | 19 this.framerate = (long) framerate; |
20 this.ticks = 0; | 20 this.ticks = 0; |
21 } | 21 } |
22 | 22 |
23 /** | 23 /** |
24 * return time in milliseconds | 24 * return time in milliseconds |
25 */ | 25 */ |
26 public long getTime() { | 26 public long getTime() { |
27 return (long) (this.ticks * (1.0f / this.framerate) * 1000f); | 27 return ticks; |
28 } | 28 } |
29 | 29 |
30 public long getResolution() { | 30 public long getResolution() { |
31 return 1000000000L; | 31 return framerate; |
32 } | 32 } |
33 | 33 |
34 public float getFrameRate() { | 34 public float getFrameRate() { |
35 return this.framerate; | 35 return framerate; |
36 } | 36 } |
37 | 37 |
38 public float getTimePerFrame() { | 38 public float getTimePerFrame() { |
39 return (float) (1.0f / this.framerate); | 39 return (float) (1.0f / framerate); |
40 } | 40 } |
41 | 41 |
42 public void update() { | 42 public void update() { |
43 long time = System.currentTimeMillis(); | 43 long time = System.currentTimeMillis(); |
44 long difference = time - lastTime; | 44 long difference = time - lastTime; |