Log In  
Follow
matamouros
[ :: Read More :: ]

Hi all, just a quick noob question. I'm struggling with making two objects (asteroids in this case) coming down a trajectory on x,y and colliding, deflect each other a little more realistically (but without having to implement a physics engine!). I don't have the maths skills as of yet, I'm guessing something to do with angles/trigonometry?

At the moment I'm basically forcing the leftmost asteroid to the left and the rightmost object to the right, but 90% of times this just looks very unnatural.

Would someone kindly point me some resource I could check up on/read/watch on how to approach this? I don't have the smarts to figure it out on my own, but will be more than ok researching it on my own - just need to be pointed in the right direction. Any tips or pointers would be greatly appreciated.

Thank you in advance!

Pedro.

P#114546 2022-07-19 17:08

[ :: Read More :: ]

Aw man, I'm so sorry, I feel really silly... How on earth do you generate a random bool? I can't find any way to cast an int into a bool, so I'm down to doing the sort of stuff below:

randbool=flr(rnd(2))
if randbool==0 then randbool=false else randbool=true end

This feels really dirty and silly. What's the established way of doing this please? And apologies in advance.

Thanks,

Pedro.

P#113684 2022-06-26 18:03

[ :: Read More :: ]

Hi everyone, I think this can't be a bug that only I just found out so I'm posting it here for some help instead of in the bugs forum.

I seem to be having the weirdest behaviour easing out a negative var towards 0: it never becomes zero again (either negative or positive), despite printing as such. Check the below reproducer code and gif, neither y==0 nor y==-0 conditions catch the zero, even though at first you can see true.

Please help?

Thanks!

function _init()
 y=0
end

function _update()
 y*=0.85
 if btn(2) then
  y-=0.65
 end
end

function _draw()
 cls()
 print("time: "..time())
 print("y="..y)
 print("is y==0? "..(y==0 and 'true' or 'false'))
 print("is y==-0? "..(y==-0 and 'true' or 'false'))
end
P#113348 2022-06-19 11:45

Follow Lexaloffle:          
Generated 2024-03-29 04:57:29 | 0.063s | Q:7