[Fixed] Simple sine/radians problem - I think
Posted: Mon Sep 20, 2021 12:38 pm
I got this off a random 2 year old github and found a bug almost instantly. A tiny 100 line file is attached. This is the old lunar lander 'game' but this one line seems to bug out:
I think, with my basic knowledge - a certain combination of radian + sine will = zero and the ship can't break and can't land properly.
Use UP key for thrust and left/right key to rotate.
(actually kinda fun)
Edit: I made a zip file and not a .love file in case anyone thought this was 'production ready'. It's not. Just my own little habits I guess.
Code: Select all
if love.keyboard.isDown("up") then
Lander.engineOn = true
local angle_radian = math.rad(Lander.angle)
local force_x = math.cos(angle_radian) * (Lander.speed * dt)
local force_y = math.sin(angle_radian) * (Lander.speed * dt)
-- this will sometimes be zero meaning zero force meaning the lander never slows down
print(force_y)
--
Lander.vx = Lander.vx + force_x
Lander.vy = Lander.vy + force_y
else
Lander.engineOn = false
end
Use UP key for thrust and left/right key to rotate.
(actually kinda fun)
Edit: I made a zip file and not a .love file in case anyone thought this was 'production ready'. It's not. Just my own little habits I guess.