simple project

Started by
7 comments, last by loire 21 years, 3 months ago
hi!I''m an absolute beginner i need a very simple example for learning something about collision: A box with 2 ball inside. The ball must be in moving. Thanks in advance. Se non credi in te stesso, chi ci credera''''
Se non credi in te stesso,chi ci credera''
Advertisement
nehe.gamedev.net

Nehe''s Tutorial #30

Have fun

Thanks!
But i ''ve already see it......
It''s too difficult for me, so i need something easier
Se non credi in te stesso,chi ci credera''
Do You need Physics of collision, or how to visualise it?
C++ RULEZ!!! :)
how to visualize

Se non credi in te stesso,
chi ci credera''''
Se non credi in te stesso,chi ci credera''
how to visualize

Se non credi in te stesso,
chi ci credera''''
Se non credi in te stesso,chi ci credera''
visualise

Se non credi in te stesso,
chi ci credera''''
Se non credi in te stesso,chi ci credera''
Well, so if you know, how to visualize (visualiSe, whatever?! ) the single ball, lets make two of them collide:

consider these vectors:
pos1, pos2 - coordinates of balls
v1, v2 - velocities
v10, v20 - velocities JUST before the collision
u1, u2 - velocities JUST after the collision.

and scalars:
r1, r2 - radii of balls

and function: m_abs() - returns the length of a vector

Now the collison stuff is as follows:


  if ( m_abs(pos1-pos2) < r1+r2 ){  /* There was a collision, man, so use some math and physics to calculate u1 and u2 from v10 and v20, taking into the account that, in general, collision is NOT central and ellastic! */  // calculations of u1=f(v10,v20) and u2=g(v10, v20) go here...  //...  // assign final velocities:  v1=u1;  v2=u2;  // Finally make some bursts in the place the balls meet :)  DrawSpecialEffects();}  


You have to implement different function and use slightly diferent math to check the collisions with walls, if coordinates of balls exeed "wall limits"... but the idea is the same

Thanks it!

Hope this helps.
C++ RULEZ!!! :)
THK!


Se non credi in te stesso,
chi ci credera''''
Se non credi in te stesso,chi ci credera''

This topic is closed to new replies.

Advertisement