I'm trying to make a Brick Breaker game in Java and I want my ball to have a curved trajectory, based on paddle's acceleration (no gravity involved). How can I compute the ball position at a given moment? I think I need to compute the velocity first but i can't figure out how to do this.
Curved Trajectory for a 2D game in Java
536 Views Asked by user3801593 At
1
There are 1 best solutions below
Related Questions in JAVA
- How to define WIX agent requirement in TeamCity?
- Reading msbuild syntax
- Release Management for Visual Studio 2013 - Release Exception
- Exception in SonarQube.Msbuild.Runner
- How to build rptproj using C#
- Can't build a project with Postsharp 4.1.14
- Migrate ClickOnce certificate from Sha1 to SHA256 and run on .NET 4.0 client machines
- Run MSBuild from powershell without specifying .Net version
- hosted build visual studio online
- WebDeploy from TFS using Build Definitions to IIS site containing files changed by users
Related Questions in PHYSICS
- How to define WIX agent requirement in TeamCity?
- Reading msbuild syntax
- Release Management for Visual Studio 2013 - Release Exception
- Exception in SonarQube.Msbuild.Runner
- How to build rptproj using C#
- Can't build a project with Postsharp 4.1.14
- Migrate ClickOnce certificate from Sha1 to SHA256 and run on .NET 4.0 client machines
- Run MSBuild from powershell without specifying .Net version
- hosted build visual studio online
- WebDeploy from TFS using Build Definitions to IIS site containing files changed by users
Related Questions in GAME-PHYSICS
- How to define WIX agent requirement in TeamCity?
- Reading msbuild syntax
- Release Management for Visual Studio 2013 - Release Exception
- Exception in SonarQube.Msbuild.Runner
- How to build rptproj using C#
- Can't build a project with Postsharp 4.1.14
- Migrate ClickOnce certificate from Sha1 to SHA256 and run on .NET 4.0 client machines
- Run MSBuild from powershell without specifying .Net version
- hosted build visual studio online
- WebDeploy from TFS using Build Definitions to IIS site containing files changed by users
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The Spinning ball's path.
Curved trajectory? Do you mean when you hit the ball you add spin to the ball and then that spin causes the ball to curve through the air?
If so then use the following method.
The ball needs the following properties
And a bat
When the ball hits the bat do the normal reflection.
To convert the bats sideways movement into ball rotation just needs the ball's radius (for the most simple method) Assuming that the bat is at bottom of screen.
The amount of spin is related to the ball sideways motion relative to the bat, then divided by the radius to give the change in rotation per frame. Add that to the ball's current rotation
We are not going to do a full fluid dynamic simulation but rather an approximation.
Magnus effect
When a ball moving through the air, is spinning, one side of the ball moves forward in the air stream (outside), and the other side move in the opposite direction (inside). The imbalance in airflow over the surface and the way the inside spin pulls the air with it causes a low pressure region on the inside in the direction perpendicular to the ball's motion.
The force applied by this low pressure area is spread over the ball's diameter
We don't need all of this. Air density is fixed as is the ball radius. Thus the force is a linear relationship between ball velocity and ball spin rate. The rest can be set as a coefficient value we can call spinCof
The force adds acceleration which is dependent on mass. Again this does not change so we can add that to the spinCof value.
So the final formula is
The value of spinCof is unknown and you will need to experiment to find a value that is playable.
To do this in code
And that is it.
And quick example of this in practice