make rotator and locomotor function
@@ -25,6 +25,23 @@ var cell =
25
25
scaleUpTween.start();
26
26
},
27
27
28
activate: function(strength, deltaTime)
29
{
30
this.lastSum = strength;
31
32
switch(this.type)
33
{
34
case TYPES.LOCOMOTOR:
35
var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);
36
37
this.parentCreature.transform.position = this.parentCreature.transform.position.subtract(rotated.stretch(deltaTime));
38
break;
39
case TYPES.ROTATOR:
40
this.parentCreature.transform.rotation += (strength - 0.5) * deltaTime * 50;
41
break;
42
}
43
},
44
28
45
draw: function()
29
46
{
30
47
this.defaultDraw();
@@ -37,9 +54,12 @@ var cell =
37
54
{
38
55
var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);
39
56
this.transform.position = rotated.stretch(this.transform.scale.x).add(this.parentCreature.transform.position);
40
57
41
58
if(this.type == TYPES.EYE)
42
this.transform.rotation = this.localPos.toAngle();
59
this.transform.rotation = rotated.toAngle();
60
61
if(this.type == TYPES.LOCOMOTOR)
62
this.transform.rotation = rotated.toAngle() - 90;
43
63
},
44
64
45
65
setType: function(typeID)
@@ -96,9 +116,10 @@ var creature =
96
116
if(this.dna[this.cellInstances[i].cellRef].inputs.length > 0)
97
117
{
98
118
var sum = sigmoid(this.getCellInputSum(this.cellInstances[i]));
99
this.cellInstances[i].lastSum = sum;
100
119
101
120
//TODO: Act on the sum we've received (ALWAYS between 0 and 1, but VERY rarely exactly 0 or 1)
121
122
this.cellInstances[i].activate(sum, deltaTime);
102
123
}
103
124
}
104
125
}
@@ -25,6 +25,23 @@ var cell =25
scaleUpTween.start();25
scaleUpTween.start();26
},26
},27
27
28
activate: function(strength, deltaTime)29
{30
this.lastSum = strength;31
32
switch(this.type)33
{34
case TYPES.LOCOMOTOR:35
var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);36
37
this.parentCreature.transform.position = this.parentCreature.transform.position.subtract(rotated.stretch(deltaTime));38
break;39
case TYPES.ROTATOR:40
this.parentCreature.transform.rotation += (strength - 0.5) * deltaTime * 50;41
break;42
}43
},44
28
draw: function()45
draw: function()29
{46
{30
this.defaultDraw();47
this.defaultDraw();@@ -37,9 +54,12 @@ var cell =37
{54
{38
var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);55
var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);39
this.transform.position = rotated.stretch(this.transform.scale.x).add(this.parentCreature.transform.position);56
this.transform.position = rotated.stretch(this.transform.scale.x).add(this.parentCreature.transform.position);40
57
41
if(this.type == TYPES.EYE)58
if(this.type == TYPES.EYE)42
this.transform.rotation = this.localPos.toAngle();59
this.transform.rotation = rotated.toAngle();60
61
if(this.type == TYPES.LOCOMOTOR)62
this.transform.rotation = rotated.toAngle() - 90;43
},63
},44
64
45
setType: function(typeID)65
setType: function(typeID)@@ -96,9 +116,10 @@ var creature =96
if(this.dna[this.cellInstances[i].cellRef].inputs.length > 0)116
if(this.dna[this.cellInstances[i].cellRef].inputs.length > 0)97
{117
{98
var sum = sigmoid(this.getCellInputSum(this.cellInstances[i]));118
var sum = sigmoid(this.getCellInputSum(this.cellInstances[i]));99
this.cellInstances[i].lastSum = sum;100
119
101
//TODO: Act on the sum we've received (ALWAYS between 0 and 1, but VERY rarely exactly 0 or 1)120
//TODO: Act on the sum we've received (ALWAYS between 0 and 1, but VERY rarely exactly 0 or 1)121
122
this.cellInstances[i].activate(sum, deltaTime);102
}123
}103
}124
}104
}125
}@@ -62,3 +62,15 @@
62
62
-13-10-2021- 13:24
63
63
-13-10-2021- 13:27
64
64
-13-10-2021- 13:28
65
-13-10-2021- 13:41
66
-13-10-2021- 13:42
67
-13-10-2021- 13:43
68
-13-10-2021- 13:43
69
-13-10-2021- 13:44
70
-13-10-2021- 13:46
71
-13-10-2021- 13:46
72
-13-10-2021- 13:47
73
-13-10-2021- 13:47
74
-13-10-2021- 13:47
75
-13-10-2021- 13:48
76
-13-10-2021- 13:48
@@ -62,3 +62,15 @@62
-13-10-2021- 13:24 62
-13-10-2021- 13:24 63
-13-10-2021- 13:27 63
-13-10-2021- 13:27 64
-13-10-2021- 13:28 64
-13-10-2021- 13:28 65
-13-10-2021- 13:41 66
-13-10-2021- 13:42 67
-13-10-2021- 13:43 68
-13-10-2021- 13:43 69
-13-10-2021- 13:44 70
-13-10-2021- 13:46 71
-13-10-2021- 13:46 72
-13-10-2021- 13:47 73
-13-10-2021- 13:47 74
-13-10-2021- 13:47 75
-13-10-2021- 13:48 76
-13-10-2021- 13:48 @@ -25,6 +25,23 @@ var cell =
25
25
scaleUpTween.start();
26
26
},
27
27
28
activate: function(strength, deltaTime)
29
{
30
this.lastSum = strength;
31
32
switch(this.type)
33
{
34
case TYPES.LOCOMOTOR:
35
var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);
36
37
this.parentCreature.transform.position = this.parentCreature.transform.position.subtract(rotated.stretch(deltaTime));
38
break;
39
case TYPES.ROTATOR:
40
this.parentCreature.transform.rotation += (strength - 0.5) * deltaTime * 50;
41
break;
42
}
43
},
44
28
45
draw: function()
29
46
{
30
47
this.defaultDraw();
@@ -37,9 +54,12 @@ var cell =
37
54
{
38
55
var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);
39
56
this.transform.position = rotated.stretch(this.transform.scale.x).add(this.parentCreature.transform.position);
40
57
41
58
if(this.type == TYPES.EYE)
42
this.transform.rotation = this.localPos.toAngle();
59
this.transform.rotation = rotated.toAngle();
60
61
if(this.type == TYPES.LOCOMOTOR)
62
this.transform.rotation = rotated.toAngle() - 90;
43
63
},
44
64
45
65
setType: function(typeID)
@@ -25,6 +25,23 @@ var cell =25
scaleUpTween.start();25
scaleUpTween.start();26
},26
},27
27
28
activate: function(strength, deltaTime)29
{30
this.lastSum = strength;31
32
switch(this.type)33
{34
case TYPES.LOCOMOTOR:35
var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);36
37
this.parentCreature.transform.position = this.parentCreature.transform.position.subtract(rotated.stretch(deltaTime));38
break;39
case TYPES.ROTATOR:40
this.parentCreature.transform.rotation += (strength - 0.5) * deltaTime * 50;41
break;42
}43
},44
28
draw: function()45
draw: function()29
{46
{30
this.defaultDraw();47
this.defaultDraw();@@ -37,9 +54,12 @@ var cell =37
{54
{38
var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);55
var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);39
this.transform.position = rotated.stretch(this.transform.scale.x).add(this.parentCreature.transform.position);56
this.transform.position = rotated.stretch(this.transform.scale.x).add(this.parentCreature.transform.position);40
57
41
if(this.type == TYPES.EYE)58
if(this.type == TYPES.EYE)42
this.transform.rotation = this.localPos.toAngle();59
this.transform.rotation = rotated.toAngle();60
61
if(this.type == TYPES.LOCOMOTOR)62
this.transform.rotation = rotated.toAngle() - 90;43
},63
},44
64
45
setType: function(typeID)65
setType: function(typeID)@@ -45,9 +45,10 @@ var creature =
45
45
if(this.dna[this.cellInstances[i].cellRef].inputs.length > 0)
46
46
{
47
47
var sum = sigmoid(this.getCellInputSum(this.cellInstances[i]));
48
this.cellInstances[i].lastSum = sum;
49
48
50
49
//TODO: Act on the sum we've received (ALWAYS between 0 and 1, but VERY rarely exactly 0 or 1)
50
51
this.cellInstances[i].activate(sum, deltaTime);
51
52
}
52
53
}
53
54
}
@@ -45,9 +45,10 @@ var creature =45
if(this.dna[this.cellInstances[i].cellRef].inputs.length > 0)45
if(this.dna[this.cellInstances[i].cellRef].inputs.length > 0)46
{46
{47
var sum = sigmoid(this.getCellInputSum(this.cellInstances[i]));47
var sum = sigmoid(this.getCellInputSum(this.cellInstances[i]));48
this.cellInstances[i].lastSum = sum;49
48
50
//TODO: Act on the sum we've received (ALWAYS between 0 and 1, but VERY rarely exactly 0 or 1)49
//TODO: Act on the sum we've received (ALWAYS between 0 and 1, but VERY rarely exactly 0 or 1)50
51
this.cellInstances[i].activate(sum, deltaTime);51
}52
}52
}53
}53
}54
}