1
\$\begingroup\$

I am trying to implement realistic physics for my game plinko. As of now i only implemented the inversion of the velocity and the distance between both objects.

public void changedirX () { velocityx = -velocityx; } public void changedirY() { velocityy = -velocityy; } 

And the 'back bounce' of the ball gets implemented here:

if (Circle.isColliding(win1, kugel)){ //gewinn berechnen, Kugel entfernen } 

Now the ball just bounces back infinitely until it hits the bounds of the canvas. I know that i need to implement the airresistance but do not know how to start. The questions answered here on StackExchange do not have any full code unfortunately. How can i let the ball bounce realistically without just falling down vertical.

\$\endgroup\$
6
  • 1
    \$\begingroup\$ Does this answer your question? How to calculate the exit speed of ball bouncing off a solid surface \$\endgroup\$ Commented Sep 16, 2023 at 12:35
  • \$\begingroup\$ We also have posts on calculating air drag. \$\endgroup\$ Commented Sep 16, 2023 at 12:52
  • \$\begingroup\$ @Pikalek i can't use vectors in android studio, i tried everything i know and posted a question about it too here. Is there any way to calculate that without vectors or do you know a way with handling vectors in android studio (canvas)? \$\endgroup\$ Commented Sep 16, 2023 at 15:24
  • \$\begingroup\$ There are three good books on this topic. Amazon... Game Physics In One Weekend, Game Physics The Next Week, Game Physics The Rest of Your Life.. There is a physics/collision library for shapes called bullet.. pybullet.org/wordpress \$\endgroup\$ Commented Sep 16, 2023 at 16:27
  • \$\begingroup\$ Do you have to use vectors? Yes & no. You don't have to use a vector class, but you do have to deal with X,Y coords, velocities & forces. The options are to use a predefined Vector class/struct, make your own vector class, or track the relevant info as variables pairs (i.e. posX, posY, deltaX, deltaY, etc.) Folks tend to use a vector class because it's a useful abstraction. To clarify: these are math type vectors not the dynamic list type \$\endgroup\$ Commented Sep 16, 2023 at 22:48

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.