Author Topic: Starting out  (Read 1941 times)

0 Members and 1 Guest are viewing this topic.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Starting out
« Reply #15 on: August 04, 2010, 11:41:03 PM »
The functionality that I _really_ want to code is asteroids bouncing off one another, like snooker balls.

Will need to do some research and think about that one a lot.  Not sure offhand how I would express that mathematically.  I will have to do this for Big Bang, though... my mind is working on it :>  Albeit part-time, for now..

Jeheace

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 32
    • Jeheace's Art
Re: Starting out
« Reply #16 on: August 05, 2010, 01:31:44 AM »
You need collision detections! ^-^

What happens if the roid i JUST clicked to send my seedlings to sudden vanishes..?

Should they seek the nearest roid, or return to roid of origin..?

Ytaker

  • Tester
  • Seedling
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 33
Re: Starting out
« Reply #17 on: August 05, 2010, 02:37:01 AM »
You need collision detections! ^-^

What happens if the roid i JUST clicked to send my seedlings to sudden vanishes..?

Should they seek the nearest roid, or return to roid of origin..?

Or die in the cold and harsh environment which is space.

Farnett

  • Guest
Re: Starting out
« Reply #18 on: August 05, 2010, 03:30:18 AM »
The functionality that I _really_ want to code is asteroids bouncing off one another, like snooker balls.

Will need to do some research and think about that one a lot.  Not sure offhand how I would express that mathematically.  I will have to do this for Big Bang, though... my mind is working on it :>  Albeit part-time, for now..


That's fairly simple.  All you need is the vector between the two objects and the momentum vectors of each asteroid, both of which I believe are already being tracked in your gravity engine.  Simply check if the length of the vector between two asteroids is less than the sum of their radii and if so then you have a collision.  After that you have two choices, an elastic or an inelastic collision.  For an inelastic collision the two asteroids merge (with the smaller one loosing out presumably) and their momentum vectors are added together to get the new momentum vector.  For an elastic collision the two asteroids bounce off like billiard balls; you then use the momentum vectors to calculate the angle at which they 'bounce' off of each other. 

Jeheace

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 32
    • Jeheace's Art
Re: Starting out
« Reply #19 on: August 05, 2010, 03:40:58 AM »
And right now, I'm doing some trial and error to find good distance from sun and roid density to create stable orbits.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 13
  • Posts: 1,035

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1,794
Re: Starting out
« Reply #21 on: August 05, 2010, 09:53:55 AM »
Collision detection is _very_ simple.

Accurate collision detection, not relying on the 60fps offered by lua, is harder.
(ie, "last frame i had not collided, this frame i am 30 units overlapping.  at what point did I go from 0 units to 1 unit overlap?  What would the other values have been at that point?  These are the variables that must be used for an accurate bounce calculation)


Even harder is calculating the angles they bounce off at.


Thanks for the link Alex, will read up on it :>
« Last Edit: August 05, 2010, 09:57:54 AM by annikk.exe »