I see the Guns:newBullet() function takes a dx and dy parameter:
function Guns:newBullet(x,y,image,speed,damage,rotation,dx,dy)
I'm thinking it would be much simpler to instead not use dx or dy, and calculate the bullet's dx and dy during the update using its speed and rotation. I actually had to do some testing to figure out the right formula for movement, but this should work:
function Guns:newBullet(x,y,image,speed,damage,rotation)
local bullet = {}
bullet.x = x
bullet.y = y
bullet.image = image
bullet.speed = speed
bullet.rotation = rotation
bullet.damage = damage
table.insert(Guns.bullets,bullet)
end
function Guns:update(dt)
for i=#Guns.bullets, 1, -1 do
local bullet = Guns.bullets[i]
--Move the bullet
bullet.x = bullet.x - math.sin(-bullet.rotation) * bullet.speed * dt
bullet.y = bullet.y - math.cos(-bullet.rotation) * bullet.speed * dt
end
end