/pocjs/entities/OgreEntity.js
JavaScript | 37 lines | 31 code | 6 blank | 0 comment | 4 complexity | 7866cc4e05e6934589ecfc7f0a87e47c MD5 | raw file
1dojo.provide("pocjs.entities.OgreEntity"); 2 3dojo.declare("pocjs.entities.OgreEntity", pocjs.entities.EnemyEntity, { 4 5 shootDelay: null, 6 7 8 "-chains-": {constructor: "manual"}, 9 constructor: function(x, z) { 10 this.inherited(arguments, [x, z, 4 * 8 + 2, pocjs.Art.getCol(0x82A821)]); 11 this.x = x; 12 this.z = z; 13 this.health = 6; 14 this.r = 0.4; 15 this.spinSpeed = 0.05; 16 }, 17 18 hurt: function(xd, zd) { 19 this.inherited(arguments); 20 this.shootDelay = 50; 21 }, 22 23 tick: function() { 24 this.inherited(arguments); 25 if (this.shootDelay > 0) this.shootDelay--; 26 else if ((Math.random() * 40 << 0) == 0) { 27 this.shootDelay = 40; 28 this.level.addEntity( 29 new pocjs.entities.Bullet( 30 this, this.x, this.z, 31 Math.atan2( 32 this.level.player.x - this.x, this.level.player.z - this.z 33 ), 34 0.3, 1, this.defaultColor)); 35 } 36 } 37});