Go Back   Forums > Community Chatterbox > Tech Corner > Programming
Memberlist Forum Rules Today's Posts
Search Forums:
Click here to use Advanced Search

Reply
 
Thread Tools Display Modes
Old 02-02-2007, 07:08 AM   #1
nitro
Forum hobbit

 
Join Date: Jan 2007
Location: Nunspeet, Netherlands
Posts: 31
Default

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.
nitro is offline                         Send a private message to nitro
Reply With Quote
Old 05-02-2007, 06:20 PM   #2
Shadikka
Newbie

 
Join Date: Aug 2005
Location: Ofverby, Finland
Posts: 12
Default

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?
Shadikka is offline                         Send a private message to Shadikka
Reply With Quote
Old 10-02-2007, 08:18 PM   #3
orieac
Newbie

 
Join Date: Oct 2006
Location: Lisbon, Portugal
Posts: 15
Default

If you don't know how to do it, why don't you create the table with Future Pinball (http://www.futurepinball.com/).
orieac is offline                         Send a private message to orieac
Reply With Quote
Old 18-02-2007, 01:05 PM   #4
nitro
Forum hobbit

 
Join Date: Jan 2007
Location: Nunspeet, Netherlands
Posts: 31
Default

<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
nitro is offline                         Send a private message to nitro
Reply With Quote
Old 19-02-2007, 06:22 PM   #5
Reup
10 GOSUB Abandonia
20 GOTO 10
 
Reup's Avatar

 
Join Date: Dec 2004
Location: Eindhoven, Netherlands
Posts: 1,508
Default

Maybe you'll find out something on Gamedev. They have quite a few game physics articles.
Reup is offline                         Send a private message to Reup
Reply With Quote
Old 20-02-2007, 04:17 PM   #6
nitro
Forum hobbit

 
Join Date: Jan 2007
Location: Nunspeet, Netherlands
Posts: 31
Default

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
nitro is offline                         Send a private message to nitro
Reply With Quote
Old 13-03-2007, 05:19 AM   #7
STFM
Abandonia nerd

 
Join Date: Sep 2005
Location: ,
Posts: 96
Default

ever thought of trying out vectors? since a vector can describe an objects velocity and direction at any time it might make things easier
STFM is offline                         Send a private message to STFM
Reply With Quote
Old 13-03-2007, 06:42 AM   #8
nitro
Forum hobbit

 
Join Date: Jan 2007
Location: Nunspeet, Netherlands
Posts: 31
Default

Yes, I'm already using vectors, but thanks anyway.
nitro is offline                         Send a private message to nitro
Reply With Quote
Old 14-03-2007, 02:17 PM   #9
Taskmaster
Super Freak

 
Join Date: Oct 2005
Location: Tallahassee, United States
Posts: 167
Default

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.

__________________
i kick spammers asses on every forum i register.beware!
Taskmaster is offline                         Send a private message to Taskmaster
Reply With Quote
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bouncing Babies Tom Henrik Games Discussion 45 19-12-2009 10:30 PM
Bouncing Bob Goes to Hell chilledsanity Cold Cases 1 18-09-2007 09:00 PM
On the Ball - World Cup Edition Cadet Hog On site 4 23-05-2006 02:34 PM


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump
 


The current time is 11:45 PM (GMT)

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