Implementing physics in game [closed]
I am developing bowling game. I am unable to implement physics like collision detection, ball movement (Force and Friction) and the spin. Can anyone please help me out?
The physics we cannot teach you, but MIT will.
If this is your first game and you are learning graphics programming at the same time, I would suggest working with a prebuilt physics library, such as Bullet.
EDIT: There is a large list of physics engines here.
I can advice you to use tokamak physics engine, if you don't wan't to imlement all this things yourself. I remember that getting accustomed to this engine doesn't take a lot of time.
Or maybe you can find another physics engine.
Your best bet is to use a physics library, like the Open Dynamics Engine. ODE has a C/C++ interface, since you tagged as C++ it might be of use to you. It's open source, pretty fast, and works well for games. If you really want to get into the physics and try to implement yourself, it's quite a bit of work, but fun if you're into that sort of thing.
The basic idea is to keep track of all the physical parameters (position, velocity, acceleration, rotational speed, etc.) of all your playfield objects (ball, pins, the floor, etc.). Then on a regular time interval, say every 10 msec, you update the physical parameters as they change over this time interval, accounting for all the laws of physics (f = m * a
type stuff) and physical interactions (collisions, friction, other forces applied). Take the output and redraw the playfield objects.
That's the simplified explanation. There are a lot of other things to worry about, like numerical stability and performance when you have a lot of playfield objects to interact. The math also gets pretty complicated when you try to do collision detection for something other than the simplest of gemoetrical primitives. Which is why it's best to learn a third-party engine if you just want to focus on your game.
精彩评论