-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessager.js
91 lines (77 loc) · 2.24 KB
/
messager.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
function Messager() {
tlWidth = 100;
radius = 45;
tlHeight = 3 * tlWidth;
tlX = stage_size / 2 - tlWidth / 2;
tlY = stage_size / 2 - tlHeight / 2;
gr = null;
this.drawYouDied = function() {
var text = new Text("You lose.", "bold 100px Arial", "#ff0000");
text.textAlign = "center";
text.textBaseline = "middle";
text.x = stage_size / 2;
text.y = stage_size / 2;
return text;
};
this.drawYouWin = function() {
var text = new Text("You win.", "bold 100px Arial", "#ff0000");
text.textAlign = "center";
text.textBaseline = "middle";
text.x = stage_size / 2;
text.y = stage_size / 2;
return text;
};
this.drawResult = function(data) {
var str = "Result:"
for (var i = 0; i < data.deathOrder.length; i++) {
str += "\r\n";
str += (i + 1) + ". " + data.deathOrder[i].substring(0, 4);
}
var text = new Text(str, "bold 60px Arial", "#ffffff");
text.textAlign = "center";
text.textBaseline = "middle";
text.x = stage_size / 2;
text.y = stage_size / 2 - (1 + data.deathOrder.length) / 2 * text.getMeasuredLineHeight();
return text;
}
function drawEmptyTL() {
gr.beginStroke("#c3c3c3");
gr.drawRect(tlX, tlY, tlWidth, tlHeight);
gr.endStroke();
gr.beginStroke("#c3c3c3");
gr.drawCircle(stage_size / 2, stage_size / 2 - tlHeight / 3, radius);
gr.endStroke();
gr.beginStroke("#c3c3c3");
gr.drawCircle(stage_size / 2, stage_size / 2 , radius);
gr.endStroke();
gr.beginStroke("#c3c3c3");
gr.drawCircle(stage_size / 2, stage_size / 2 + tlHeight / 3, radius);
gr.endStroke();
stage.update();
setTimeout(draw1stYellowLight, 500);
}
function draw1stYellowLight() {
gr.beginFill("#ffff00");
gr.drawCircle(stage_size / 2, stage_size / 2 - tlHeight / 3, radius);
gr.endFill();
stage.update();
setTimeout(draw2ndYellowLight, 500);
}
function draw2ndYellowLight() {
gr.beginFill("#ffff00");
gr.drawCircle(stage_size / 2, stage_size / 2 , radius);
gr.endFill();
stage.update();
setTimeout(drawGreenLight, 500);
}
function drawGreenLight() {
gr.beginFill("#00ff00");
gr.drawCircle(stage_size / 2, stage_size / 2 + tlHeight / 3, radius);
gr.endFill();
stage.update();
}
this.playTrafficLightAmimation = function(image) {
gr = image.graphics;
drawEmptyTL();
}
};