itch.io is community of indie game creators and players

Devlogs

How I made this game completely from scratch

Box Pushing Game
A browser game made in HTML5

This was a large project.

Probably the biggest I have taken on at the time.

I started this project barely knowing C++ or how game development even worked. I ended with thousands of lines of code, my own game engine, and lots of new knowledge on programming. And a half-baked game.

Box Pushing Game

I started this project with the intent of developing a game engine and a game entirely from scratch. I wasn't sure what kind of game I could make, so I put together the most simple premise I could: a simple game about pushing boxes. What should I name it? There were so many good names out there, so obviously I picked the most original one I could come up with. Box Pushing Game.

I pulled up a sheet of paper, and started doodling some ideas out for levels. I even came up with the character design in that short time.

Of course, first I needed to have an engine to even test that art out on. I didn't have that anywhere near done.

I had no idea how to make a 2D game engine. So I looked up "2D C++ Game tutorial" and kept finding mentions of this SDL2 library.

It was one of the best discoveries I made. SDL2, to me, is a great way to be able to build a game from scratch without having to deal with all the low level things like OS window creation, managing rendering, etc because it has all of those features built in.

I found this great site called https://lazyfoo.net/ and it made learning how to use SDL2 so much easier, and made me want to stay and actually finish this project.

1 week in and several tutorials later I had the basis for a functioning sprite renderer and was able to test out my art.

The first image attached is that version.

Getting anything going was a milestone for me, and it was amazing to see what I had imagined come to life on screen, even if it was some static art.

I also added Dear Imgui, and it made certain things a lot easier because I could create a few things during run time and paste that into my code.

Then, to be able to have some sort of physics in my engine, I chose Chipmunk2D, because it was fast enough and I knew the name from years ago. Physics was really really fun to work with, and it made my project start to feel real as a game engine.

Then, I decided I wanted a PSP version of the engine for some reason. Then was another week of learning, testing, and compiling until I had a version of it running on my PSP. I had to keep looking through forums from 2007/2008, and looking at documentation written for people who actually know what they are doing. Of course, I had no idea what I was doing but eventually I got something working.

I spent some time trying to maintain the two ports of the program from the same codebase, but I had two different build systems handling those things and any changes I made to the structure of the project had to be put into each build system I used.

Eventually I just threw the PSP version away and focused on Windows only.

It was about 1 month in and I had something "working" as far as gameplay went. You could walk around in a little room, the guy had animations, and you could push boxes around. It was functional at least. The second image is this version.

I finally opened up my art editor, and drew up some art for the level, for real this time. I tried to refine the sort of art style I had been using, it was really just my horrible handwriting in drawing form.

I got the art into my engine, figured out where to put collisions by drawing lines over my art with my mouse and a dear imgui UI I made, added the level-specific stuff, and tested it. It worked!

Of course, I still had the whole game to make. I added the gameplay in, and had to figure out how to even approach things like animations in a statically compiled language, where it was a pain to test anything, and most animating is really just writing out math equations and seeing what it looks like. I set up state machines, an Entity-Component system, and a scene system. I probably did a lot more then that, but forgot. It was a huge project. Finally though, I had a score counter, collision detection, and spawner all working in harmony to give you "gameplay".

The third image is the game at that point.

To easily code my levels, I used some components from a previous project and integrated Lua into the engine, allowing me to quickly script all the gameplay code I needed.

Then, I spent a week polishing it, added a menu, transitions, etc. and finally had something that a person could play.

2 months, off and on, and I was done.

I published it on itch.io, wrote a description, made a gameplay video, and watched the download count rise.

At least I thought I was done.

Part 2: The OpenGL renderer

For some reason I really like to make things difficult. Because making an engine from scratch in a programming language I barely knew wasn't enough. So I decided to switch to OpenGL3 for rendering. I was lured by the concept of shaders and framebuffer effects, and how much prettier my game would like if I used them. I found this great site called https://learnopengl.com/ , and it really helped me understand how 3D graphics worked. I kept having to dig through my high school algebra books and relearn a lot of the math behind how some things work. It was insanely hard, but I got something that worked. It was an exact copy of the SDL2 version, except it was cooler! Because 3D!

I was browsing through my Youtube feed and saw a neat looking video of a 2D game. It had lighting, and that lighting looked really pretty. I had no idea how that worked, so I looked around for ideas.

Turns out all lights are just regular 2D sprites, just multiplied on top of rest of the scene, and the scene is tinted black so the lights actually have something to light up. I made a light texture in gimp, put it into a sprite, and then rendered that sprite separately from the rest of the scene, and combined it with again with the main scene by multiplying the colors of the two until I got image 4. It was really pretty.

I also wrote up some framebuffer effects, and made the scene kind of wiggle and look blurry, and I got something that looked amazing.

I was happy with what I had, and uploaded it into itch.io.

3 months, and that was what I had.


It may not be the best game as far as gameplay goes, but it was one hell of a project to work on, and I enjoyed it.

I finished it December of 2020, and just recently decided to go through the codebase and clean it up a little and port it to Web, Linux, Android, and finally PSP. Stay tuned for that!

Download Box Pushing Game
Leave a comment