Juckniz

Untitled

May 28th, 2013
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. /**
  2. * Class Enemy que construye un Enemy
  3. * @class Enemy
  4. * @constructors
  5. * @this {Enemy}
  6. * @param {Number} x posicion x
  7. * @param {Number} y posicion y
  8. * @param {Number} width anchura del Enemy
  9. * @param {Number} height altura del Enemy
  10. * @param {Number} positionpath posicion que se encuentra dentro de la array de path
  11. * @param {Image} img imagen del Enemy
  12. * @param {Number} hp vida del Enemy
  13. * @param {Number} gunter gunters que da el Enemy
  14. * @param {Number} princess princesas que quita el Enemy
  15. * @returns {Enemy}
  16. */
  17. function Enemy(x, y, width, height, positionpath, img, hp, gunter, princess) {
  18. /**
  19. * Posicion X en el que se encuentra. Por defecto 0.
  20. * @type Number
  21. */
  22. this.x = (x == null) ? 0 : x;
  23. /**
  24. * Posicion Y en el que se encuentra. Por defecto 0.
  25. * @type Number
  26. */
  27. this.y = (y == null) ? 0 : y;
  28. /**
  29. * Anchura del Enemy. Por defecto 0.
  30. * @type Number
  31. */
  32. this.width = (width == null) ? 0 : width;
  33. /**
  34. * Altura del Enemy. Por defecto el valor de width.
  35. * @type Number
  36. */
  37. this.height = (height == null) ? this.width : height;
  38. /**
  39. * Posicion actual que se encuentra en la array del Path
  40. * @type Number
  41. */
  42. this.positionpath = (positionpath == null) ? 0 : positionpath;
  43. /**
  44. * Porcentaje del tamano del path que se encuentra
  45. * @type Number
  46. */
  47. this.porcentaje = 0;
  48. /**
  49. * Imagen del Enemy
  50. * @type Image
  51. */
  52. this.img = img;
  53. /**
  54. * Vida del Enemy
  55. * @type Number
  56. */
  57. this.hp = hp;
  58. /**
  59. * Gunters que da el Enemy
  60. * @type Number
  61. */
  62. this.gunter = gunter;
  63. /**
  64. * Princesas que quita el enemigo al llegar al final del camino.
  65. * @type Number
  66. */
  67. this.princess = princess;
  68. /**
  69. * Barra de vida del Enemigo
  70. * @type LifeBar
  71. */
  72. this.lifebar = new LifeBar(x, y - 15, width, 5, hp);
  73.  
  74. /**
  75. * Metodo para mover el Enemy
  76. * @returns {void}
  77. */
  78. this.move = function() {
  79. this.x = (path[this.positionpath + 1].x - path[this.positionpath].x) * this.porcentaje + path[this.positionpath].x;
  80. this.y = (path[this.positionpath + 1].y - path[this.positionpath].y) * this.porcentaje + path[this.positionpath].y;
  81. this.porcentaje += 0.03;
  82. if (this.porcentaje >= 1) {
  83. this.porcentaje = 0;
  84. this.positionpath++;
  85. }
  86. this.lifebar.updatePosition(this.x, this.y - 15);
  87. }
  88.  
  89. /**
  90. * Metodo para infligir dano al Enemigo.
  91. * Reduciendo su vida
  92. * @param {Number} damage
  93. * @returns {void}
  94. */
  95. this.damaged = function(damage) {
  96. this.hp -= damage;
  97. this.lifebar.updateLife(this.hp);
  98. }
  99.  
  100.  
  101.  
  102. }
Advertisement
Add Comment
Please, Sign In to add comment