-
Notifications
You must be signed in to change notification settings - Fork 3
/
GesturePlayer.pde
61 lines (47 loc) · 1.01 KB
/
GesturePlayer.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
class GesturePlayer{
int cTime, sTime;
float position;
Table table;
int rowNum;
int numRows;
TableRow theRow;
boolean backAtZero = true;
GesturePlayer(String fileName){
init(fileName);
}
void init(String fileName){
rowNum = 0;
backAtZero = false;
table = loadTable(fileName,"header");
numRows = table.getRowCount();
theRow = table.getRow(rowNum);
cTime = theRow.getInt("time");
sTime = millis();
position = theRow.getFloat("value");
}
boolean update(float iTime){
if(backAtZero)
sTime = millis();
backAtZero = false;
if(iTime - sTime >= cTime){
rowNum++;
if(rowNum >= numRows){
rowNum = 0;
backAtZero = true;
}
theRow = table.getRow(rowNum);
cTime = theRow.getInt("time");
position = theRow.getFloat("value");
}
return backAtZero;
}
int getTime(){
return cTime;
}
void resetTime(){
backAtZero = true;
}
float getPosition(){
return position;
}
}