-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrid.js
More file actions
57 lines (51 loc) · 1.23 KB
/
Grid.js
File metadata and controls
57 lines (51 loc) · 1.23 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
function Grid(){
var grid=new Array();
this.grid=grid;
}
Grid.prototype.add_actor=function(a){
this.grid.push(a);
}
Grid.prototype.rmv_actor=function(a){
for(var i=this.grid.length - 1; i > 0; i--){
if (this.grid[i].get_id() == a.get_id()){
this.grid.splice(i,1);
break;
}
}
}
Grid.prototype.getAllTriangles = function() {
var output = new Array();
for(var i = 0; i<this.grid.length; i++) {
if(this.grid[i].constructor == Triangle) {
output.push(this.grid[i]);
}
}
return output;
}
Grid.prototype.getAllSquares = function() {
var output = new Array();
for(var i = 0; i<this.grid.length; i++) {
if(this.grid[i].constructor == Square) {
output.push(this.grid[i]);
}
}
return output;
}
Grid.prototype.getAllTrianglesAndSquares = function() {
var output = new Array();
for(var i = 0; i<this.grid.length; i++) {
if(this.grid[i].constructor == Square || this.grid[i].constructor == Triangle) {
output.push(this.grid[i]);
}
}
return output;
}
Grid.prototype.getAllCircles = function() {
var output = new Array();
for(var i = 0; i<this.grid.length; i++) {
if(this.grid[i].constructor == Circle) {
output.push(this.grid[i]);
}
}
return output;
}