Magmescape Mac OS

A paddle-whacking game built from ground up in Unity, initially as a pong-like game…But ultimately on the path to becoming an air hockey game.

Magmescape

Magmescape Mac Os X

Ea games for mac From high fantasy to competitive sports – you can tap into the excitement of EA's hottest Mac games! Unleash your imagination in The Sims 4, rise to power and fight epic battles in Dragon Age II, build a living world where every choice matters in SimCity, and more. A paddle-whacking game built from ground up in Unity, initially as a pong-like game But ultimately on the path to becoming an air hockey game.

Catalina

Can download and play on itch.io!: https://jeffreypersons.itch.io/paddle-whacker

Sample Screenshots

Start menu screen

Game play screen

Game end screen

Magmescape Mac Os Catalina

How the AI works

Basically, the ai runs in a seperate coroutine launched (after a response time delay) when its opponent (ie the player) hits the ball, and then approachs the point that the trajectory intersects with the x position of the ai’s paddle.

Implementation details for nerds

Magmescape Mac Os Update

  1. listen to opponent paddle hit event
  2. on an opponent hit event, launch a coroutine after time N (ie 20 milliseconds, to simulate human reaction delay), in which the ai paddle does not move
  3. when the delay is up, the trajectory of the ball is predicted by casting a ray from the ball’s position, in the direction of the ball’s velocity, casting an additional ray for each HorizontalWall hit, until the ray reaches the AI paddle’s X position, or max number of iterations occurs
  4. from the list of positions, we set the targetPosition to be the Y position of the final predicted position in the pathupon hitting the AI paddle, the targetPosition then switches to simply vertically aligning itself with the ball, until its opponent hits it again
  5. repeat from step #2

Note that there is some randomness built in to the AI speed in addition to the response time delay, to give it a bit of a more human feel.