-
Notifications
You must be signed in to change notification settings - Fork 0
/
canvas.js
175 lines (153 loc) · 3.92 KB
/
canvas.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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
//¡draw-canvas
function divujarCanvas() {
tablero.lineWidth = 8;
tablero.lineCap = "round";
tablero.lineJoin = "round";
tablero.fillStyle = "#F3F5F6";
tablero.strokeStyle = "#5e6ce8";
tablero.fillRect(0, 0, 660, 500);
}
//¡draw-floor-line
function divujarLinea() {
tablero.lineWidth = 6;
tablero.lineCap = "round";
tablero.lineJoin = "round";
tablero.fillStyle = "#F3F5F6";
tablero.strokeStyle = "#5e6ce8";
let anchura = 600 / palabraSecreta.length;
for (let i = 0; i < palabraSecreta.length; i++) {
tablero.moveTo(90 + anchura * i, 350);
tablero.lineTo(60 + anchura * i, 350);
}
tablero.stroke();
tablero.closePath();
}
//¡draw-floor
function divujarPiso() {
tablero.beginPath();
tablero.moveTo(400, 300);
tablero.lineTo(210, 300);
tablero.stroke();
tablero.closePath();
}
//¡draw-vertical-line
function divujarLineaRecta() {
tablero.lineWidth = 8;
tablero.lineCap = "round";
tablero.lineJoin = "round";
tablero.fillStyle = "#F3F5F6";
tablero.strokeStyle = "#5e6ce8";
tablero.fillRect(200, 50, 100, 100);
tablero.beginPath();
tablero.moveTo(290, 90);
tablero.lineTo(290, 298);
tablero.stroke();
tablero.closePath();
}
//¡draw-horizontal-line
function divujarLineaHorizontal() {
tablero.lineWidth = 8;
tablero.lineCap = "round";
tablero.lineJoin = "round";
tablero.fillStyle = "#F3F5F6";
tablero.strokeStyle = "#5e6ce8";
tablero.beginPath();
tablero.moveTo(365, 88);
tablero.lineTo(290, 88);
tablero.stroke();
tablero.closePath();
}
//¡draw-hang
function divujarhorca() {
tablero.lineWidth = 8;
tablero.lineCap = "round";
tablero.lineJoin = "round";
tablero.fillStyle = "#F3F5F6";
tablero.strokeStyle = "#5e6ce8";
tablero.beginPath();
tablero.moveTo(365, 125);
tablero.lineTo(365, 90);
tablero.stroke();
tablero.closePath();
}
//¡draw-head
function divujarCara() {
tablero.beginPath();
tablero.arc(365, 145, 18, 0, Math.PI * 2, true);
tablero.stroke();
tablero.closePath();
}
//¡draw-body
function divujarCuerpo() {
tablero.moveTo(365, 227);
tablero.lineTo(365, 163);
tablero.stroke();
tablero.closePath();
}
//¡draw-arms
function divujarBrazos() {
tablero.beginPath();
tablero.moveTo(365, 163);
tablero.lineTo(390, 205);
tablero.moveTo(365, 163);
tablero.lineTo(340, 205);
tablero.stroke();
tablero.closePath();
}
//¡ draw-legs--+menssage-end-game
function divujarPiernas() {
tablero.beginPath();
tablero.moveTo(365, 230);
tablero.lineTo(385, 265);
tablero.moveTo(365, 165);
tablero.lineTo(345, 265);
tablero.stroke();
tablero.closePath();
finDelJuego();
reinicio();
}
//¡draw-corrrect-letter
function escribirLetraCorrecta(index) {
tablero.font = "bold 40px Inter";
tablero.lineWidth = 6;
tablero.lineCap = "round";
tablero.lineJoin = "round";
tablero.fillStyle = "#5e6ce8";
let anchura = 600 / palabraSecreta.length;
tablero.fillText(palabraSecreta[index], 60 + anchura * index, 343);
tablero.stroke();
}
//¡draw-incorrect-letter
function escribirLetraIncorrecta(letra, errorsLeft) {
let errores = 7;
tablero.font = "bold 40px Inter";
tablero.lineWidth = 6;
tablero.lineCap = "round";
tablero.lineJoin = "round";
tablero.fillStyle = "#5e6ce8";
tablero.fillText(letra, 10 + 40 * (11 - errorsLeft), 400, 12);
letras.push(letra.toUpperCase());
dibujoHombreAhorcado(letras.length);
if (letras.length == errores) {
derrotaReinicio();
}
}
//¡draw-letter-end-game
function finDelJuego() {
tablero.lineWidth = 5;
tablero.lineCap = "round";
tablero.lineJoin = "round";
tablero.font = "bold 35px Inter";
tablero.fillStyle = "#ff0000";
tablero.fillText("Fin del juego!", 392, 200);
}
//¡draw-message-winner
function ganadorJuego() {
tablero.lineWidth = 5;
tablero.lineCap = "round";
tablero.lineJoin = "round";
tablero.font = "bold 40px Inter";
tablero.fillStyle = "#008000";
tablero.fillText("Ganaste ", 0, 150);
tablero.fillText("Felicidades!", 0, 210);
}