Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Clase Bullet que construye un Bullet
- * @class Bullet
- * @constructors
- * @this {Bullet}
- * @param {Number} x Posicion X en el que se encuentra
- * @param {Number} y Posicion Y en el que se encuentra
- * @param {Enemy} Enemy enemigo que tiene seleccionado
- * @param {Number} damage dano que inflije la bala
- * @param {Number} index indice para sacar la informacion del json
- * @param {String} direccion direccion que va a disprar
- * @returns {Bullet}
- */
- function Bullet(x, y, Enemy, damage, index, direccion) {
- /* * 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;
- /* * Posicion X inicial coje el valor de X al construir el objeto.
- * @type Number
- */
- this.xi = this.x;
- /* * Posicion Y inicial coje el valor de Y al construir el objeto.
- * @type Number
- */
- this.yi = this.y;
- /**
- * Direccion donde va disparar "bot" || "top" || "left" || "right" solo se usara si bulletType es "lineal" o "area".
- * @type String
- */
- this.direccion = direccion;
- /**
- * Tipo de la bala coje el valor del json tipotower.
- * @type String
- */
- this.bulletType = tipotower[index].bulletType;
- /**
- * Anchura de la bala coje el valor del json tipotower.
- * @type Number
- */
- this.width = tipotower[index].bulletSize;
- /**
- * Altura de la bala coje el valor del json tipotower.
- * @type Number
- *
- */
- this.height = tipotower[index].bulletSize;
- /**
- * Dano de la bala por defecto 0.
- * @type Number
- */
- this.damage = (damage == null) ? 0 : damage;
- /**
- * Imagen de la bala coje la src del json tipotower.
- * @type Image
- */
- this.img = new Image();
- this.img.src = tipotower[index].imgbullet;
- /**
- * Enemigo que tiene seleccionado solo lo utilizara si el bulletType es "target"
- * @type Enemy
- */
- this.Enemy = Enemy;
- /**
- * Velocidad de la bala coje el valor del json tipotower.
- * @type Number
- */
- this.velocity = tipotower[index].velocity;
- this.radio = tipotower[index].radio;
- this.countradio = 0;
- /**
- * Metodo que comprueba si se ha chocado con otro cuerpo
- * @param {type} rect
- * @returns {boolean}
- */
- this.intersects = function(rect) {
- if (rect != null) {
- return(this.x <= rect.x + rect.width &&
- this.x + this.width > rect.x &&
- this.y <= rect.y + rect.height &&
- this.y + this.height > rect.y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment