phys pong
So this is a game of Pong, but with slightly modified bounce mechanics. Rather than basing the ball’s angle on where it hits the paddle, like the classic version, this one takes a bit more inspiration from real life. If the ball hits your paddle while the paddle is still, it’ll bounce a bit like a billiard ball against the edge of the table. And if your paddle is moving, it’ll add its speed to the ball.
Also, you control your paddle’s acceleration, a bit like a car, so feel free to try experimenting with it a bit!
This was my first project in TIC-80, and in Lua, and while you might’ve heard of Lua, you might not have heard about TIC-80.
TIC-80 is a “fantasy console”, meant to emulate a fictitious retro video game console. The console provides a fairly narrow API for input, output, and reading and writing memory, and the display is pretty small, but limited palettes can motivate creativity and provide a lot of room for learning.
Which leads me to Lua.
In my CS classes, we learned languages quickly, identifying any idiosyncrasies we needed to be aware of in order to focus on our projects. In the case of Lua, I’d never used prototypes to make objects before, but it didn’t take long to learn, and once I did, I was able to focus on problem-solving and architecture.
I actually started making the game after completing a short tutorial on how to animate a ball bouncing around the screen. The project reminded me of Pong, so I figured I’d try making a game like Pong myself.
The main game loop checks for player input, updates the ball’s position, then checks if it’s out of bounds, in which case, the player who knocked it in gets a point.
While the basic logic for updating a ball’s position had already been developed, I had to modify a lot of it in order to allow the ball to fall off the screen, and to follow a paddle once it had done so. I also had to develop the logic for updating a paddle’s position.
A lot of the process involved refining what I actually wanted the game to be like. I thought it could be fun to experiment with simple physics, and limit the player’s control over the paddle’s position, so I tinkered a bit with the acceleration to make it feel like the paddle slides along the side of the screen, and like there’s a bit of friction to slow it down when the player releases the control. I think it adds a new dimension to the game, and makes experimenting movement a bit more fun.
I also spent a decent amount of time trying to work around some poor decisions I’d made early on, with how I encoded each player, and how their paddles would be spawned onto the screen. While I had tried early on to decouple, for example, the physics from the graphics, I also encoded each player with a numerical ID, and designed a general “Player” which, based on its ID, would spawn in a different location, and made the actual size of the field much smaller than what’s displayed (the ball is scaled to eight times its size), resulting in enough opacity that I ended up having to guess about my earlier intent while working out some of the physics behavior, and deciding whether certain features felt weird because the physics weren’t great, or the graphics just weren’t quite right.
In the future, I’ll need to be clearer about my intent, the relationship between different kinds of data, and how I try to separate out different concerns.
Overall, though, I’m pretty happy with how the game turned out. I got to experiment with game development, learn a new language, as well as a new programming philosophy, and familiarize myself with the API for TIC-80, which I plan to continue tinkering with in the future.
I hope you have fun experimenting with different approaches to controlling the paddle and the ball, and playing against friends!