Code: Select all
-- input handling
if pad:l() then
ship.aimdir = relative(ship.aimdir +2)
end
if pad:r() then
ship.aimdir = relative(ship.aimdir -2)
end
ship.aimdir = math.abs(ship.aimdir)
if ship.aimdir > 360 then
ship.aimdir = ship.aimdir -360
end
if ship.aimdir <0 then
ship.aimdir = ship.aimdir +360
end
the ships aiming will go round anti clockwise (when ship.aimdir is being +ed) but if you go clockwise it gets stuck at the ship.aimdir = 0 mark.
i use this pice of code in loads of other languages and it works great.
whats going on??
edit: oops nver mind there is an unneccessary math.abs in there