-
Notifications
You must be signed in to change notification settings - Fork 3
/
sketch.js
93 lines (81 loc) · 2.03 KB
/
sketch.js
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
// The Nature of Code
// Daniel Shiffman
// http://natureofcode.com
// A reference to our box2d world
let world;
// A list we'll use to track fixed objects
let boundaries = [];
// A list for all of our rectangles
let boxes = [];
let timer = 0;
let OldSekunden = -1;
let OldMinuten = -1;
function setup()
{
createCanvas(800, 800);
// Initialize box2d physics and create the world
world = createWorld();
//Kasten rundherum
//unten
boundaries.push(new Boundary(0, height - 5, width*2, 5));
//oben
boundaries.push(new Boundary(0,5, width*2, 5));
//links
boundaries.push(new Boundary(5,height, 5, height*2));
//rechts
boundaries.push(new Boundary(width-5,height, 5, height*2));
}
function draw()
{
background(15);
// We must always step through time!
let timeStep = 1.0 / 30;
// 2nd and 3rd arguments are velocity and position iterations
world.Step(timeStep, 10, 10);
if (millis() >= 500+timer)
{
var d = new Date();
var Sekunden = d.getSeconds();
var Minuten = d.getMinutes();
var Stunden = d.getHours();
if(-1==OldSekunden)
{
let bm = new BoxMin(width / 2, 30, Minuten.toString());
boxes.push(bm);
let bs = new BoxStu(width / 2, 30, Stunden.toString());
boxes.push(bs);
}
if (OldSekunden != Sekunden)
{
let b = new BoxSec(width / 2, 30, Sekunden.toString());
boxes.push(b);
}
if(59==OldSekunden && 0==Sekunden)
{
let b = new BoxMin(width / 2, 30, Minuten.toString());
boxes.push(b);
}
if(59==OldMinuten && 0==Minuten)
{
let b = new BoxStu(width / 2, 30, Stunden.toString());
boxes.push(b);
}
OldMinuten=Minuten;
OldSekunden=Sekunden;
timer = millis();
}
// Display all the boundaries
for (let i = 0; i < boundaries.length; i++)
{
boundaries[i].display();
}
// Display all the boxes
for (let i = boxes.length - 1; i >= 0; i--)
{
boxes[i].calColor();
boxes[i].display();
if (boxes[i].done()) {
boxes.splice(i, 1);
}
}
}