Friday, February 28, 2020

Boing! A Python Tribute to Pong @Raspberry_Pi #PiDay #RaspberryPi

If you really want to do some quality age signaling, tell the tale of the first time you saw Pong. For me, it was via an Atari 2600 on a cathode ray tube TV set into a big wooden box. Pterodactyls flew overhead, we could hear the distant sounds of the storming of the bastille, and in the far distance we heard the sound of the first locomotive rumble by — but what kept our attention was Pong, the first breakout home video game hit. We played for days.

Ebon Upton has created a Python-based tribute to PONG called BOING, made for Code the Classics. Here’s more from RaspberryPi.org:

To show how a game like Pong can be coded, we’ve created Boing! using Pygame Zero, a beginner-friendly tool for making games in Python. It’s a good starting point for learning how games work – it takes place on a single screen without any scrolling, there are only three moving objects in the game (two bats and a ball), and the artificial intelligence for the computer player can be very simple – or even non-existent, if you’re happy for the game to be multiplayer only. In this case, we have both single-player and two-player modes.

The code can be divided into three parts. First, there’s the initial startup code. We import from other Python modules so we can use their code from ours. Then we check to make sure that the player has sufficiently up-to-date versions of Python and Pygame Zero. We set the WIDTH and HEIGHT variables, which are used by Pygame Zero when creating the game window. We also create two small helper functions which are used by the code.

See project!

The History of Pong


3055 06Each Friday is PiDay here at Adafruit! Be sure to check out our posts, tutorials and new Raspberry Pi related products. Adafruit has the largest and best selection of Raspberry Pi accessories and all the code & tutorials to get you up and running in no time!

No comments:

Post a Comment