Merge branch 'eatfood'
@@ -51,6 +51,18 @@ var cell =
51
51
}
52
52
},
53
53
54
onCollision: function(other)
55
{
56
if (this.type == TYPES.MOUTH && !this.destroyed)
57
{
58
if(other.parentCreature == this.parentCreature)
59
return;
60
61
this.parentCreature.gainEnergy(10);
62
other.destroy();
63
}
64
},
65
54
66
draw: function()
55
67
{
56
68
this.defaultDraw();
@@ -190,6 +202,29 @@ var creature =
190
202
}
191
203
},
192
204
205
gainEnergy: function(amount)
206
{
207
var stomachRef = -1;
208
var amt = 10000;
209
210
for(var i = 0; i < this.cellInstances.length; i++)
211
{
212
if(this.cellInstances[i].type == TYPES.STOMACH)
213
{
214
if(this.cellInstances[i].energy < amt)
215
{
216
stomachRef = i;
217
amt = this.cellInstances[i].energy;
218
}
219
}
220
}
221
222
if(stomachRef == -1)
223
return 0;
224
225
this.cellInstances[stomachRef].energy = Math.min(cell.maxEnergy, this.cellInstances[stomachRef].energy + amount)
226
},
227
193
228
getCellInputSum: function(cellInstance, tracer = [])
194
229
{
195
230
var cellId = this.dna[cellInstance.cellRef].id;
@@ -519,6 +554,7 @@ var gem =
519
554
{
520
555
start: function()
521
556
{
557
this.name = "gem";
522
558
this.renderer.subImage = Math.floor(Math.random() * this.renderer.image.subImages);
523
559
524
560
this.transform.scale.x = 0;
@@ -561,8 +597,6 @@ var gem =
561
597
onDestroy: function()
562
598
{
563
599
gemSpawner.currentActive--;
564
565
enemySnake.edibles.remove(this);
566
600
},
567
601
568
602
onCollision: function(other)
@@ -51,6 +51,18 @@ var cell =51
}51
}52
},52
},53
53
54
onCollision: function(other)55
{56
if (this.type == TYPES.MOUTH && !this.destroyed) 57
{58
if(other.parentCreature == this.parentCreature)59
return;60
61
this.parentCreature.gainEnergy(10);62
other.destroy();63
}64
},65
54
draw: function()66
draw: function()55
{67
{56
this.defaultDraw();68
this.defaultDraw();@@ -190,6 +202,29 @@ var creature =190
}202
}191
},203
},192
204
205
gainEnergy: function(amount)206
{207
var stomachRef = -1;208
var amt = 10000;209
210
for(var i = 0; i < this.cellInstances.length; i++)211
{212
if(this.cellInstances[i].type == TYPES.STOMACH)213
{214
if(this.cellInstances[i].energy < amt)215
{216
stomachRef = i;217
amt = this.cellInstances[i].energy;218
}219
}220
}221
222
if(stomachRef == -1)223
return 0;224
225
this.cellInstances[stomachRef].energy = Math.min(cell.maxEnergy, this.cellInstances[stomachRef].energy + amount)226
},227
193
getCellInputSum: function(cellInstance, tracer = [])228
getCellInputSum: function(cellInstance, tracer = [])194
{229
{195
var cellId = this.dna[cellInstance.cellRef].id;230
var cellId = this.dna[cellInstance.cellRef].id;@@ -519,6 +554,7 @@ var gem =519
{554
{520
start: function()555
start: function()521
{556
{557
this.name = "gem";522
this.renderer.subImage = Math.floor(Math.random() * this.renderer.image.subImages);558
this.renderer.subImage = Math.floor(Math.random() * this.renderer.image.subImages);523
559
524
this.transform.scale.x = 0;560
this.transform.scale.x = 0;@@ -561,8 +597,6 @@ var gem =561
onDestroy: function()597
onDestroy: function()562
{598
{563
gemSpawner.currentActive--;599
gemSpawner.currentActive--;564
565
enemySnake.edibles.remove(this);566
},600
},567
601
568
onCollision: function(other)602
onCollision: function(other)@@ -94,3 +94,5 @@
94
94
-13-10-2021- 15:07
95
95
-13-10-2021- 15:12
96
96
-13-10-2021- 15:14
97
-13-10-2021- 15:19
98
-13-10-2021- 15:20
@@ -94,3 +94,5 @@94
-13-10-2021- 15:07 94
-13-10-2021- 15:07 95
-13-10-2021- 15:12 95
-13-10-2021- 15:12 96
-13-10-2021- 15:14 96
-13-10-2021- 15:14 97
-13-10-2021- 15:19 98
-13-10-2021- 15:20 @@ -51,6 +51,18 @@ var cell =
51
51
}
52
52
},
53
53
54
onCollision: function(other)
55
{
56
if (this.type == TYPES.MOUTH && !this.destroyed)
57
{
58
if(other.parentCreature == this.parentCreature)
59
return;
60
61
this.parentCreature.gainEnergy(10);
62
other.destroy();
63
}
64
},
65
54
66
draw: function()
55
67
{
56
68
this.defaultDraw();
@@ -51,6 +51,18 @@ var cell =51
}51
}52
},52
},53
53
54
onCollision: function(other)55
{56
if (this.type == TYPES.MOUTH && !this.destroyed) 57
{58
if(other.parentCreature == this.parentCreature)59
return;60
61
this.parentCreature.gainEnergy(10);62
other.destroy();63
}64
},65
54
draw: function()66
draw: function()55
{67
{56
this.defaultDraw();68
this.defaultDraw();@@ -104,6 +104,29 @@ var creature =
104
104
}
105
105
},
106
106
107
gainEnergy: function(amount)
108
{
109
var stomachRef = -1;
110
var amt = 10000;
111
112
for(var i = 0; i < this.cellInstances.length; i++)
113
{
114
if(this.cellInstances[i].type == TYPES.STOMACH)
115
{
116
if(this.cellInstances[i].energy < amt)
117
{
118
stomachRef = i;
119
amt = this.cellInstances[i].energy;
120
}
121
}
122
}
123
124
if(stomachRef == -1)
125
return 0;
126
127
this.cellInstances[stomachRef].energy = Math.min(cell.maxEnergy, this.cellInstances[stomachRef].energy + amount)
128
},
129
107
130
getCellInputSum: function(cellInstance, tracer = [])
108
131
{
109
132
var cellId = this.dna[cellInstance.cellRef].id;
@@ -104,6 +104,29 @@ var creature =104
}104
}105
},105
},106
106
107
gainEnergy: function(amount)108
{109
var stomachRef = -1;110
var amt = 10000;111
112
for(var i = 0; i < this.cellInstances.length; i++)113
{114
if(this.cellInstances[i].type == TYPES.STOMACH)115
{116
if(this.cellInstances[i].energy < amt)117
{118
stomachRef = i;119
amt = this.cellInstances[i].energy;120
}121
}122
}123
124
if(stomachRef == -1)125
return 0;126
127
this.cellInstances[stomachRef].energy = Math.min(cell.maxEnergy, this.cellInstances[stomachRef].energy + amount)128
},129
107
getCellInputSum: function(cellInstance, tracer = [])130
getCellInputSum: function(cellInstance, tracer = [])108
{131
{109
var cellId = this.dna[cellInstance.cellRef].id;132
var cellId = this.dna[cellInstance.cellRef].id;@@ -6,6 +6,7 @@ var gem =
6
6
{
7
7
start: function()
8
8
{
9
this.name = "gem";
9
10
this.renderer.subImage = Math.floor(Math.random() * this.renderer.image.subImages);
10
11
11
12
this.transform.scale.x = 0;
@@ -48,8 +49,6 @@ var gem =
48
49
onDestroy: function()
49
50
{
50
51
gemSpawner.currentActive--;
51
52
enemySnake.edibles.remove(this);
53
52
},
54
53
55
54
onCollision: function(other)
@@ -6,6 +6,7 @@ var gem =6
{6
{7
start: function()7
start: function()8
{8
{9
this.name = "gem";9
this.renderer.subImage = Math.floor(Math.random() * this.renderer.image.subImages);10
this.renderer.subImage = Math.floor(Math.random() * this.renderer.image.subImages);10
11
11
this.transform.scale.x = 0;12
this.transform.scale.x = 0;@@ -48,8 +49,6 @@ var gem =48
onDestroy: function()49
onDestroy: function()49
{50
{50
gemSpawner.currentActive--;51
gemSpawner.currentActive--;51
52
enemySnake.edibles.remove(this);53
},52
},54
53
55
onCollision: function(other)54
onCollision: function(other)