PLEASE NOTE: this is an older version of my pong game, please find the post on the newer one over here, or download it on the code downloads page right away.
The NXT pong game is finished at last! It uses my previous bouncing ball program, combined with a player-controlled bat, different levels, random difficulty increase and point display. The ball starts off at a random position within the playing field, to avoid patterns, after which it bounces off every wall (or bat) it meets, at a 90° angle. The bat is controlled by turning the wheel connected to motor A, and its stopped whenever it tries to exit the allowed area. Once the ball gets one pixel away from the bat, it compares its own position to the bat’s, and bounces away when it’s acceptable, increasing your point-count with one for each hit. In case it’s not, the game freezes and the famous “you lose” appears on the display, after which the program is aborted.
The game has different levels, too; the level you’re playing at is increased by one whenever your points are above 150% of the last level you passed (if the last level was ten, you’d need to get above 15, then 23, then 35, etc.), so it takes longer as you get better. Each time the level increases, the NXT randomly picks one of the following to make your life more difficult:
Increasing the ball’s speed, by decreasing the waiting time at the end of the main loop
Decreasing the bat’s speed, by increasing the amount of encoder ticks it takes to move one pixel
Making the bat smaller, by four pixels
So, it really gets hard after level seven! Here’s a demo movie, explaining what’s happening (kind of) and when:
something else I’ve been working on: a two player tick-tack-toe game. Here’s a video of me playing it:
It lets you select a box and highlights it according to what’s inside it, so you know where you are. When you click, it puts either a cross or circle into the spot according to whose turn it is. The coding allows for me to change it into a one player game, but I haven’t started on that yet.