aliens.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. var ALIENS = {
  2. alien1 : {
  3. health : 1,
  4. weapon : AlienWeapon,
  5. score : 5,
  6. aggression : 0.0005,
  7. animation : ALIENS_TYPE[0]
  8. },
  9. alien2 : {
  10. health : 1,
  11. weapon : AlienWeapon,
  12. score : 10,
  13. aggression : 0.001,
  14. animation : ALIENS_TYPE[1]
  15. },
  16. alien3 : {
  17. health : 1,
  18. weapon : AlienWeapon,
  19. score : 20,
  20. aggression : 0.0015,
  21. animation : ALIENS_TYPE[2]
  22. }
  23. }
  24. /*** Actors - Aliens ***/
  25. function Alien(id, start, move, type) {
  26. "use strict";
  27. this.id = id;
  28. this.x = start.x;
  29. this.y = start.y;
  30. this.moveFct = move;
  31. this.weapon = new type.weapon();
  32. this.fireDirectionY = 1;
  33. this.originX = this.x;
  34. this.originY = this.y;
  35. this.directionX = -1;
  36. this.speed = 0.5;
  37. this.animation = type.animation;
  38. this.width = type.animation.width;
  39. this.height = type.animation.height;
  40. this.health = type.health;
  41. this.aggression = type.aggression;
  42. this.score = type.score;
  43. }
  44. Alien.prototype = {
  45. moveFct : null,
  46. width : 0,
  47. height : 0,
  48. aggression : 0,
  49. animation : null,
  50. score : 0,
  51. init : function() {
  52. "use strict";
  53. this.speed = 0;
  54. this.node.x(this.x);
  55. this.node.y(this.y);
  56. },
  57. move : function() {
  58. "use strict";
  59. this._super("move", arguments);
  60. if (typeof this.moveFct !== undefined) {
  61. this.moveFct();
  62. }
  63. },
  64. destroy : function() {
  65. this._super("destroy", arguments);
  66. Game.addToScore( this.score );
  67. }
  68. };
  69. heriter(Alien.prototype, Actor.prototype);
  70. /*** Actors - Aliens - END ***/