-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBikeTransponderDemo.pde
149 lines (118 loc) · 5.89 KB
/
BikeTransponderDemo.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* @pjs preload="dashboard.png","image1.jpeg","image2.jpeg","image4.jpeg","image5.jpeg","image6.jpeg","image7.jpeg","image8.jpeg","image9.jpeg","image10.jpeg","image11.jpeg","image12.jpeg","image13.jpeg","image14.jpeg","image15.jpeg","image16.jpeg","image17.jpeg","image18.jpeg","image19.jpeg","image21.jpeg","image23.jpeg","image24.jpeg","image25.jpeg","image26.jpeg","image27.jpeg","image28.jpeg","image29.jpeg","image31.jpeg","image32.jpeg","image34.jpeg","image37.jpeg","image41.jpeg","image46.jpeg","image49.jpeg","image50.jpeg","image51.jpeg","image52.jpeg","image53.jpeg","image54.jpeg","image55.jpeg","image56.jpeg","image57.jpeg","image58.jpeg","image59.jpeg","image60.jpeg","image61.jpeg","image62.jpeg","image63.jpeg","image64.jpeg","image65.jpeg","image68.jpeg","image72.jpeg","image77.jpeg","image84.jpeg","image87.jpeg","image89.jpeg","image90.jpeg","image93.jpeg","image97.jpeg","image98.jpeg","image99.jpeg","image100.jpeg","image101.jpeg","image102.jpeg","image103.jpeg","image104.jpeg","image105.jpeg","image106.jpeg","image107.jpeg","image108.jpeg","image109.jpeg","image110.jpeg","image111.jpeg","image112.jpeg","image113.jpeg","image120.jpeg","image123.jpeg","image129.jpeg","image130.jpeg","image138.jpeg","image144.jpeg","image145.jpeg","image153.jpeg","image161.jpeg","image162.jpeg","image166.jpeg","image170.jpeg","image173.jpeg","image176.jpeg","image177.jpeg","image181.jpeg","image187.jpeg","image193.jpeg","image194.jpeg","image195.jpeg","image196.jpeg","image198.jpeg","image200.jpeg","image201.jpeg","image202.jpeg","image203.jpeg","image204.jpeg","image205.jpeg","image206.jpeg","image207.jpeg","image208.jpeg","image210.jpeg","image211.jpeg","image212.jpeg","image213.jpeg","image214.jpeg","image215.jpeg","image216.jpeg","image217.jpeg","image218.jpeg","image219.jpeg","image220.jpeg","image221.jpeg","image222.jpeg","image223.jpeg"; */
ArrayList<Bicycle> bikes = new ArrayList<Bicycle>();
String[] imageNames = {"image1.jpeg","image2.jpeg","image4.jpeg","image5.jpeg","image6.jpeg","image7.jpeg","image8.jpeg","image9.jpeg","image10.jpeg","image11.jpeg","image12.jpeg","image13.jpeg","image14.jpeg","image15.jpeg","image16.jpeg","image17.jpeg","image18.jpeg","image19.jpeg","image21.jpeg","image23.jpeg","image24.jpeg","image25.jpeg","image26.jpeg","image27.jpeg","image28.jpeg","image29.jpeg","image31.jpeg","image32.jpeg","image34.jpeg","image37.jpeg","image41.jpeg","image46.jpeg","image49.jpeg","image50.jpeg","image51.jpeg","image52.jpeg","image53.jpeg","image54.jpeg","image55.jpeg","image56.jpeg","image57.jpeg","image58.jpeg","image59.jpeg","image60.jpeg","image61.jpeg","image62.jpeg","image63.jpeg","image64.jpeg","image65.jpeg","image68.jpeg","image72.jpeg","image77.jpeg","image84.jpeg","image87.jpeg","image89.jpeg","image90.jpeg","image93.jpeg","image97.jpeg","image98.jpeg","image99.jpeg","image100.jpeg","image101.jpeg","image102.jpeg","image103.jpeg","image104.jpeg","image105.jpeg","image106.jpeg","image107.jpeg","image108.jpeg","image109.jpeg","image110.jpeg","image111.jpeg","image112.jpeg","image113.jpeg","image120.jpeg","image123.jpeg","image129.jpeg","image130.jpeg","image138.jpeg","image144.jpeg","image145.jpeg","image153.jpeg","image161.jpeg","image162.jpeg","image166.jpeg","image170.jpeg","image173.jpeg","image176.jpeg","image177.jpeg","image181.jpeg","image187.jpeg","image193.jpeg","image194.jpeg","image195.jpeg","image196.jpeg","image198.jpeg","image200.jpeg","image201.jpeg","image202.jpeg","image203.jpeg","image204.jpeg","image205.jpeg","image206.jpeg","image207.jpeg","image208.jpeg","image210.jpeg","image211.jpeg","image212.jpeg","image213.jpeg","image214.jpeg","image215.jpeg","image216.jpeg","image217.jpeg","image218.jpeg","image219.jpeg","image220.jpeg","image221.jpeg","image222.jpeg","image223.jpeg"};
PImage dashboard;
Bicycle bike1 = new Bicycle(900,10,10,0.25);
ArrayList<PImage> images;
int locator = 0;
int total = 0;
long prevTime = 0;
void setup(){
dashboard = loadImage("dashboard.png");
size(793,716);
//setup timelapse
images = new ArrayList<PImage>();
for (String imageName : imageNames) {
try {
thisImage = loadImage(imageName);
thisImage.resize(1200,600);
images.add(thisImage);
} catch (Exception e) {}
}
total = images.size();
prevTime = millis();
//end timelapse setup
}
void draw(){
//draw road
if (locator == total) {
locator = 0;
}//time between frames = 50 millis
if(prevTime+100 < millis()){
print (locator);
image(images.get(locator), -200, 0);
image(dashboard, 0, 0);
locator++;
prevTime = millis();
}
//end draw road
bike1.display();
bike1.moveRight();
for(int i = 0; i < 9; i++){
if(bike1.getX() <= 0){
bike1.setX(769);
bike1.setY(55);
bike1.setSpeed(bike1.getSpeed()+0.5);
bike1.moveRight();
}
if (i==8){
for(int j = 0; j < 9; j++){
if(bike1.getX() <= 825){
print("hi");
}
if(bike1.getX() <= 0){
bike1.setX(749);
bike1.setY(55);
bike1.setSpeed(bike1.getSpeed()+0.5);
bike1.moveRight();
}
}
}
}
if(key==CODED){
}
}
int timer(int timerLength) {
int remainingTime = timerLength-millis();
if(remainingTime/1000>0){
int actualTime = (remainingTime/1000);
return actualTime;
}
else {
//time = false;
return 0;
}
}
class Bicycle{
int x;
int y;
int z;
double speed;
Bicycle(int x, int y, int z, double speed){
this.x = x;
this.y = y;
this.z = z;
this.speed = speed;
}
void display(){
fill(255,0,0);
rect(x,y,10,10);
}
void moveLeft(){
x+=speed;
}
void moveRight(){
x-=speed;
}
void setX(int x){
this.x = x;
}
int getX(){
return x;
}
void setY(int y){
this.y = y;
}
int getY(){
return y;
}
void setSpeed(double speed){
this.speed = speed;
}
double getSpeed(){
return speed;
}
int getZ(){
return z;
}
}