Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Class Enemy que construye un Enemy
- * @class Enemy
- * @constructors
- * @this {Enemy}
- * @param {Number} x posicion x
- * @param {Number} y posicion y
- * @param {Number} width anchura del Enemy
- * @param {Number} height altura del Enemy
- * @param {Number} positionpath posicion que se encuentra dentro de la array de path
- * @param {Image} img imagen del Enemy
- * @param {Number} hp vida del Enemy
- * @param {Number} gunter gunters que cuesta la torre
- * @param {Number} princess princesas que quita la torre
- * @returns {Enemy}
- */
- function Enemy(x, y, width, height, positionpath, img, hp, gunter, princess) {
- /**
- * Posicion X en el que se encuentra. Por defecto 0.
- * @type Number
- */
- this.x = (x == null) ? 0 : x;
- /**
- * Posicion Y en el que se encuentra. Por defecto 0.
- * @type Number
- */
- this.y = (y == null) ? 0 : y;
- /**
- * Anchura del Enemy. Por defecto 0.
- * @type Number
- */
- this.width = (width == null) ? 0 : width;
- /**
- * Altura del Enemy. Por defecto el valor de width.
- * @type Number
- */
- this.height = (height == null) ? this.width : height;
- /**
- * Posicion actual que se encuentra en la array del Path
- * @type Number
- */
- this.positionpath = (positionpath == null) ? 0 : positionpath;
- /**
- * Porcentaje del tamano del path que se encuentra
- * @type Number
- */
- this.porcentaje = 0;
- /**
- * Imagen del Enemy
- * @type Image
- */
- this.img = img;
- /**
- * Vida del Enemy
- * @type Number
- */
- this.hp = hp;
- /**
- * Gunters que cuesta la torre
- * @type Number
- */
- this.gunter = gunter;
- /**
- * Princesas que quita el enemigo al llegar al final del camino.
- * @type Number
- */
- this.princess = princess;
- /**
- * Barra de vida del Enemigo
- * @type LifeBar
- */
- this.lifebar = new LifeBar(x, y - 15, width, 5, hp);
- /**
- * Metodo para mover el Enemy
- * @returns {void}
- */
- this.move = function() {
- this.x = (path[this.positionpath + 1].x - path[this.positionpath].x) * this.porcentaje + path[this.positionpath].x;
- this.y = (path[this.positionpath + 1].y - path[this.positionpath].y) * this.porcentaje + path[this.positionpath].y;
- this.porcentaje += 0.03;
- if (this.porcentaje >= 1) {
- this.porcentaje = 0;
- this.positionpath++;
- }
- this.lifebar.updatePosition(this.x, this.y - 15);
- }
- /**
- * Metodo para infligir dano al Enemigo.
- * Reduciendo su vida
- * @param {Number} damage
- * @returns {void}
- */
- this.damaged = function(damage) {
- this.hp -= damage;
- this.lifebar.updateLife(this.hp);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment