I'm currently working on a 'Generic Engine' that I can use for multiple games, and am up to creating a physics system.
I was thinking of creating a Physics class, with a few methods like CreateForce() and what not, but I am seeking some help with general gravity.
I know there are countless tutorials on the web, but I find that it helps me to write things down, and I thought why not do it on the forum and see what other people suggest.
Basically I want a few features, but not that complicated for the time being as it is my first engine.
Vector2 position, velocity, gravity; float elapsed = (float)gameTime.ElapsedGameTime.Milliseconds; // or something to that effect. int mass;
There are probably a few more I would need but I wanted to know what other people did.
I have a basic idea of what to do. Something like this:
velocity += gravity * elapsed; position += velocity * gravity;
But I wanted to know how to implement the mass in as well.
With the bouncing I thought of doing something like this: (but it didn't work ;()
if (Collision)
{
velocity = new Vector2(-velocity.X * mass, -velocity.Y * mass);
}
Is there also something I should be doing to tone done the values, because when I mix a few of them together it goes kinda crazy
Thanks in advance,
Daniel,

New Topic/Question
Reply



MultiQuote






|