on the frames default:
Bullet = class {
constructor(angle, speed, damage) {
this.speed = speed;
this.angle = angle;
this.damage = damage;
}
move(myself) {
myself.x += Math.cos(this.angle) * this.speed;
myself.y += Math.sin(this.angle) * this.speed;
}
destroy(myself) {
if (myself.isClone) {
myself.remove();
}
}
};
Enemy = class extends Shooter {
constructor(myself, hp, maxHp) {
super(myself);
this.maxHp = maxHp;
this.hp = hp;
}
takeKnockback(myself,x1,y1) {
myself.x += ( ( myself.x+(Math.cos(this.getAngle(myself,x1,y1)*4) ) )-myself.x )/4
myself.y += ( ( myself.y+(Math.sin(this.getAngle(myself,x1,y1)*4) ) )-myself.y )/4
}
isColliding(myself,ob) {
for(var a of ob.clones){
if (myself.hits(a)) {
let out = [true,a]
return [true,a]
}else{
let out = [false,null]
return out
}
}
}
};
on my enemy clip
if(this.isClone){
this.x = p.x
setTimeout(()=>{
this.ready = true
},1000)
if(this.ready===true){
var collision = this.e.isColliding(this,pbullet)
console.log(collision[0])
it should be returning the clone of the bullet that it got hit by, but its logging undefined