Pong Game
This project, coded in Python, is one of my first explorations into reactive behavior, also known as videogame AI. Pong is a simple game designed in 1972 by Nolan Bushnell. In this game, collision detection and game mechanics have been fully implemented.
The game mechanics rely on basic physics with velocity and collision control with borders, related to CPU and user movement, very similar to Flappy Bird. The ball is randomly generated along Y-axis, in order to provide some lucky factor. A dual counter has been added to compare the CPU vs Player skills.
The game was initially developed using Python with Pygame, a popular library designed for coding 2D games by providing functionalities for rendering graphics, handling user input, and management of game logic. As other games, to be deployed on the web the code was translated to p5.js, a JavaScript library based on Processing, allowing integration with HTML and web technologies. The code developed in Python can be found here.
Regarding the AI topic in this game, reactive behavior has been added. The CPU paddle moves based on the ball's position, reacting in real-time. Whenever the ball moves upward (decreasing along Y-axis), the CPU paddle is also decremented at the same time as the ball. Likewise, when the ball moves downward, Y-axis coordinates increase. Following this logic, if we wanted to design an unbeatable game with Pong, if ball speed is equal to CPU paddle speed, it will always track the ball's coordinate, making the game unwinnable.
W and S to move.