@@ -5,10 +5,11 @@ layout: post
5
5
comments : true
6
6
---
7
7
Pong is one of the earliest arcade games, written to run in very simple hardware but with some interesting
8
- properties with regards to its physics system. Basically, when the ball collides with the paddle it's direction
9
- is inverted and it starts going to the other side of the screen. However, Pong itself and its several clones
10
- implement this in way that the ball behaves differently accordingly to the part of the paddle it hits. This is
11
- exactly where things get a bit more interesting.
8
+ properties with regards to its physics system. Basically, when the ball collides with the paddle its direction
9
+ is inverted and it starts going to the opposite side of the screen.
10
+
11
+ However, Pong itself and its several clones implement this in a way that the ball behaves differently according
12
+ to the part of the paddle it hits. This is exactly where things get a bit more interesting.
12
13
13
14
<div style =" text-align :center " markdown =" 1 " >
14
15
![ Ellipse Normals] ( /images/ellipse-normals.png )
@@ -24,12 +25,10 @@ The behaviour I wanted for the reflections is illustrated by drawing above. The
24
25
the current direction vector, surface normal and reflection vector, respectively.
25
26
26
27
What happens here is that the normals of the surface will affect the output angle of the ball, thus giving the player
27
- more control on the player morecontrol on where they want the ball to go.
28
+ more control on the player more control on where they want the ball to go.
28
29
29
- The behaviour can be achieve by applying the [ vector form equation of a specular reflection] ( http://en.wikipedia.org/wiki/Snell%27s_law#Vector_form ) .
30
+ The behaviour can be achieved by applying the [ vector form equation of a specular reflection] ( http://en.wikipedia.org/wiki/Snell%27s_law#Vector_form ) .
30
31
To do that, we need to evaluate the equation of the normals at a given ** t** , where ** t** is the normalized height where the
31
32
ball hitted the paddle.
32
33
33
- With this last piece, we can finally put our vectors back into the reflection equation and obtain our new direction vector.
34
-
35
34
And that's pretty much it. Have fun!
0 commit comments