AlderAutomation

Pong in Retrospect

Last updated: 0 minutes ago

Code: Pong on Github
Playable: Pong on Itch.io

Intro & Intentions

I recently made a Pong game in C with Raylib. Recently, as in, I just published it a few hours prior to starting to write this post. I guess one could say that this is my post mortem review of that experience.

I decided to make this game to better learn and understand C and game design. I intended to complete it but I never intended to release it or make a big deal out of it. For instance the code is a mess and needs to be refactored, and programming paradigms were not followed well; this was just a learning project. After having finished it though, it does feel like a big deal and I am going to make a thing out of it.

Tooling decisions

First I had to figure out what programming language I was going to use for this project. I had originally been planning to do this in C++ and SFML because that has been my go to programming language and renderer lately. However, I am taking a university course this semester where they are teaching C, so I decided I should be doing this in C to get the extra practice.

Next, I had to figure out what renderer to use. In my research, what I found was that I could still use SFML with C but a project called Raylib was much better and easier. I have been struggling with the complexity of SFML, not that its overly hard, but there is enough friction that it's been bothersome.

I got Raylib installed and I have to say that while it does lack nice tutorials it was a hell of a lot easier to install and configure compared to SFML. On Fedora, installing Raylib is as simple as:
sudo dnf install raylibdevel And in the C program:
#include <raylib.h>

Other tooling was fairly straight forward; Neovim editor, Git, Gitea, signboard, terminal, Firefox, Enscripton, and Itch.io.

NOTE ON AI: I don't know if I have said this before or not:

Programming

C doesn't have classes or any form of object oriented programming. I have only ever done OOP or scripting, so stepping into C with no classes was really weird at first. My ball and my paddles became data structs which held all my data. They each went into their own .c and .h files. Those files also got functions that related to them. Such as the ball files got the function for checking if the ball hit the walls or paddles. In hind sight, I feel like I still wound up setting this up as OOP. I need to do a lot of research on composition and much more practice.

One thing I noticed is that I could move functions around really easily. While refactoring the code for public display, I made a game logic file and moved a few functions from the paddle and ball files into that game logic file. The only thing I had to change in the main file was just to include the new header for the game logic file. Everything else continued to work as normal. If I had been using OOP, I would have had to change so much more code anywhere that those functions were being called.

Release and User Feedback

This was such a cool part of this project. I love seeing people using my products and offering feedback on how to improve it. I had several feature requests; add a pause, add a time elapsed, add a wall bounce sound, and make the AI easier to name a few. And I have added these features to the game. I had originally overlooked the pause and the timer but I had intentionally made the choice to not put in the wall bounce sound as I thought that it would become too much noise for the User, but I think I am more sensitive to noises than other people are.

Going Forward

Next things that I am working on:

If you want me to elaborate on anything, please message me on Discord, Mastodon, X, or email me. I’ll be happy to go into more detail one-on-one or to create more posts.

noaibadge

#C #devlog #gamedev #programming