A Bouncing Ball

Started by
4 comments, last by Woody FX 21 years, 1 month ago
Now that i have drawn a room i want the ball to bounce about. The Velocity will never change Just the direction as it boucnces off walls! I am using D3D so will it scale the ball for me? What is the best wat to draw a simple white ball? Are there any special functions to handle this in DirectX all ready. Thanks Brian (C++)
Advertisement
use something like this:

struct Ball
{
Vector3 position, velocity;
};

then each frame you update it''s position by adding its velocity, and reflect the velocity when it hits a wall. Then you can draw a sphere centered at position. Use the D3DX Mesh to load a sphere from an x file (sphere.x comes with the SDK).
Will DirectX handle the scaling of the sphere as it travels along the Z-axis and is there anything special i need to setup so that it knows how to do this?

I get that i will need a starting Position, Vector and Velocity.
And these will be updated on every loop?

I though this was simple (it probably is ) but could not track down how to do it through my Books and pages printed off the Web last night!

Dont get acess to the Web at home! :-/

Thanks for info Pseduo
"Will DirectX handle the scaling of the sphere as it travels along the Z-axis?"

it will if you are using perspective projection matrix.

"And these will be updated on every loop?"

Totaly up to you. Do it in sinc with frames or make separate thread for your "phisycs".

"I though this was simple"

Wrong. It is out right primitive, 30min of work or less.
Ok so I will look in to perspective projection matrices.
Will update every frame.

Still not simple ...yet!

Is there a specific function that will create a simple sphere?
I created the Cube the ball is to bounce around by just specifying the Vertices in the Code using the a FVF.

Is there a way to do this for a sphere? and how if you know off hand?

Thanks
Brian
D3DXCreateSphere

This topic is closed to new replies.

Advertisement