Blaster = Object:extend() function Blaster:new(x, y, owner) self.x = x self.y = y self.radius = 5 self.height = self.radius * 2 self.width = self.radius * 2 self.speed = 700 self.color = { 1, 0, 0 } self.destroy = false self.owner = owner self.hitbox = { self.x, (self.x + self.width), self.y, (self.y + self.height) } end function Blaster:draw() --draw stuff love.graphics.circle("fill", self.x, self.y, self.radius) end function Blaster:update(dt) if self.owner == "player" then self.y = self.y - self.speed * dt elseif self.owner == "enemy" then self.y = self.y + self.speed * dt end self.hitbox = { self.x, (self.x + self.width), self.y, (self.y + self.height) } end function Blaster:checkCollision(obj) local self_left = self.hitbox[1] local self_right = self.hitbox[2] local self_top = self.hitbox[3] local self_bottom = self.hitbox[4] local obj_left = obj.hitbox[1] local obj_right = obj.hitbox[2] local obj_top = obj.hitbox[3] local obj_bottom = obj.hitbox[4] if (self_right > obj_left) and (self_left < obj_right) and (self_bottom > obj_top) and (self_top < obj_bottom) then self.destroy = true obj.health = obj.health - 25 --other blaster logic here print("Collision! ", self.owner, " bullet struck ", obj.type) end end