class GameObject { constructor(x, y, width, height, hitBoxRadius, velocity, direction, color) { this.x = x; this.y = y; this.width = width; this.height = height; this.hitBoxRadius = hitBoxRadius; this.velocity = velocity; this.direction = direction; this.color = color; } update(delta) { if(this.velocity === 0) { return; } this.x += this.velocity * Math.cos(this.direction * Math.PI / 180); this.y += this.velocity * Math.sin(this.direction * Math.PI / 180); } isHitBy(object) { let distance = this.distanceTo(object); if (distance <= this.hitBoxRadius) { return true; } return false; } distanceTo(target) { let deltaX = Math.abs(this.x - target.x), deltaY = Math.abs(this.y - target.y); return Math.sqrt(deltaX * deltaX + deltaY * deltaY); } draw(context) {} } export default GameObject;