1
\$\begingroup\$

I'm developing a 2D Brick Breaker style game in Java and want to apply some real time physics to it, especially to the paddle/ball interections. Nothing too complex; just applying some of the physics principles, like: friction to transfer horizontal movement from the curved, hemisferic shaped paddle to the ball in order to change its direction; linear velocity, and maybe angular velocity to add spin to the ball, without change the ball speed; and collisions/resultant angles between the ball, the paddle, the walls and the blocks (rectangular, triangular and spherical shapes).

The point is, the few physics engines/codes that I found for Java have a lot of stuff in them, and I only need to apply few of them to my game. So, is there a way to just pick and add the functions and methods that I need, or do I have to put the entire packages of the physics engine/code to my project?

These are the physics engines that I found for Java:

http://kickjava.com/src/JSci/physics/RigidBody2D.java.htm

https://www.javatips.net/api/bdx-master/extern/gbullet/src/com/bulletphysics/dynamics/RigidBody.java

Thanks for your attention!

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

Don't worry about a package you want to use having more stuff in it than you need. It's unlikely a package will have just what you need... but no more than that.

What's more important is if it can do what you need within your performance constraints, and if you can understand it well enough to work with it. Bigger packages can be overkill, but they're not necessarily wrong to use for smaller projects.

Personally, I would recommend using Box2D. There's a Java port of it here, maybe there are other ports of it.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .