-
Notifications
You must be signed in to change notification settings - Fork 0
/
Food.js
55 lines (50 loc) · 1.45 KB
/
Food.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
console.log('Food.js loaded')
class Food{
constructor(x,y,index){
this.x = x
this.y = y
this.w = 8
this.index = index
this.deleted = false
}
render(){
//^^
data.push(
this.x-this.w,this.y+this.w, 238.0/255.0, 253.0/255.0, 237.0/255.0,
this.x, this.y+this.w, 238.0/255.0, 253.0/255.0, 237.0/255.0,
this.x-this.w/2,this.y, 238.0/255.0, 253.0/255.0, 237.0/255.0,
this.x+this.w-this.w/2,this.y+this.w, 238.0/255.0, 253.0/255.0, 237.0/255.0,
this.x-this.w/2, this.y+this.w, 238.0/255.0, 253.0/255.0, 237.0/255.0,
this.x+this.w/2-this.w/2,this.y, 238.0/255.0, 253.0/255.0, 237.0/255.0,
/*
this.x-this.w/2, this.y-this.w/2,
this.x-this.w/2, this.y+this.w/2,
this.x+this.w/2, this.y+this.w/2,
this.x-this.w/2, this.y+this.w/2,
this.x+this.w/2, this.y+this.w/2,
this.x+this.w/2, this.y-this.w/2
*/
/*
this.x-this.w/2, this.y-this.w/2,
this.x-this.w/2, this.y+this.w/2,
this.x+this.w/2, this.y-this.w/2,
this.x+this.w/2, this.y-this.w/2,
this.x-this.w/2, this.y+this.w/2,
this.x+this.w/2, this.y+this.w/2
*/
)
}
update(index){
this.index = index
}
delete(){
if(this.deleted === false){
const insertIdx = getAddIndex(deleteListFood,this.index)
deleteListFood.splice(insertIdx,0,this.index) // Because we delete it LATER, multiple critters could eat this!@##!@#!@#
this.deleted = true
return true
}else{
return false
}
}
}