BlueGit

blue-star cellular-evolution

Files

cellular-evolution / src / cell.js

cell.js

bip
timfa Tim · pushed by timfa · 5 years ago
82ed751b History
cell.js 762 B Download Raw
1/**
2 * Part of a creature!
3 */
4
5var cell =
6{
7 localPos: new vector(0, 0),
8 parentCreature: null,
9
10 start: function()
11 {
12 this.transform.scale.x = 0;
13 this.transform.scale.y = 0;
14
15 var scaleUpTween = new TWEEN.Tween(this.transform.scale);
16
17 scaleUpTween.to({x: [1.5, 1], y: [1.5, 1]}, Math.random() * 3200);
18
19 scaleUpTween.easing(TWEEN.Easing.Back.Out);
20
21 scaleUpTween.start();
22 },
23
24 update: function()
25 {
26 var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);
27 this.transform.position = rotated.stretch(this.transform.scale.x).add(this.parentCreature.transform.position);
28 },
29
30 setType: function(typeID)
31 {
32 this.renderer.subImage = typeID;
33 }
34}