Skip to content

Commit dff3c1e

Browse files
Changed let to const
Changed let to const wherever possible.
1 parent 0daeb72 commit dff3c1e

File tree

18 files changed

+66
-66
lines changed

18 files changed

+66
-66
lines changed

src/data/examples/en/10_Interaction/21_Follow2.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ function draw() {
2222
}
2323

2424
function dragSegment(i, xin, yin) {
25-
let dx = xin - x[i];
26-
let dy = yin - y[i];
27-
let angle = atan2(dy, dx);
25+
const dx = xin - x[i];
26+
const dy = yin - y[i];
27+
const angle = atan2(dy, dx);
2828
x[i] = xin - cos(angle) * segLength;
2929
y[i] = yin - sin(angle) * segLength;
3030
segment(x[i], y[i], angle);

src/data/examples/en/10_Interaction/22_Follow3.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ function draw() {
3030
}
3131

3232
function dragSegment(i, xin, yin) {
33-
let dx = xin - x[i];
34-
let dy = yin - y[i];
35-
let angle = atan2(dy, dx);
33+
const dx = xin - x[i];
34+
const dy = yin - y[i];
35+
const angle = atan2(dy, dx);
3636
x[i] = xin - cos(angle) * segLength;
3737
y[i] = yin - sin(angle) * segLength;
3838
segment(x[i], y[i], angle);

src/data/examples/en/10_Interaction/23_snake.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
let numSegments = 10;
1111
let direction = 'right';
1212

13-
let xStart = 0; //starting x coordinate for snake
14-
let yStart = 250; //starting y coordinate for snake
15-
let diff = 10;
13+
const xStart = 0; //starting x coordinate for snake
14+
const yStart = 250; //starting y coordinate for snake
15+
const diff = 10;
1616

1717
let xCor = [];
1818
let yCor = [];
@@ -99,7 +99,7 @@ function checkGameStatus() {
9999
checkSnakeCollision()
100100
) {
101101
noLoop();
102-
let scoreVal = parseInt(scoreElem.html().substring(8));
102+
const scoreVal = parseInt(scoreElem.html().substring(8));
103103
scoreElem.html('Game ended! Your score was : ' + scoreVal);
104104
}
105105
}
@@ -109,8 +109,8 @@ function checkGameStatus() {
109109
has to be the same as one of its own segment's (x,y) coordinate.
110110
*/
111111
function checkSnakeCollision() {
112-
let snakeHeadX = xCor[xCor.length - 1];
113-
let snakeHeadY = yCor[yCor.length - 1];
112+
const snakeHeadX = xCor[xCor.length - 1];
113+
const snakeHeadY = yCor[yCor.length - 1];
114114
for (let i = 0; i < xCor.length - 1; i++) {
115115
if (xCor[i] === snakeHeadX && yCor[i] === snakeHeadY) {
116116
return true;
@@ -126,7 +126,7 @@ function checkSnakeCollision() {
126126
function checkForFruit() {
127127
point(xFruit, yFruit);
128128
if (xCor[xCor.length - 1] === xFruit && yCor[yCor.length - 1] === yFruit) {
129-
let prevScore = parseInt(scoreElem.html().substring(8));
129+
const prevScore = parseInt(scoreElem.html().substring(8));
130130
scoreElem.html('Score = ' + (prevScore + 1));
131131
xCor.unshift(xCor[0]);
132132
yCor.unshift(yCor[0]);

src/data/examples/en/10_Interaction/24_Wavemaker.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ function draw() {
2020
for (let x = 0; x <= width; x = x + 30) {
2121
for (let y = 0; y <= height; y = y + 30) {
2222
// starting point of each circle depends on mouse position
23-
let xAngle = map(mouseX, 0, width, -4 * PI, 4 * PI, true);
24-
let yAngle = map(mouseY, 0, height, -4 * PI, 4 * PI, true);
23+
const xAngle = map(mouseX, 0, width, -4 * PI, 4 * PI, true);
24+
const yAngle = map(mouseY, 0, height, -4 * PI, 4 * PI, true);
2525
// and also varies based on the particle's location
26-
let angle = xAngle * (x / width) + yAngle * (y / height);
26+
const angle = xAngle * (x / width) + yAngle * (y / height);
2727

2828
// each particle moves in a circle
29-
let myX = x + 20 * cos(2 * PI * t + angle);
30-
let myY = y + 20 * sin(2 * PI * t + angle);
29+
const myX = x + 20 * cos(2 * PI * t + angle);
30+
const myY = y + 20 * sin(2 * PI * t + angle);
3131

3232
ellipse(myX, myY, 10); // draw particle
3333
}

src/data/examples/en/10_Interaction/26_reach2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ function positionSegment(a, b) {
4848
}
4949

5050
function reachSegment(i, xin, yin) {
51-
let dx = xin - x[i];
52-
let dy = yin - y[i];
51+
const dx = xin - x[i];
52+
const dy = yin - y[i];
5353
angle[i] = atan2(dy, dx);
5454
targetX = xin - cos(angle[i]) * segLength;
5555
targetY = yin - sin(angle[i]) * segLength;

src/data/examples/en/10_Interaction/27_reach3.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ function positionSegment(a, b) {
6464
}
6565

6666
function reachSegment(i, xin, yin) {
67-
let dx = xin - x[i];
68-
let dy = yin - y[i];
67+
const dx = xin - x[i];
68+
const dy = yin - y[i];
6969
angle[i] = atan2(dy, dx);
7070
targetX = xin - cos(angle[i]) * segLength;
7171
targetY = yin - sin(angle[i]) * segLength;

src/data/examples/es/10_Interaction/21_Follow2.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ function draw() {
2222
}
2323

2424
function dragSegment(i, xin, yin) {
25-
let dx = xin - x[i];
26-
let dy = yin - y[i];
27-
let angle = atan2(dy, dx);
25+
const dx = xin - x[i];
26+
const dy = yin - y[i];
27+
const angle = atan2(dy, dx);
2828
x[i] = xin - cos(angle) * segLength;
2929
y[i] = yin - sin(angle) * segLength;
3030
segment(x[i], y[i], angle);

src/data/examples/es/10_Interaction/22_Follow3.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ function draw() {
3030
}
3131

3232
function dragSegment(i, xin, yin) {
33-
let dx = xin - x[i];
34-
let dy = yin - y[i];
35-
let angle = atan2(dy, dx);
33+
const dx = xin - x[i];
34+
const dy = yin - y[i];
35+
const angle = atan2(dy, dx);
3636
x[i] = xin - cos(angle) * segLength;
3737
y[i] = yin - sin(angle) * segLength;
3838
segment(x[i], y[i], angle);

src/data/examples/es/10_Interaction/23_snake.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
let numeroSegmentos = 10;
1111
let direccion = 'derecha';
1212

13-
let xInicio = 0; //coordenada x de partida de la serpiente
14-
let yInicio = 250; //coordenada y de partida de la serpiente
15-
let diferencia = 10;
13+
const xInicio = 0; //coordenada x de partida de la serpiente
14+
const yInicio = 250; //coordenada y de partida de la serpiente
15+
const diferencia = 10;
1616

1717
let xCuerpo = [];
1818
let yCuerpo = [];
@@ -100,7 +100,7 @@ function comprobarEstadoJuego() {
100100
detectarColision()
101101
) {
102102
noLoop();
103-
let puntajeValor = parseInt(elementoPuntaje.html().substring(8));
103+
const puntajeValor = parseInt(elementoPuntaje.html().substring(8));
104104
elementoPuntaje.html('Juego finalizado! Tu puntaje fue: ' + puntajeValor);
105105
}
106106
}
@@ -110,8 +110,8 @@ function comprobarEstadoJuego() {
110110
(x,y) tiene que ser igual a la de un segmento propio.
111111
*/
112112
function detectarColision() {
113-
let cabezaSerpienteX = xCuerpo[xCuerpo.length - 1];
114-
let cabezaSerpienteY = yCuerpo[yCuerpo.length - 1];
113+
const cabezaSerpienteX = xCuerpo[xCuerpo.length - 1];
114+
const cabezaSerpienteY = yCuerpo[yCuerpo.length - 1];
115115
for (let i = 0; i < xCuerpo.length - 1; i++) {
116116
if (xCuerpo[i] === cabezaSerpienteX && yCuerpo[i] === cabezaSerpienteY) {
117117
return true;
@@ -130,7 +130,7 @@ function comprobarFruta() {
130130
xCuerpo[xCuerpo.length - 1] === xFruta &&
131131
yCuerpo[yCuerpo.length - 1] === yFruta
132132
) {
133-
let prevScore = parseInt(elementoPuntaje.html().substring(8));
133+
const prevScore = parseInt(elementoPuntaje.html().substring(8));
134134
elementoPuntaje.html('Score = ' + (prevScore + 1));
135135
xCuerpo.unshift(xCuerpo[0]);
136136
yCuerpo.unshift(yCuerpo[0]);

src/data/examples/es/10_Interaction/24_Wavemaker.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ function draw() {
2020
for (let x = 0; x <= width; x = x + 30) {
2121
for (let y = 0; y <= height; y = y + 30) {
2222
// punto de partida de cada círculo depende de posición del ratón
23-
let anguloX = map(mouseX, 0, width, -4 * PI, 4 * PI, true);
24-
let anguloY = map(mouseY, 0, height, -4 * PI, 4 * PI, true);
23+
const anguloX = map(mouseX, 0, width, -4 * PI, 4 * PI, true);
24+
const anguloY = map(mouseY, 0, height, -4 * PI, 4 * PI, true);
2525
// y también varía según la posición de la partícula
26-
let angulo = anguloX * (x / width) + anguloY * (y / height);
26+
const angulo = anguloX * (x / width) + anguloY * (y / height);
2727

2828
// cada partícula se mueve en forma circular
29-
let myX = x + 20 * cos(2 * PI * t + angulo);
30-
let myY = y + 20 * sin(2 * PI * t + angulo);
29+
const myX = x + 20 * cos(2 * PI * t + angulo);
30+
const myY = y + 20 * sin(2 * PI * t + angulo);
3131

3232
ellipse(myX, myY, 10); // dibujar partícula
3333
}

0 commit comments

Comments
 (0)