Gamecrash: writing games using “C without pointers”!

The concept for the Gamecrash course was clear from the first moment: really focused course to get people to actually learn to develop games in one week. Focus on fundamentals, such that people learn the core skills. But be sure to create an actual game – this is not a theory-only course, we need results! Of course you can’t write the latest advanced 3D consoles first-person-shooter with amazing AI in a week. But the core game-development skills and the skills to write 2D action/puzzle games can definitely be taught in one week, and they can be the best foundation on which to build future knowledge for more complex types of games (3D, etc…).

It’s clear that if you want to create a one-week course that really gets students to the “next level” you are going to have to be very precise on what things you want to cover and which ones you want to leave out. You have to make sure the whole contents are a solid structure that holds itself together well, that can be used without any extra content to actually develop games, and which can later become a great base upon which to build a full professional career if students want to pursue that road.

A key question here was the base language and technology to use. There were several options: most professional games are done using C/C++, but more and more frameworks and libraries allow you to write games in Javascript or C#. Also, languages such as Python are easier to pick up than C/C++, maybe we should go that way?

Also, students will come from different backgrounds. All of them will have software development experience, but not games development experience. That means that some of them will be fluent in Java, others in Ruby or Javascript, and some others even in PHP. We have to make two things very sure: (1) that it is possible to attain the goals we have set out to cover, and (2) that we actually choose the contents and design the course such that we actually get everyone to be developing games by Friday.

First, it was easy to dismiss options such as using Python with some games/graphics library, or similar high-level languages. They are a great environment, but it’s difficult to actually build a full game of production quality using those. Many commercial games embed Python or similar for the scripting of the game content, for which it’s great, but the games itself is usually written in C/C++.

Second, Javascript would be one language to think of, but developing a game for the browser has it’s own challenges: it’s still a games-platform struggling to become established! Also, we are after creating the type of games that people actually play (and pay for!) every day on Windows, Mac, mobile, consoles, etc…

Third option, frameworks such as Unity and the like allow you to develop cross-platform games in not-hard-to-pick-up languages such as C# or Javascript. But I didn’t want to center the course around a specific framework, technology or library: we want students to learn the fundamentals, to take their game-development career to the platform they are interested on, to have freedom to develop their own games in the way they like – and this requires another approach.

Finally, everything seemed to point towards using C/C++ with OpenGL, which are actually used for most games development out there, and with which, apart from games, you can build a professional career if you feel so inclined. But this road had its own difficulties: programming in C and C++ is notoriously hard. Learning classes, inheritance, templates, etc… for C++ development is just not doable in one week. On the other hand, even if you go for C, which is simpler but equally powerful, there are difficulties. Most developers have had contact with C, and have been bitten by its quirks, mainly, the dreaded pointers. For those of us coming from assembly language development, pointers come naturally, but for a Java developer joining the course, covering pointers would be hard. And not only that – I don’t want to waste a full dear day out of just five that the course consists on!

And so, I started considering how I could simplify things, and I came up with an intersting idea: is it maybe possible to write a complex program such a game in C, using only a subset of its features, and mainly, avoiding the use of the dreaded pointers?

It seemed a bit shocking, I don’t think I’ve ever seen or written C/C++ without using pointers, but it still seemed like it could work. This meant using just variables, functions, arrays, and structs (for non-C-ers, they are something like records/dictionaries where you can pack several related values in a new type for your variables). Nearly all developers will be familiar with these concepts, are they are the basic building blocks of programming in any language.

So I started writing some sample code using this approach, and it turned out it is amazing! Really simple to write and to comprehend, using simple arrays and variable types, but still able to express everything games development needs.

The advantages are twofold:

First, that it’s really easy to pick up. I expect to dedicate a grand total of about two hours to teaching “C without pointers” – and thus have all the rest of the time to actually create and develop games.

And second, really importantly, what you learn is pure, actual games development in the way that commercial games are done on nearly all platforms! It’s not a toy language or technology, C and OpenGL are the base of everything, and it turns out our best didactical choice is also a great choice career-wise. After the course, you can add more C and C++ knowlege, which is not that difficult to do on your own, and you are progressively becoming an experienced games developer that can work in creating commercial games, be it “indie” or in the games industry.

After this awesome didactically-motivated discovery, I’m happy I’ve found “C without pointers”, a great tool that I’ll be using for many years to come in Gamecrash courses and similar initiatives. And I look forward to the feedback from students when they start using it!