[MFC] How to make a ball bounce off from an object?
How would i make the ball bounce off from the object (bitmap) in MFC? (look at the picture below)
How would i set the boundaries and stuff?
Does anyone have the code?
I really really need help....i need to complete my project soon.
just in case you want to know, the bitmap size is 40 x 40.
don't know if it matters though.
and remember, i want the ball to bounce off from all four sides of the bitmap, and it would just repeat this process over and over.
Last edited by hkboy1019; April 27th, 2004 at 09:12 PM.
Assuming you have objects for ( a ) the ball, and ( b ) the obstacles; all you need to do is check that the two are not intersecting after you've moved them.
Some pseudo code:
Code:
- Check ball bounds for obstacle intersection
- If something intersects, check which side of ball
- Change ball direction based on side hit
- Move ball
While this is a simple solution; I don't have any actual code offhand...
The project file contain the program of bouncing ball. This require DirectX SDK to compile. But you can run the executable inside the release folder. And i written this program just for fun
Originally posted by MrViggy
HAHAHAHAHAHAHA! That's funny! I didn't realize that!!!
Viggy
yeah, i started that thread.
i solved that problem (in the other thread)...so now i could click anywhere in the four areas and the ball will move to different directions!
Originally posted by patricksky
The project file contain the program of bouncing ball. This require DirectX SDK to compile. But you can run the executable inside the release folder. And i written this program just for fun
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.