/pocjs/entities/OgreEntity.js

http://github.com/sbober/pocjs · JavaScript · 37 lines · 31 code · 6 blank · 0 comment · 4 complexity · 7866cc4e05e6934589ecfc7f0a87e47c MD5 · raw file

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