I'm using Hardon Collider for my project. At the moment I'm using it for everything including bullets that the player shoots.
Code: Select all
function ammo.update(dt)
for i,v in ipairs(ammo) do
if v.id == nil then
v.id = ammo.id
ammo.id = ammo.id + 1
end
v.bullet.type = v.id
v.xvel = v.xvel + 12000 * dt * math.cos(v.angle)
v.yvel = v.yvel + 12000 * dt * math.sin(v.angle)
if v.reverse == 1 then
v.x = v.x - (v.xvel + 1) * dt
v.y = v.y - (v.yvel + 1) * dt
else
v.x = v.x + v.xvel * dt
v.y = v.y + v.yvel * dt
end
-- Continued
But is there a more realistic approach, rather than just reversing the bullet direction?
If so could you give me some code that will make the velocity do that?
Oh, and explain it too!
Cheerus