Click here to play this Pong mod.
The circles are randomly generated using code similar to the randomly generated squares from the group Pong mod. Where I used one for loop to generate a line of squares, here I used two for loops to create a grid of circles. Plugging randomly generated numbers into the for loops breaks up the grid into a more interesting mess of circles.
Unlike the squares (which were hidden for a time and then revealed with a new random color), the circles are destroyed when the ball passes through them. The destruction of a circle triggers another piece of code that creates a new circle after a few seconds in a random place. The reason for the two different methods is that I wanted to squares to always appear in the same line, and the circles to be more unpredictable. Not destroying the squares was the easiest way to store the screen position. Since nothing of the original circle would be needed for the regenerated circle, it made sense to just destroy the original and create a new one.
Mod game logic:
- Same rules as regular pong plus below
- Circles pass their color on the ball
- Circle disappears
- New circle appears after a few seconds
- Players can switch between two paddle colors
- If the paddle and ball colors match, the ball is deflected
- If the paddle and ball colors do not match, the ball passes through the paddle
No comments:
Post a Comment