-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph_constructor.js
More file actions
114 lines (90 loc) · 3.11 KB
/
graph_constructor.js
File metadata and controls
114 lines (90 loc) · 3.11 KB
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
/* this module is a graph builder that will attempt to automatically
* walk in the maze and map all the coordinates and gaps, once that the map is ready
* it could be used by the ghosts to chase pacman properly and more acurately
* than the current slow algorithms :(
*
*/
Window.GraphConstructor = (function(){
var characterArray = [];
var direction = 'right';
var incrix = 0, incriy = 0;
var intx, inty;
var roundRect = function (x, y, w, h, r,color) {
context.lineWidth = 2;
context.strokeStyle = color || 'blue';
//if (w < 2 * r) r = w / 2;
//if (h < 2 * r) r = h / 2;
context.beginPath();
context.moveTo(x+r, y);
context.arcTo(x+w, y, x+w, y+h, r);
context.arcTo(x+w, y+h, x, y+h, r);
context.arcTo(x, y+h, x, y, r);
context.arcTo(x, y, x+w, y, r);
context.fillStyle = 'black';
context.fill();
context.closePath();
context.stroke();
context.restore();
}
return {
characterCoordinate: function(){
return {getCurrentCoordinates: function(){ return [intx,inty]}}
},
characterDirection: function(){
return direction;
},
mapTheMazeSurface: function(){
//Window.Labyrinth.getLimitRanges()
var rangess = 0,
ranges = 0,
context = Window.myCanvas.context;
context.lineWidth = 2;
context.strokeStyle = 'green';
// rangess = [{ node: 'A', ix: 35, iy: 35, fx:35, fy: 35, vertices: ['A','B','C'] },
// { node: 'B', ix: 35, iy: 35, fx:100, fy: 35, vertices: ['A','J','H'] },
// { node: 'C', ix: 35, iy: 35, fx:35, fy: 81, vertices: ['A','F','D'] },
// { node: 'D', ix: 35, iy: 81, fx:35, fy: 120, vertices: ['C','G'] },
// { node: 'F', ix: 35, iy: 81, fx:100, fy: 81, vertices: ['C','B','G','H'] },
// { node: 'G', ix: 35, iy: 120, fx:100, fy: 120, from: ['F','D'] },
// { node: 'F->B', ix: 100, iy: 120, fx:100, fy: 35, vertices: ['C','B','G','H'] },
// { node: 'H', ix: 100, iy: 81, fx:145, fy: 81, vertices: ['F'] },
// ]
Window.Labyrinth.checkHotAreas(this).temperature
ranges = {ix:35,iy:35}
while(true){
context.beginPath();
context.lineWidth = 2;
context.strokeStyle = 'green';
context.moveTo(intx, inty )
intx = ranges['ix'] + (incrix);
inty = ranges['iy'] + (incriy);
// if(i>200){
// debugger;
// }
if( Window.Labyrinth.checkHotAreas(this).temperature){
roundRect(intx + 1 ,inty, 2, 2, 0, "red");
direction = "down"
//debugger;
break
}
if (direction == "right"){
incrix++;
}
if (direction == "down"){
incriy++
}
if (direction == "left"){
incrix--
}
if (direction == "up"){
incriy--
}
context.lineTo(intx, inty);
//context.lineTo(232, inty + (incriy));
context.stroke();
//(x, y, w, h, r)
Window.Labyrinth.checkHotAreas(this)
}
}
}
})();