-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathObjectMover.pde
More file actions
41 lines (31 loc) · 764 Bytes
/
Copy pathObjectMover.pde
File metadata and controls
41 lines (31 loc) · 764 Bytes
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
abstract class Movable {
int startX, startY, nowX, nowY;
int endX, endY;
float curFrames, dxFrames;
PImage gToMove;
boolean done = false;
void setDuration(float secs) {
curFrames = secs * frameRate;
dxFrames = 1.0/curFrames;
done = false;
}
void draw(PGraphics g) {
if(this.gToMove == null) return;
if (!done) {
float curRatio = 1.0 -( curFrames * dxFrames );
nowX = (int)lerp(startX, endX, curRatio);
nowY = (int)lerp(startY, endY, curRatio);
}
g.image(gToMove, nowX, nowY);
curFrames--;
done = (curFrames <= 0);
}
}
class ObjectMover {
List<Movable> movables = new ArrayList();
void draw(PGraphics g) {
for (Movable m : movables) {
m.draw(g);
}
}
}