-
Notifications
You must be signed in to change notification settings - Fork 0
/
TrainSim.pde
70 lines (69 loc) · 1.58 KB
/
TrainSim.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
int Distance;
float a;
ArrayList<Anomaly> Anomalies = new ArrayList<Anomaly>();
int anomalycount = 0;
boolean wr = false;
void setup()
{
PFont f;
Distance = 10;
stroke(255);
size(1920,1080);
printArray(PFont.list());
f = createFont("SourceCodePro-Regular.tff",24);
textFont(f);
a = height;
textAlign(LEFT,LEFT);
}
void draw()
{
background(178,190,181);
int margin = 10;
translate(margin*4, margin*4);
Distance++;
text("Train Distance: "+Distance/10, 10, 25);
Train();
TrainTrack();
Anomalies();
}
public class Anomaly{
int Angle = int(random(45));
float Speed = random(10,20);
int DfromT = int(random(850));
int StartD = (int(random(1000)));
}
void Anomalies()
{
int r = int(random(100));
if (Distance>100 && r==25){
Anomaly a = new Anomaly();
Anomalies.add(a);
anomalycount++;
}
for(int i = 0; i<anomalycount; i++){
if(((Anomalies.get(i).DfromT)<850&&(Anomalies.get(i).DfromT)<1900)||(Anomalies.get(i).StartD<900)){
DrawAnomaly(i);
}
}
}
void DrawAnomaly(int AnomalyCount){
int Distance = Anomalies.get(AnomalyCount).DfromT;
int Angle = Anomalies.get(AnomalyCount).Angle;
float Speed = Anomalies.get(AnomalyCount).Speed;
int StartD = (Anomalies.get(AnomalyCount).StartD);
Anomalies.get(AnomalyCount).DfromT = Distance+1;
circle(Distance, StartD, 50);
}
void Train(){
rect(825,900,215,100);
}
void TrainTrack()
{
for(int x=1; x<35;x++){
line(850, (a+(50*x)-100), width-(900), (a+(50*x))-100);
}
a = a + 2;
if (a>100) {
a = 0;
}
}