c tutorials | Learn C Games Programming Blog (2024)

Tutorials

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

c tutorials | Learn C Games Programming Blog (1)

  • Atoms aka Chain Reaction. A simple console game to introduce you to C programming.
  • Atoms. Tutorial one. Displaying the board, accepting player input.
  • Atoms Tutorial two. Doing computer moves
  • Atoms Tutorials three. Finishing off.

Onslaught (aka Slay for Linux) Tutorials

  • Tutorial one. How to implement Slay for Linux. Aka Onslaught.
  • Tutorial two. How to draw Map hexagons. Plus code to draw a bunch of hexagons on Linux.
  • Tutorial Three. Devise and code up a map generator.
  • Tutorial Four, Adding forts, trees and wild hexes.

c tutorials | Learn C Games Programming Blog (2)

(Visited 10,781 times, 1 visits today)

c tutorials | Learn C Games Programming Blog (2024)

FAQs

Where can I learn C language? ›

In summary, here are 10 of our most popular c programming courses
  • Introductory C Programming: Duke University.
  • C Programming for Everybody: University of Michigan.
  • Coding for Everyone: C and C++: University of California, Santa Cruz.
  • C Programming with Linux: Dartmouth College.

Is C good for game programming? ›

Both C and C++ are commonly used for game development, but C++ is generally considered to be the better choice.

How to learn C language from scratch? ›

The best way to learn C programming is to start by reading C programming books or tutorials online. Go through beginner tutorials to grasp the basics like data types, loops, functions, and arrays. Make sure to code alongside the tutorials and get hands-on practice with simple programs.

Is C language still in demand? ›

C is still used extensively in fields where performance matters more than ease of development. While C may be harder to learn than Python or JavaScript, it can be worth the effort to gain skills for building software for constrained devices. The efficiency of C provides unique benefits in the right application domain.

Is C or C++ easier to learn? ›

C does not have so many rules and restrictins as C++ it is not so difficult to learn it because it is more direct to code. On other hand the C++ is more powefull to use. The conclusion is C is easier to learn, C++ is easier to use.

Is Java or C better for games? ›

In some cases, the decision between C++ and Java is clear. Native Android applications should typically use Java unless the app is a game. Most game developers should opt for C++ or another language for the smoothest possible real-time animation; Java's memory management often causes lag during gameplay.

Which C language is best for games? ›

C++: C++ is one of the most popular languages for game development, especially for high-performance and AAA titles. It offers low-level memory control, which is crucial for optimizing performance. Many game engines like Unreal Engine and Unity (in parts) use C++.

Which is better for games C++ or C#? ›

C++ for Game Development:

When it comes to performance, C++ is one step ahead of C#. In games for faster compilation of code, developers love to use C++. A very famous engine is Unreal engine support and also written in C++.

Why is learning C hard? ›

C is a tiny language to learn, but it can be hard to use due to its pervasive use of pointers. Basically, C requires that you can visualize the memory layout of your program and its components.

Can I learn C language for free? ›

Welcome to the learn-c.org free interactive C tutorial. Whether you are an experienced programmer or not, this website is intended for everyone who wishes to learn the C programming language. There is no need to download anything - Just click on the chapter you wish to begin from, and follow the instructions.

Is C an easy language to learn? ›

C is a relatively easy language to learn, making it a good choice for beginners. Despite its popularity, there is no guarantee that C will be around forever. Languages come and go, and new technologies always have the potential to replace existing ones. However, C will probably remain a popular language for many years.

What is a good way to learn C? ›

Tips and Strategies for Learning C
  • Learn the variable types. Understand the type of data that you are working with, such as whether it's an integer or a character. ...
  • Learn the operators. ...
  • Use standard libraries. ...
  • Understand error handling. ...
  • Use a debugger. ...
  • Look at sample code.

References

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Amb. Frankie Simonis

Last Updated:

Views: 6177

Rating: 4.6 / 5 (76 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Amb. Frankie Simonis

Birthday: 1998-02-19

Address: 64841 Delmar Isle, North Wiley, OR 74073

Phone: +17844167847676

Job: Forward IT Agent

Hobby: LARPing, Kitesurfing, Sewing, Digital arts, Sand art, Gardening, Dance

Introduction: My name is Amb. Frankie Simonis, I am a hilarious, enchanting, energetic, cooperative, innocent, cute, joyous person who loves writing and wants to share my knowledge and understanding with you.