| View previous topic :: View next topic |
| Author |
Message |
jimjamjahaa
Joined: 03 Oct 2005 Posts: 17
|
Posted: Mon Oct 03, 2005 5:04 am Post subject: what is wrong with this code (or lua)? |
|
|
| Code: |
-- 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 |
|
| Back to top |
|
 |
chaos
Joined: 10 Apr 2005 Posts: 135
|
Posted: Mon Oct 03, 2005 7:59 am Post subject: |
|
|
isn't it funny how you can always spot the answer 5 minutes after making a thread about it? :) _________________ Chaosmachine Studios: High Quality Homebrew. |
|
| Back to top |
|
 |
BePe86
Joined: 02 Oct 2005 Posts: 10 Location: Norway
|
Posted: Mon Oct 03, 2005 8:39 am Post subject: |
|
|
lol, it's an universal law :P _________________ EU PSP 1.52 -> 2.0 -> 1.50
Untold Legends
32MB + 1GB Memory Sticks |
|
| Back to top |
|
 |
|