-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
39 lines (35 loc) · 857 Bytes
/
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
var cols;
var rows;
var grid;
var inicio;
var final;
var final_x;
var final_y;
function setup() {
createCanvas(400, 400);
cols = 20;
rows = 20;
tablero = new Game(width,height,cols,rows);
tablero.InicializarNodos();
tablero.AsignarNeighbors();
inicio = tablero.grid[0][0];
final_x = cols- 1;
final_y = rows -1;
final = tablero.grid[final_x][final_y];
inicio.wall = false;
final.wall = false;
algoritmo = new Astar(inicio,final);
}
function draw() {
//final_x=floor(map(mouseX,0,400,0,rows));
//final_y=floor(map(mouseX,0,400,0,cols));
background(100);
//Si no cambia el final entonces sigue ejecutando
algoritmo.Run();
//else / sino ejecuta el nuevo final
tablero.MostrarNodos();
// a=floor(map(mouseX,0,400,0,rows));
// b=floor(map(mouseX,0,400,0,cols));
// console.log(`mouseX => ${a}`);
// console.log(`mouseY => ${b}`);
}