Hi everybody!
I'm trying to do a "simple" 2D tennis game, like Tennis NES
or, the more complicated Mario Tennis GB
.
I found another topic about adding visual z depth to the ball, but that's not where I think I will have a lot of trouble.
So basically I thought about the logic behind the basic functions, but I fail to find the correct math to link it all, and I wanted to share it right now with you, to see if my logic works or if it doesn't make sense.
Please tell me what you think, and what you would change/suggest!
---
So, basically we have 3 types of shot. The
top spin is a normal, powerful shot. The
slice shot is a precise, short shot, where the ball doesn't go very far up. And the
lob shot is a very long, but slow shot, where the ball goes very high.
The idea is that I have the main ball collider, invisible, which follows a straight line. I then put a shadow, and a visible ball sprite, that goes up and down, and bounce. The height should be used to check if the player can hit the ball and if the ball is higher than the net.
Ball angle : analog stick angle + a small error margin depending on the type of shot precision.
Type of shot strength : A small constant value determined by each type of shot
Player strength : A value determined by a holden button time before the shot (aka charging the shot)
Ball speed : Type of shot strength + player strength + incoming shot speed + deceleration over time
Bounce number : A value that starts at 0 and increases which each bounce, influencing the ball speed and height.
Ball height : For the ball sprite, il will determine the visual height of the ball and be used to test if the ball is higher than the net and hittable (is that a word?). The y=0 will be the shadow y, and it should be determined by : the type of shot, the ball speed, and the bounce number.
Ball height speed : ball speed, and accelerate/decelerate going up and down according to gravity,which I have no idea how to fake, for that specific use, I thought maybe something involving a lerp. Basically I know how to put "real" gravity for a plateformer, but for something top down, no idea.
Okay! I think I put everything in here! Thanks a lot for reading. Does that seem good to you? What change would you make? Does that sound stupid and there is a way better way to do this?
Thanks for your help!