C++ is a powerful programming language, but its complexity can be daunting. Even writing a simple “Hello, World!” program can feel cumbersome. When I was challenged to create a game using C++, I was apprehensive. However, considering that many major applications like Google Chrome, Photoshop, and numerous video games such as Kingdom Hearts and Wind Waker are built with C++, I decided to take on the challenge.
To begin, I needed a framework. Initially, I chose Raylib, but as you’ll see, that didn’t work out. I downloaded the Windows installer from raylib.com and set it up using Notepad++. My first task was to draw a window, which I managed to do by following online tutorials, despite frequently forgetting semicolons. I then moved on to drawing and animating a ball to get familiar with the syntax.
After creating a basic design in Illustrator, I attempted to display the image on the screen. Surprisingly, this was straightforward. However, I soon realized I was coding in C, not C++. While C++ builds on C, they are distinct languages, and I felt frustrated for having spent a day learning the wrong one.
Feeling disheartened, I decided to focus on the game’s concept. I used Adobe Illustrator to design a mock-up. Inspired by a speedrun I had recently watched, I envisioned a game where players must sharpen five pencils as quickly as possible by pressing the correct arrow keys. With this idea, I created a design I was satisfied with.
Reluctant to return to C++, I decided to challenge myself further by using SDL2, a popular framework used by companies like Valve. After downloading SDL2, I relied on online tutorials and videos to set it up with Sublime Text. Drawing a window took about eight hours, but I learned a lot and gained confidence in my ability to create the game.
With the gameplay concept being relatively simple, I focused on creating the artwork. I programmed the game to respond to keyboard inputs, affecting gameplay. Initially, I planned for pencils to move down in rows, but I opted for a single large pencil image instead. I also designed a menu and titled the game “Pencil Sharpening Championship.”
To enhance the visuals, I layered the pencils to appear behind the sharpener and programmed the correct arrow to display when needed. Implementing the text system was surprisingly easy. I borrowed code to make the text wiggle and formatted the timer correctly. Randomizing the arrow prompts added an element of challenge.
With the game nearly complete, I added a menu system, fixed bugs, and incorporated sound and music. I mixed sounds in Audacity and selected a song from OpenGameArt. Although I couldn’t include features like saving high scores or pencil shavings, I was pleased with the final product.
This project was one of the most challenging programming tasks I’ve undertaken, especially given my artistic background. If you’re interested in testing your speedrunning skills, the game is available on itch.io. I’m eager to see your fastest times! While I won’t be releasing the source code, I welcome suggestions on which programming language to learn next.
Start by writing a simple “Hello, World!” program in C++. This will help you get comfortable with the syntax and structure of the language. Pay attention to common pitfalls like missing semicolons, which are crucial in C++.
Research and compare different frameworks like Raylib and SDL2. Create a pros and cons list for each, focusing on ease of use, community support, and features. This will help you understand why SDL2 was chosen for the game development project.
Design your own simple game concept using a tool like Adobe Illustrator. Think about the gameplay mechanics and how you would implement them using C++ and SDL2. Share your concept with peers for feedback and suggestions.
Follow online tutorials to set up SDL2 in your preferred IDE. Practice drawing a window and displaying a simple image. This hands-on activity will reinforce your understanding of setting up a development environment and using SDL2.
Develop a basic version of the “Pencil Sharpening Championship” game. Focus on implementing keyboard input and simple animations. This activity will help you apply your C++ and SDL2 knowledge in a practical setting, enhancing your programming skills.
Here’s a sanitized version of the transcript:
—
C++ is powerful, but with great power comes great complications. For example, it feels like writing a basic “Hello, World!” program takes as long as reading one. So when you all challenged me to make a game in C++, I was a little nervous. Now, granted, everything from Google Chrome to Photoshop, not to mention most video games, are made using C++. Games like Kingdom Hearts, Wind Waker, and Nintendogs all have that in common. So that’s what I’m going to do. I mean, it can’t be that hard, right?
But we can’t get started unless we have a framework to work with. At first, I decided to use Raylib, which you’ll notice isn’t in the title of this video, and you’ll see why shortly. I went to raylib.com and downloaded the Windows installer. Yes, I know I’m on Windows; forgive me. The installation was pretty easy, and everything was set up with Notepad++.
As always with these projects, I like to get started by just trying to figure out how to draw a window. By following the tutorials on the website, I found it was actually pretty easy to do—except for me constantly forgetting semicolons. After this, I decided to draw a ball, and then I made it move. At this point, I had no idea what I was doing; I just wanted to get familiar with the syntax and how everything worked.
I quickly hopped over to Illustrator and made a design, and then it was time for the ultimate challenge: drawing the image to the screen. Surprisingly, it was easy! Everything was going perfectly—almost too perfectly—because it was around this time that I realized I wasn’t coding in C++; I was actually coding in C.
For some of you out there, you might be thinking, “Well, those are very similar languages,” and yes, C++ is just built on top of C, but let me tell you, they’re incredibly different. All the tutorials I was following were in C, and I felt pretty frustrated because I spent a whole day doing absolutely nothing and didn’t really learn anything because it wasn’t even the language I intended to use.
So, disheartened, I decided to take a break and focus on something I always neglect at first: the concept of this game. I jumped into my favorite game development tool—Adobe Illustrator—to design a mock-up for what I think this game could look like. Recently, I had rewatched a speedrun and thought about how that could be a really unique mechanic for a video game.
Here’s my idea: you have to sharpen five pencils as fast as possible by mashing the correct arrow keys—hopefully not destroying your keyboard in the process. With my idea in hand, I started to mock up the game. I played around with some styles and colors, and ultimately, I ended up with a design I liked.
At this point, I was really procrastinating jumping back into C++. I was disheartened by my Raylib experience and wasn’t sure what to do next. Instead of making it easier, I decided to crank it up and make it harder: let’s make it SDL2. SDL is a very popular framework, and many companies, such as Valve, have used it to make games.
I downloaded the latest version of SDL2 and had no idea what to do, but fortunately, the internet had the answers. I read some online tutorials and watched some videos, and after all that, I was able to set up SDL2 with Sublime Text. I could even draw a window, and the best part is it only took about eight hours to do. Setting all theatrics aside, I actually learned a lot from those videos and tutorials, and I felt a little more confident that I could create this game.
Since I knew the gameplay was relatively simple, I focused on drawing all the artwork I would be using in the game. I even made it so if you pressed the keyboard, it would affect gameplay. I considered how the pencils would move down; originally, I thought there would be rows of pencils above that would tween and move into position after you sharpened a whole pencil. But I quickly realized that wasn’t going to work out, so instead, I decided to just use a big image of a pencil.
At this point, I thought I should work on artwork for a menu and a title for the game. After a moment of thought, I decided to call it “Pencil Sharpening Championship.” That just rolls off the tongue! I was starting to see the light at the end of the tunnel because, honestly, before this, I had no idea if I would be able to figure this out.
Next, I did some clever layering so that the pencils looked like they were behind the sharpener. I also made it so the proper arrow appears when you’re supposed to press it. Then, I had to figure out the text system, which was actually easy for once. I went online and borrowed some code from a friend so that the text could wiggle. I added the text for the timer and formatted it correctly so it looked like a timer. I also randomized what arrows you should be pressing to add some gameplay.
At this point, the game was basically done. I had a menu system and just had to fix a few bugs and add some sound and music. I looked through my sound library, mixed those in Audacity, and then added a song I found on OpenGameArt. Voila! We had a game!
Of course, I wasn’t able to add everything I wanted, like saving your high score or adding little shavings that would come out of the sharpener, but all in all, I’m really happy with how the game turned out. This challenge was hard—really hard. It’s probably one of the hardest programming challenges I’ve ever done, and granted, I come from an artistic background, but it’s fine.
If you’d like to sharpen your speedrunning skills, you can check out the game over on itch.io. I’m curious to see what your fastest times are! Also, I’m not planning on releasing the source code, as I don’t want anyone learning from my absolute spaghetti code. My last question for all of you is: what language should I learn next?
—
This version removes informal language and maintains a more professional tone while preserving the original message.
C++ – A high-level programming language known for its performance and efficiency, often used in system/software development and game programming. – Many game engines are built using C++ due to its ability to handle complex computations efficiently.
SDL2 – Simple DirectMedia Layer version 2, a cross-platform software development library used to provide low-level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. – SDL2 is widely used in game development for handling multimedia tasks across different platforms.
Framework – A set of tools and libraries that provide a foundation for developing software applications, offering predefined classes and functions to manage hardware, software, and graphical user interface elements. – The Unity framework simplifies the process of game development by providing a robust set of tools and resources.
Programming – The process of designing and building an executable computer program to accomplish a specific computing task. – Programming in Python can be a great way to quickly prototype game mechanics before implementing them in a more performance-oriented language.
Game – An interactive software application designed for entertainment, education, or simulation, often involving a user interface and user input. – Developing a game requires a deep understanding of both programming and design principles to create an engaging experience.
Artwork – Visual elements such as graphics, textures, and animations used in a game or software application to enhance its aesthetic appeal. – The artwork in the game was praised for its unique style and attention to detail, contributing significantly to the overall user experience.
Keyboard – An input device used to interact with a computer or software application, often playing a crucial role in user interface design and user experience. – Customizing keyboard controls can greatly improve the accessibility and playability of a game.
Tutorials – Educational resources designed to teach users how to use software or programming languages, often including step-by-step instructions and examples. – Online tutorials can be invaluable for learning new programming languages or mastering complex software tools.
Design – The process of conceptualizing and planning the structure and aesthetics of a software application or game, focusing on user experience and functionality. – Good design is crucial in game development to ensure that the gameplay is intuitive and engaging for players.
Gameplay – The interactive elements and mechanics of a game that define the player’s experience and engagement. – The gameplay of the new release was praised for its innovative mechanics and challenging puzzles.