As COD3 said, handmade hero is mostly C (ANSI C if I'm correct not C99 or later).
You can find differences between ...fferent version of C on wikipedia.
No concept in handmade hero requires C++, meaning everything you will learn can be applied in C. The stream is more about teaching how to program a game that how to program in C. I recommend to watch the
week 0: Intro to C videos to know if handmade hero is for you.
A few things in handmade hero will not work in pure C but can be converted to C with little changes:
- structure definition:
| // C++ code:
struct StructName {
int x;
...
};
// C code:
typedef struct {
int x;
...
} StructName;
|
- Comments: in C you can only use /* and */ to write comment. In C++ you can used // to do a one line comment.
- Operator overloading: C++ allows you to redefine the behaviour of (most) operators. E.g. : you can change what + or - means between two types. Casey only use that for (math) vectors. It's not possible to do it in C, but it can be replaced by a function call.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 | // C++ code:
inline v2
operator+(v2 A, v2 B)
{
v2 Result;
Result.x = A.x + B.x;
Result.y = A.y + B.y;
return(Result);
}
v2 a = { 1.0f, 4.0f };
v2 b = { 2.0f, 3.0f };
v2 c = a + b;
// C code:
inline v2
v2Add(v2 A, v2 B)
{
v2 Result;
Result.x = A.x + B.x;
Result.y = A.y + B.y;
return(Result);
}
v2 a = { 1.0f, 4.0f };
v2 b = { 2.0f, 3.0f };
v2 c = v2Add( a, b );
|
- Function overloading: in C++ you can have function with the same name but different arguments types and/or order (the function signature: name of the function + arguments type and order. The return type is not part of the signature).
| // C++ code:
float add( float a, float b ) { ... }
int add( int a, int b ) { ... }
// C code:
float addFloat( float a, float b ) { ... }
int addInt( int a, int b ) { ... }
|
- [Not sure]Function inlining might not work in C.