-
Notifications
You must be signed in to change notification settings - Fork 1
/
testPVector.pde
77 lines (52 loc) · 1.01 KB
/
testPVector.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
double t = 0.0;
double dt = .01;
double currentTime;
double accumulator;
PGraphics pg;
myCircle mC;
void setup() {
size(500, 500);
pg = createGraphics(500, 500);
currentTime = millis();
accumulator = 0.0;
mC = new myCircle(width/2, height/2);
}
void draw() {
double newTime = millis();
double frameTime = newTime - currentTime ;
frameTime /= 1000;
currentTime = newTime;
accumulator += frameTime;
printFPS();
while(accumulator >= dt) {
t += dt;
accumulator -= dt;
}
disp();
}
void disp() {
pg.beginDraw();
pg.background(255);
mC.show();
pg.endDraw();
image(pg, 0, 0);
}
void printFPS() {
if(frameCount % 50 == 0) {
println(rameCount / (millis()/1000f));
}
}
void mouseMoved() {
mC.x = mouseX;
mC.y = mouseY;
}
class myCircle() {
float x, y;
myCircle(float x, float y) {
this.x = x;
this.y = y;
}
void show() {
pg.ellipse(this.x, this.y, 10, 10);
}
}