blue-star / cellular-evolution
creature.js
| 1 | /** |
| 2 | * It's a thing! |
| 3 | */ |
| 4 | |
| 5 | var creature = |
| 6 | { |
| 7 | dna: {}, |
| 8 | cellInstances: [], |
| 9 | |
| 10 | start: function() |
| 11 | { |
| 12 | |
| 13 | }, |
| 14 | |
| 15 | initCells() |
| 16 | { |
| 17 | for(var i = 0; i < this.dna.length; i++) |
| 18 | { |
| 19 | var newCell = GameObject.create(cell, this.transform.position.x + (this.dna[i].pos.x * 32), this.transform.position.y + (this.dna[i].pos.y * 32), s_orb, 500); |
| 20 | |
| 21 | newCell.setType(this.dna[i].type); |
| 22 | newCell.parentCreature = this; |
| 23 | newCell.localPos = new vector(this.dna[i].pos.x * 32, this.dna[i].pos.y * 32) |
| 24 | |
| 25 | this.cellInstances.push(newCell); |
| 26 | } |
| 27 | }, |
| 28 | |
| 29 | update: function(deltaTime) |
| 30 | { |
| 31 | this.transform.rotation += deltaTime * 60; |
| 32 | this.transform.position = this.transform.position.add(this.transform.forward().stretch(deltaTime * 250)) |
| 33 | }, |
| 34 | |
| 35 | onDestroy: function() |
| 36 | { |
| 37 | |
| 38 | }, |
| 39 | |
| 40 | onCollision: function(other) |
| 41 | { |
| 42 | |
| 43 | } |
| 44 | } |