project-witchy/imperium-porcorum.love/scenes/levels/entities/bullet.lua

41 lines
826 B
Lua

local Entity = require "scenes.levels.entities.parent"
local Bullet = Entity:extend()
function Bullet:new(world, x, y, w, h, speed, dir)
Bullet.super.new(self, world, "bullet", x - (w / 2), y - (h / 2), w, h)
self.life = 0;
self:setMotionDirection(dir, speed)
end
function Bullet:setFilter()
self.filter = function(item, other)
if (other.type=="wall") then
return 'touch'
else
return 'cross'
end
end
end
function Bullet:updateEnd(dt)
local isInsideView = self:isInsideView()
if (isInsideView == false) or (self.xsp == 0) then
self:destroy()
end
end
function Bullet:collisionResponse(collision)
local other = collision.other
if other.type=="wall" then
self:destroy()
end
end
function Bullet:draw(dt)
currentLevel:drawHitbox(self, 0,128,0)
end
return Bullet