These are various game related tutorials in C, C++ and C#.


C Programming Tutorials

(Originally published on the now defunct on cplus.About.com)

This is a very rough guide to a learning C syllabus. It’s tailored to be practical and details steps, many of which correspond to C tutorials. I’ve also linked to the relevant tutorials and this provides a guide.  If you are going to follow this you should work your way through the tutorials in order.  As more tutorials are added, I’ll add the links in to the relevant bits which are shown in bold as place holders.

  • A quick overview. A look at computers, machine code, assembly language, editing, compilers, compiling and debugging.
  • How to install VS Code and Clang on Ubuntu and Raspberry Pi. Note you can also install VS Code on Windows. Many examples use the ideoone.com website. This is an online C compiler so you can use that to run code instead of compiling it.
  • Introduction to Hello World. The shortest easiest program of them all. Explains the different parts of a C program.
  • Introduction to variables. Explains how to hold data in memory. Mostly numbers but can also include text strings. It also explains how to declare variables. The different data types (int, float, char).
  • A look at enum variables. These are int variables where each value 0,1, etc represents something say like a colour.
  • A look at array variables. This is a collection of variables of the same type that are accessed by an index.
  • A look at struct variables. How to group different types of variables together. Variables can be different types but can also include arrays. You can have struct which includes arrays of structs as well as other types up to the limits of the compiler.
  • A look at functions. Functions are blocks of code that can be called. You can pass values in and get values back. They are an important part of C.
  • Simple control flow. (Not due till 23rd Dec) Use {} to build blocks of code and if or switch statements to control what happens.
  • Looping in C. C offers four ways to loops in this order of importance: For loops, while loops, do-while loops and the Goto statement,
  • All about operators in C. You can manipulate data in C using a variety of operators and control program flow.

At this point you have the simple fundamentals of C programming but still have to learn pointers, text strings and of course SDL.

  • A look at pointers. This is actually a simple concept once you get it. A pointer variable just holds the address of something. The complexity is understanding that the compiler needs to know how big that something is. People who have done assembly language programming usually have an easier time of it.
  • Pointers and c-strings. A string in C is actually a pointer to a block of characters terminated by a 0.  There are a few gotchas though.
  • Pointers and linked lists. Other programming languages tend to have a bunch of advanced data structures like Queues and stacks. In C you often have to roll your own using pointers. A linked list is a structure made using pointers and usually structs.
  • Working with strings. Although I looked at them in the pointers and c-strings tutorial, this is a more in-depth look at working with them.
  • Allocating memory dynamically. Use of malloc/free.
  • What are function pointers? As well as pointers to data, you can have pointers to code, in particular pointers to functions. But the syntax is probably the most horrible part of C.
  • What are C compiler directives? Like #define and #include as well as others. Learn all about them.
  • How do I structure my C program? While you can have your program in one file, it often makes sense and shorter compile times to split it into multiple files. This needs careful attention as some bits can be included while others need to be declared as extern.

That’s mostly the C bit done but now comes the SDL library code. This is a media library that lets you use graphics and audio files in your program as well as exotic devices like joysticks and game pads. Most importantly it lets you write programs that can run at 60 frames per second or higher which is perfect for games.

  • How do I install SDL on Linux? It’s different between Windows and other platforms.
  • How to install SDL2 in Visual Studio. This of course is on Windows.
  • Getting started with SDL. Here’s a typical Hello World but in graphics.  It explains some simple concepts like double buffering which is how your graphics are kept flicker free and smooth looking.
  • All about blitting.  So you have a nice set of graphics? How do you get them in to your program and “blit” them quickly onto the screen.
  • How I play sound with SDL? How do you load audio files in and what are the different formats it can play?
  • How do I read keys or handle mouse moves in SDL? It’s not that difficult.

The last bit is about games development.

How do I structure a game in C with SDL? This explains the concept of a game loop and making things to do to make a game that runs smoothly at 60 frames per second.

Simple Game Tutorials


Atoms 3 screenshot

Onslaught (aka Slay for Linux)  Tutorials

Onslaught map

(Visited 8,677 times, 9 visits today)