473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Ball physics

ilikepython
844 Expert 512MB
Hi,
I made a pong game with pygame. It works pretty good but I want the ball to bounce realistically. Just like in real pong when it bounces off the right edge it goes to the right and when it bounces off the left edge it goes to the left. Right now, I just reverse the x speed of the ball (3 becomes -3). I need a way for the ball to bounce off the paddle depending on where it hit. I tried looking on Google but I couldn't find anything. Does anyone know how to implement physics like in real pong?

Thanks in advance.
Apr 24 '07 #1
1 2246
JonLT
41
on collision, devide you velocity vector in to components one perpendicular to the collision surface and on parallel. If you dont want frinction or "bounciness", all you need to do is to negate the perpendicular component. If you want frinction and "bounciness" scale the perpendicular component with a bounceCoef and the parallel with a frictionCoef, but tou still need to negate the perpendicular component.
Jul 24 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Satish Chimakurthi | last post by:
Hello all, For the last six months I have been working with Python for a certain multi-physics application (Fluid-Structure Interactions) related to my project. Beyond any doubt, Python proved to...
5
by: carl bloc | last post by:
Has any body got any code for this brief that a friend has to do, its for the uk version of the lottery i.e 6 balls and a bouns ball. 1. a control loop is required to determine the operation...
2
by: Joan Parera | last post by:
Hello everybody, I have been searching around the net for a good (commercial or non-commercial) physics engine written in C#. Unfortunately I only know the existence of many physics engine...
1
by: sake | last post by:
Dear All, I'm working on a 3d breakout game in C++, and I'm having a little trouble with the collision. It will detect that the ball has hit the paddle just fine, but after that, how do I determine...
2
by: SilentCodingOne | last post by:
I have a application where each time you click the add ball button a new randomly colored ball is added to the jpanel. It works fine except that the balls suddenly stop at the same spot. I want them...
0
by: kirby.urner | last post by:
This archival (yet recent) posting to an obscure physics list might be of some interest to those taking a longer view. The work/study projects described below come from an Oregon think tank...
0
by: andreachilam | last post by:
I am doing a project of creating a playing pool and 2 balls bouncing within the pool. I have tried to use "while loop" and "if statement" to set restriction limiting the ball not to bounce out of the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.