Forums

Forums (http://www.abandonia.com/vbullet/index.php)
-   Programming (http://www.abandonia.com/vbullet/forumdisplay.php?f=25)
-   -   Bouncing Ball (http://www.abandonia.com/vbullet/showthread.php?t=13401)

nitro 02-02-2007 07:08 AM

Hello

I am trying to create a pinball game, but I don't know how to program a ball that bounces of the sides in a realistic way.
Does anyone have any experience with this or already have some working code?

Thanks in advance.

Shadikka 05-02-2007 06:20 PM

It depends on the language you're coding in.

If you want to really make a realistic bounce, you should consider the following:
- The tilt of the board
- Friction
- How much does the side absorb of the energy

The easiest part is of the angle is probably the simple fact that when it bounces to the wall at an angle, it bounces off at the same angle. With the tilt applied etc. Physics are fun, aren't they?

orieac 10-02-2007 08:18 PM

If you don't know how to do it, why don't you create the table with Future Pinball (http://www.futurepinball.com/).

nitro 18-02-2007 01:05 PM

<div class='quotetop'>QUOTE(Shadikka @ Feb 5 2007, 09:20 PM) [snapback]278143[/snapback]</div>
Quote:

It depends on the language you're coding in.
[/b]
That will be C++ with SDL.

<div class='quotetop'>QUOTE(orieac @ Feb 10 2007, 11:18 PM) [snapback]278761[/snapback]</div>
Quote:

If you don't know how to do it, why don't you create the table with Future Pinball (http://www.futurepinball.com/).
[/b]
I know that is easier, but you will miss the fun part of coding a physics engine. Future pinball is also Windows based and I want to run my game also on Linux.

I will try to create something myself and If I make any progress I'll post it and maybe it can be of some help to someone else.

Thanks anyway

Reup 19-02-2007 06:22 PM

Maybe you'll find out something on Gamedev. They have quite a few game physics articles.

nitro 20-02-2007 04:17 PM

Thanks for the link Reup. I will check it out.

I have written some code for a bounce on a straight wall. What I do is split the velocity in two part. The part parallel to the wall and the part perpendicular to the wall. Then I reverse the part perpendicular to the wall and I combine them to the true velocity. I know it's not perfect as this code generates a 100% perfect bounce. without any loss of energy, but for now it'll do.

I can also use it for a bounce against an arc but the ball can get stuck for a while in some rare cases.

Next up: adding gravity and friction

STFM 13-03-2007 05:19 AM

ever thought of trying out vectors? since a vector can describe an objects velocity and direction at any time it might make things easier

nitro 13-03-2007 06:42 AM

Yes, I'm already using vectors, but thanks anyway.

Taskmaster 14-03-2007 02:17 PM

And don't forget transfer of energy from the reflecting object. That is, if the bumper is pushing the ball i the opposite direction it may actually gain speed.



The current time is 10:39 AM (GMT)

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.