-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActors.js
More file actions
105 lines (83 loc) · 2.09 KB
/
Actors.js
File metadata and controls
105 lines (83 loc) · 2.09 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
function Actors(x,y,height,width,id){
this.x=x;
this.y=y;
this.id=id;
this.height=height;
this.width=width;
}
Actors.prototype.get_x=function(){
return this.x;
}
Actors.prototype.get_y=function(){
return this.y;
}
Actors.prototype.get_id=function(){
return this.id;
}
Actors.prototype.get_height=function(){
return this.height;
}
Actors.prototype.get_width=function(){
return this.width;
}
Actors.prototype.move=function(a,b){
this.x=a;
this.y=b
}
Actors.prototype.draw=function(){
}
function Pitt_Student(x,y,height,width,id){
Actors.call(this,x,y,height,width,id);
}
Pitt_Student.prototype=Object.create(Actors.prototype);
Pitt_Student.prototype.construtor = Pitt_Student;
Pitt_Student.prototype.draw=function(context){
context.beginPath();
context.moveTo(this.x, this.y + this.height);
context.lineTo(this.x + this.width / 2, this.y);
context.lineTo(this.x + this.width, this.y + this.height);
context.closePath();
context.fill();
}
function Scotty(x,y,height,width,id){
Actors.call(this,x,y,height,width,id);
}
Scotty.prototype=Object.create(Actors.prototype);
Scotty.prototype.constructor=Scotty;
Scotty.prototype.draw=function(context){
context.beginPath();
context.arc(this.x + this.width / 2, this.y + this.height / 2, this.height / 2, 0, 2 * Math.PI, true);
context.closePath();
context.fill();
}
function Fence(x,y,height,width,id){
Actors.call(this,x,y,height,width,id);
}
Fence.prototype=Object.create(Actors.prototype);
Fence.prototype.constructor=Fence;
Fence.prototype.draw=function(context){
context.fillRect(this.x, this.y, this.width, this.height);
}
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=0;i<grid.length;i++){
if (this.grid[i].get_id == a.get_id){
array.splice(i,1);
}
}
}
Grid.prototype.getAllTriangles = function() {
var output = new Array();
for(var i = 0; i<this.grid.length; i++) {
if(this.grid[i].construtor === Pitt_Student) {
output.push(this.grid[i]);
}
}
return output;
}