Jun 5, 2023

Top Players Tennis

This game doesn't get much love, and rightly so, but I grew up with it. I could have sworn back then that stats like Spin made a huge difference in how the ball traveled. Yet, playing it again and looking at the code for this game, Spin is more or less negligible. I don't think my version was any different from the version of the ROM I have. The nice thing about playing on a ROM was I could finally figure out what each stat actually did! 

I waded into this code in an attempt to help someone make an old-school tennis game. This was the only tennis game I was very familiar with. These are some of my takeaways from this recent expedition.

 

Ball Physics 

BALL MOTION

On the surface, this game appears to be semi-realistic. It incorporates aerodynamics and such. However, the vertical axis is treated separately from the horizontal axis. This may be simply to make the logic simpler for the designers, but it does make the game feel like it originated as a 2.5D side-view tennis game. The artificial z axis is for gravity. The vertical axis is for impulse motion. The horizontal axis is for angular returns and ball spin.

COURT SURFACES

Each court has a restitution value that affects how high a ball bounces, and a friction value that affects the vertical speed after bouncing. The higher the value, the less significant the changes in velocity. The French Open's clay court has a friction value of 68% and a restitution value of 62%, meaning with each bounce the vertical speed will decrease by 32% and the bounce height will decrease by 38%. In contrast, Wimbledon's grass court has a friction value of 81% and restitution value of 59%, meaning with each bounce the vertical speed will decrease by only 19% and the bounce height will decrease by 41%. The differences between restitution values might not seem like much, but after factoring in gravity, a 3% difference is significant. 

For the sake of comparison, the back walls have restitution and friction values of 37% each. The net has a restitution of 65% and a friction value of 22% affecting both vertical and horizontal speeds.

Swing Types

There are 6 types of swings. Each swing type scales the normal vector - in other words, the rising speed - of the ball by a percentage as the ball leaves the racquet. 

  1. The standard swing, as well as a standard serve, using A has no effect on the ball when hit in the lower court, and scales the rising speed of the ball by 112% in the upper court. 
  2. A diving swing using A+B away from the net scales the rising speed by 43% in the lower court, and by 50% in the upper court. 
  3. A play at the net (both standing and leaping), scales the rising speed by 12% in the lower court, and by 48% in the upper court. 
  4. A lob swing using B increases the rising speed of the ball by 150% in the lower court, and by 154% in the upper court. 
  5. A jump serve scales the rising speed by 62% in the lower court, and by 59% in the upper court.
  6. A soft serve scales the rising speed by 96% in the lower court, and by 78% in the upper court.

The differences between lower court and upper court are to account for the game's perspective. In a game without such 2D perspective, this would be detrimental for players in the upper court.

Ball Gravity

Gravity is unique for the ball and can be thought of as the net vector of physical gravity, aerodynamic lift, and aiming. A default gravity is calculated based on what is essentially a random value updated after the ball is hit. For the player, the height of the ball when serving determines the racquet angle, with the majority of angles setting gravity to 1/2pps². For the CPU, the value is randomly chosen. Then, if the ball is being served, an additional 1/32pps² is added make the ball drop faster. If the player is near the net, 1/64pps² is added to gravity.

 

PLAYER STATS

STRENGTH

Affects vertical speed of the ball upon impact with racquet. Each level adds 5/64pps to the ball's vertical speed. Players should try to max this out before playing the Wimbledon Open.

Note that higher ball speed increases the likelihood of out-of-bounds or fault shots, but is valuable for scoring aces. On grass courts, with their low friction coefficient, higher ball speed is preferred.

SPEED

Affects maximum running speed. Default is 117/32 pixels per step. The first 2 levels add 16/32pps to your speed, then only 8/32pps per level after that, until level 10, which again increases it by 16/32pps. Players should therefore only put up to 2 points in SPEED when starting out.

Note that higher running speeds result in longer stopping delays. Higher AGILITY does help mitigate this, but not by much.

AGILITY

Affects acceleration and deceleration rates of the player. Default acceleration rate is 15/64pps². Default deceleration rate is 25/64pps². The first 2 levels increase acceleration by 1/32pps² and deceleration by 1/64pps². Each level after that only increases acceleration by 1/128pps² and deceleration by 1/256pps², except that last 2 levels. Level 9 increases acceleration by 1/32pps² and deceleration by 1/64pps², whereas level 10 increases both acceleration by 1/64pps². Players should therefore only put 1 or 2 points in AGILITY when starting out.

Note that deceleration rates do not improve parallel to maximum speeds, increasing momentum adversely. Players should maximize AGILITY before raising SPEED past level 3.

STAMINA

Affects reduction of STRENGTH, SPEED and AGILITY levels. This is an arguably useless stat, as even at level 0 it will still take 5 minutes and 40 seconds before the first stat drop. On top of that, it has laughable diminishing returns until level 8. Players should therefore only put 2 points in STAMINA and then ignore it until the three affected stats have been maxed.

SKILL

Affects horizontal speed of the ball upon impact with racquet. Roughly speaking, it increases the angles the ball can travel. There are essentially 8 positions on the racquet the ball can hit, with 8 possible directions the ball can travel (16 after final calculations), for a total of 64 horizontal speed values per level, making it difficult to actually quantify this stat. Basically, each level uniformly increases horizontal speed by some factor determined by the angle the ball is hit, which results in the ball traveling at wider angles. Beginner players may want to max this out first, even though it does potentially result in more returns going out-of-bounds.

Note that at higher levels, this makes serves veer away from the center of the court. This is critical for scoring aces in the early stages of the game. Against faster and smarter opponents, this is less valuable.

BALLSPIN

Affects acceleration of the ball by 1/256pps² per level. Not entirely useless. Left and right spin affect horizontal acceleration explicitly. Top-spin and slices affect gravity explicitly. A slice (back-spin) effectively reduces gravity on the ball, whereas top-spin increases it. I don't think vertical acceleration is affected by Spin at all.

FOCUS

Affects reduction of SKILL and SPIN levels. This is an arguably useless stat, as even at level 0 it will still take 5 minutes and 40 seconds before the first stat drop. On top of that, it has laughable diminishing returns until level 8. Players should therefore only put 2 points in FOCUS and then ignore it until the two affected stats have been maxed.

MIRACLE

Affects which miracle shots you can perform. Once a miracle shot is unlocked, each level after that improves the shot up to four times. No miracle shots are available at level 0.

  1. Miracle Speed, unlocked at level 1. 
    • Level 1: increases ball gravity by 3/256pps² and speed by 6/4pps
    • Level 2: increases ball gravity by 13/256pps² and speed by 3/4pps
    • Level 3: increases ball gravity by 23/256pps² and speed by 4/4pps
    • Level 4: increases ball gravity by 33/256pps² and speed by 5/4pps
    • Level 5: increases ball gravity by 43/256pps² and speed by 6/4pps
      Note that there may be a typo with Miracle Speed's boost to vertical movement. With the negligible gravity boost at its initial level, this makes Miracle Speed practically suicidal at the first level. Players therefore should put 2 points in MIRACLE together if intending to use this game feature at all. 
  2. Miracle Lob, unlocked at level 2. 
    • Level 2: sets top-spin to 31/32pps² and drop height to 112
    • Level 3: sets top-spin to 28/32pps² and drop height to 128
    • Level 4: sets top-spin to 27/32pps² and drop height to 144
    • Level 5: sets top-spin to 26/32pps² and drop height to 160
    • Level 6: sets top-spin to 25/32pps² and drop height to 176
      Note that the ball will always attempt to land in the same positions, roughly just behind the service lane to the middle of either service box. It will never go past that position. The service box chosen depends on the horizontal speed of the ball (see "SKILL" summary). Once the drop height is reached, the ball will fall wherever it currently is over the court. Because of this behavior, the skill is best used near the sidelines. 
  3. Miracle Spiral, unlocked at level 3. 
    • Level 3: radius of 10px
    • Level 4: radius of 16px
    • Level 5: radius of 24px
    • Level 6: radius of 36px
    • Level 7: radius of 49px
      Note that only its horizontal position changes. The vertical offset is merely a draw effect, making a Miracle Spiral return tricky for human opponents to follow. When used as a serve, CPU opponents will get confused, frequently hitting the ball before it has bounced, resulting in a point for the player.
  4. Miracle Return, unlocked at level 4.
    • Level 4: no effect
    • Level 5: accelerate vertical speed by 1/32pps² based on volley count
    • Level 6: accelerate vertical speed by 2/32pps² based on volley count
    • Level 7: accelerate vertical speed by 3/32pps² based on volley count
    • Level 8: accelerate vertical speed by 4/32pps² based on volley count
    • Level 9: accelerate vertical speed by 5/32pps² based on volley count
      Note that this ability is extremely difficult to use. And glitchy... so glitchy. Volley count is set to 0 when served from the lower court, or set to 1 when served from the upper court, and increased whenever the ball is hit. That means typically this ability merely slows down the ball, making it relatively useless. The "return" referred to by the manual is actually in reference to the volley counter. If the ability is timed properly, the volley counter will not increase when the player hits the ball. This means if the ball hits the net or goes out of bounds before bouncing, it will count against the opponent. Sometimes it doesn't register and the hit is counted anyway, for some reason, in which case the player gets the miss instead of the opponent. Another use for it, which again requires very tight timing, is to use it as soon as the ball is in play on the opponent's serve, resulting in a let or fault.
  5. Miracle Split, unlocked at level 5. Essentially the same as Miracle Spiral, but without the height illusion.

Note that pulling off miracle shots can be understandably tricky. The game will check for a miracle shot every time the player's height is greater than 28px off the ground. Since this occurs many times during a jump, the player must continue to hold the D-pad in the direction corresponding to the desired miracle shot, otherwise the game will cancel the miracle shot completely.


No comments:

Post a Comment

©TheouAegis Productions™. Powered by Blogger.