Hey, thanks for uploading this. I’ve been learning C for about a week now and seeing something like this has really motivated me to keep trying harder. Thanks a bunch.
Was actually just curious about how to program games in C, but your explanations (and your small mistakes lol) made your video really interesting and fun to watch. Keep going, I think you found a new subscriber 😉
hey. can you make more tutorials,? just still use C. mario, pacman, pong, tetris, which have some basic concepts of game development. I started game dev in unity but it feels like I am missing something.Then I tried this tutorial ,which opens a lot about how a game really works. Hoping for more of your tutoirlas. (from the 2015 kids)
The first valid array index is 0, you should be writing i >= 0. Also, free(NULL) is a safe no-op, you are only adding unneeded complexity by checking for NULL before freeing.
The first valid array index is 0, you should be writing i >= 0. Also, free(NULL) is a safe no-op, you are only adding unneeded complexity by checking for NULL before freeing.
idTech 1, 2 and 3 engine were written in C and games that are using it are Doom 1/2, Quake 2/3. You can develop games in pure C but you will need good skills. You can just use structs and pointers to mimic Class in OOP. structs can hold data types, other structs(which is basically advanced data type) and pointers to functions. You can make your code really nice. For example:
What’s wrong with just using ‘Bullet bullets[]’? You’d remove a layer of complexity and still be able to use it as an array: bullets[n].x or (bullets + n)->x.
Then you could add a flag into the structure like “int visible:1;” and default the whole array to 0, thus when you want to “add” a new bullet, you set its “visible” member to 1. When the bullet is removed, you set it to 0.
As an array of structures, it would provide a single pointer to the beginning of a chunk of memory representing multiple contiguous bullet structures, and each one is re-usable without having to dynamically allocate new space for them, nor deal with an extra layer of indirection.
Plus, it’s better to avoid dynamic memory allocation and take advantage of the stack rather than allocate everything on the heap.
Braden Best No I think it’s easier to use a constant to fill up an array of the maximum amount of bullets this makes it easier for someone new starting out with C…but nonetheless I see what your saying he basically did a much easier way than…what you just said
I also felt a simple linked list would work well, but that may have been too much for this simple tutorial. A nice index variable, something that pointed to the last available location in the array would have saved going through a loop each time. Just add to that spot then increment the index (or decrement it if a bullet is removed). Then the only loop needed would be at the end of the program and even that would only need to go up to the index and no farther.
Hey i’m starting in programming, chose to begin with C language which i find really interesting to me.
As for my 1st library to work with i would like to master SDL one. But should i try to learn SDL then move to SDL2 or SDL2 from the beginning instead ?
Awesome video make more videos like this
Hey, thanks for uploading this. I’ve been learning C for about a week now and seeing something like this has really motivated me to keep trying harder. Thanks a bunch.
Same here.
You make game programming seem more accessible. Thank you for this video.
This is really useful man, keep going with this series if you have time I for one really appreciate it.
Was actually just curious about how to program games in C, but your explanations (and your small mistakes lol) made your video really interesting and fun to watch. Keep going, I think you found a new subscriber 😉
hey. can you make more tutorials,? just still use C. mario, pacman, pong, tetris, which have some basic concepts of game development. I started game dev in unity but it feels like I am missing something.Then I tried this tutorial ,which opens a lot about how a game really works. Hoping for more of your tutoirlas. (from the 2015 kids)
Dude, I was like: GREATER THAN EQUAL TO!!!! Great video. Thanks so much for these they are super inspiring!!!
Honestly I love C for it’s simplicity.
‘simplicity’
The first valid array index is 0, you should be writing i >= 0. Also, free(NULL) is a safe no-op, you are only adding unneeded complexity by checking for NULL before freeing.
The first valid array index is 0, you should be writing i >= 0. Also, free(NULL) is a safe no-op, you are only adding unneeded complexity by checking for NULL before freeing.
hi great video; could you create a memory blocks game in c language for your next video; thanks in advance
Nice tutorial, needs more (and smaller) functions.
Cool Stuff. @VertoStudio3D can u elaborate more on how u refresh and update the screen?
Hi can you tell me or make a video on How to perform an action using arrow keys in C?(not in C++ but in C)
idTech 1, 2 and 3 engine were written in C and games that are using it are Doom 1/2, Quake 2/3. You can develop games in pure C but you will need good skills. You can just use structs and pointers to mimic Class in OOP. structs can hold data types, other structs(which is basically advanced data type) and pointers to functions. You can make your code really nice. For example:
typedef struct Texture {
void (*LoadTexture)(struct Texture*);
void (*RenderTexture)(struct Texture*);
void (*Destructor)(struct Texture*);
const chat *path;
SDL_Texture *texture;
} Texture;
As you can see, Texture “class” holds everything you need. Later on you just place function pointers.
Texture background = { &LoadTexture, &RenderTexture, &DestroyTexture, “data/background.png” };
And then you can use your “object”.
background.LoadTexture(&background);
background.RenderTexture(&background);
background.Destructor(&background);
Thats it, you don’t need classes.
Josh Torres Allegro is pretty good too…
Yep. I’d even wager that making games in C is even easier nowadays, if you need complex math for Vectors you can just the glm library.
I just found this guy and know nothing of C but I find this very interesting thanks man and good video!
What’s wrong with just using ‘Bullet bullets[]’? You’d remove a layer of complexity and still be able to use it as an array: bullets[n].x or (bullets + n)->x.
Then you could add a flag into the structure like “int visible:1;” and default the whole array to 0, thus when you want to “add” a new bullet, you set its “visible” member to 1. When the bullet is removed, you set it to 0.
As an array of structures, it would provide a single pointer to the beginning of a chunk of memory representing multiple contiguous bullet structures, and each one is re-usable without having to dynamically allocate new space for them, nor deal with an extra layer of indirection.
Plus, it’s better to avoid dynamic memory allocation and take advantage of the stack rather than allocate everything on the heap.
Braden Best No I think it’s easier to use a constant to fill up an array of the maximum amount of bullets this makes it easier for someone new starting out with C…but nonetheless I see what your saying he basically did a much easier way than…what you just said
I also felt a simple linked list would work well, but that may have been too much for this simple tutorial. A nice index variable, something that pointed to the last available location in the array would have saved going through a loop each time. Just add to that spot then increment the index (or decrement it if a bullet is removed). Then the only loop needed would be at the end of the program and even that would only need to go up to the index and no farther.
You were right the first time… that should be “if found >= 0”, since the first bullet could be the 0th bullet in the array. I think.
Hey i’m starting in programming, chose to begin with C language which i find really interesting to me.
As for my 1st library to work with i would like to master SDL one. But should i try to learn SDL then move to SDL2 or SDL2 from the beginning instead ?