source: src/main/java/agents/anac/y2014/BraveCat/necessaryClasses/ContinuousTimeline.java

Last change on this file was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 1.2 KB
Line 
1package agents.anac.y2014.BraveCat.necessaryClasses;
2
3import genius.core.timeline.Timeline;
4
5@SuppressWarnings("serial")
6public class ContinuousTimeline extends Timeline {
7 protected long pauseTime = 0;
8 private final int totalSeconds;
9 protected long startTime;
10
11 public ContinuousTimeline(int totalSecs) {
12 this.totalSeconds = totalSecs;
13 this.startTime = System.nanoTime();
14 this.hasDeadline = true;
15 System.out.println("Started time line of " + totalSecs + " seconds.");
16 }
17
18 public double getElapsedSeconds() {
19 long t2 = System.nanoTime();
20 return (t2 - this.startTime) / 1000000000.0D;
21 }
22
23 public double getElapsedMilliSeconds() {
24 long t2 = System.nanoTime();
25 return (t2 - this.startTime) / 1000000.0D;
26 }
27
28 public long getTotalMiliseconds() {
29 return 1000 * this.totalSeconds;
30 }
31
32 public long getTotalSeconds() {
33 return this.totalSeconds;
34 }
35
36 @Override
37 public double getTime() {
38 double t = getElapsedSeconds() / this.totalSeconds;
39 if (t > 1.0D)
40 t = 1.0D;
41 return t;
42 }
43
44 @Override
45 public double getTotalTime() {
46 return getTotalSeconds();
47 }
48
49 @Override
50 public double getCurrentTime() {
51 return getElapsedSeconds();
52 }
53}
Note: See TracBrowser for help on using the repository browser.