classic 2D tennis ball and mechanism question

Blitz3D Forums/Blitz3D Programming/classic 2D tennis ball and mechanism question

hoyoyo80(Posted 2016) [#1]
Hi there.

I interested to make classic 2d nes tennis like this

[a https://i.ytimg.com/vi/gOEeaKEyW98/hqdefault.jpg[/a]

Firstly i never do 2d and ball physic but now i would like to learn. So my questions are:
1.I use predetermined drop point(known travel distance) for the ball starting from the player.I manage to make it move in straight line.But i would like to make it travel in arc/curved like real ball. I do find the equation online but fail to translate into games. Can someone give the idea?(As for know i draw some points along the straight path and manually position it in arc form)

2.if my game view is the same as the classic nes,how do i determine the real position of the ball when comparing player y and the ball y location. E.g volley shot is higher than the player but how to differentiate the location.

3.When the player hit the "hit" button together with direction key, how do i implement the combo to create a known distance(drop point) on the opposite courst.(For know, i use move to create the known point)

Please help:)

Thanks


Rick Nasher(Posted 2016) [#2]
Perhaps: https://www.youtube.com/watch?v=WOrX8mgtx8o


Cocopino(Posted 2016) [#3]
Regardless of the visual presentation of your tennis court in 2D, you'll still need 3D coordinates for the tennis ball and the rackets. I doubt you'll need physics or a very realistic ball trajectory.

If it were me I'd go for something really simple at first, see how that turns out. Just make the ball trajectory move in a straight triangle-like line, you'll need 3 points in 3D space:
1. racket player
2. highest point
3. the target on the other side of the court where the ball will land

You could smoothen the trajectory by manipulating the Y coordinates of the ball (during the first part of the trajectory the ball should gain height more quickly than when nearing the highest point)

Calculate the distance (in 3D) between the player's racket and the ball. If it's less than x inches, the ball will be hit.


RemiD(Posted 2016) [#4]
About ball physics do a search on the forum/codearchives about "ball physics" "billard physics" "marble physics" "angle reflection", i remember to have seen some code examples...


hoyoyo80(Posted 2016) [#5]
Thanks for the replies...

Currently i use fake curve where i draw a straight light and then alter some waypoint.



This one also worry me, if im comparing the ball and the player Y coordinate, he not supposed cant hit the ball since the ball is not in his direction...i read around about create fake z coordinate to differentiate that but i clueless how to start



RemiD(Posted 2016) [#6]
Also do a search for "tank bullet physics", i remember to have seen 2 code examples that may help you.