blue-star / cellular-evolution
cell.js
| 1 | /** |
| 2 | * Part of a creature! |
| 3 | */ |
| 4 | |
| 5 | var 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 | } |