-
Notifications
You must be signed in to change notification settings - Fork 10
/
Blockchain.js
59 lines (49 loc) · 1.19 KB
/
Blockchain.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
function Blockchain(data) {
this.raised = false;
this.raising = false;
this.velocity = 12;
this.c = 80;
this.x = 0;
this.y = windowHeight;
this.width = windowWidth;
this.height = 190;
this.show = function() {
fill(this.c);
rect(this.x, this.y, this.x + this.width, this.y + this.height);
// Title
noStroke();
fill(0, 0, 20);
textSize(30);
textAlign(LEFT);
text("latest block", 10, this.y + 40);
// No Blocks Mined Placeholder
if (block_count === 0) {
textAlign(CENTER);
fill(0, 0, 40);
textSize(24);
text("No Blocks Mined In The Last", this.width/2, this.y+(this.height/2));
text(fancyTimeFormat(Math.floor(millis()/1000)), this.width/2, this.y+(this.height/2)+32);
}
}
this.raise = function() {
if (this.y > windowHeight - this.height) {
this.y -= this.velocity;
this.raising = true;
}
else {
this.y = windowHeight - this.height;
this.raising = false;
}
}
this.lower = function() {
if (this.y < windowHeight) {
this.y += this.velocity;
}
else {
this.y = windowHeight;
}
}
this.update = function() {
this.width = windowWidth;
}
}