/pocjs/entities/BatBossEntity.js

http://github.com/sbober/pocjs · JavaScript · 35 lines · 28 code · 7 blank · 0 comment · 2 complexity · 0f49cf0dace237c02d818cac83e6cdc1 MD5 · raw file

  1. dojo.provide("pocjs.entities.BatBossEntity");
  2. dojo.declare("pocjs.entities.BatBossEntity", pocjs.entities.EnemyEntity, {
  3. "-chains-": {constructor: "manual"},
  4. constructor: function(x, z) {
  5. this.inherited(arguments, [x, z, 4 * 8, pocjs.Art.getCol(0xffff00)]);
  6. this.x = x;
  7. this.z = z;
  8. this.health = 5;
  9. this.r = 0.3;
  10. this.flying = true;
  11. },
  12. die: function() {
  13. pocjs.Sound.bosskill.play();
  14. this.level.addEntity(new pocjs.entities.KeyEntity(this.x, this.z));
  15. },
  16. tick: function() {
  17. this.inherited(arguments);
  18. if (Math.random() * 20 < 1) {
  19. var xx = this.x + (Math.random() - 0.5) * 2;
  20. var zz = this.z + (Math.random() - 0.5) * 2;
  21. var batEntity = new pocjs.entities.BatEntity(xx, zz);
  22. batEntity.level = this.level;
  23. if (batEntity.isFree(xx, zz)) {
  24. this.level.addEntity(batEntity);
  25. }
  26. }
  27. }
  28. });