Hello I am learning C and I want to make games in C with SDL. However I couldn't find any good resource for learning SDL in C except a handful of youtube tutorials. Any advice on how to use SDL with C?
SDL Game Programming in C
Really? All these are on the first page of google results for "sdl tutorial"
http://lazyfoo.net/SDL_tutorials/
http://lazyfoo.net/tutorials/SDL/index.php
https://wiki.libsdl.org/Tutorials
http://www.willusher.io/pages/sdl2/
http://aaroncox.net/tutorials/2dtutorials/index.html
http://gamedevgeek.com/tutorials/getting-started-with-sdl/
etc....
But in any case it's not difficult to translate c++ tutorials to plain C.
It requires effort, mostly because you loose all the nice things of C++ (like classes or standard containers...).
I did the experiment though, I did not complete a full game but I can put my code on github if you wish to read it.
SDL is a C API so any SDL tutorial you find is going to be valid, at least so far as the SDL elements are concerned.
Maybe you need to improve your C a bit more first...
SDL is a C API so any SDL tutorial you find is going to be valid, at least so far as the SDL elements are concerned.
Maybe you need to improve your C a bit more first...
Yes, I am fairly new to C. I am trying to improve but my main goal is to make games so I just want to find places to learn when the time comes
I know what you mean. There is a c/SDL game programming tutorial on youtube.
But in any case it's not difficult to translate c++ tutorials to plain C.
It requires effort, mostly because you loose all the nice things of C++ (like classes or standard containers...).
I did the experiment though, I did not complete a full game but I can put my code on github if you wish to read it.
Yeah I am trying to translate some tutorials but I am not advanced in c or c++ so its hard. I'd love to read your code.
You may want to check out the FLARE engine. This is how I started with SDL a few years back. Not a tutorial per se, but it may help you understand some concepts or how you do certain things. I think it's in C++ but the concept is the same.
I will check it out thanks
Really? All these are on the first page of google results for "sdl tutorial"
http://lazyfoo.net/SDL_tutorials/
http://lazyfoo.net/tutorials/SDL/index.php
https://wiki.libsdl.org/Tutorials
http://www.willusher.io/pages/sdl2/
http://aaroncox.net/tutorials/2dtutorials/index.html
http://gamedevgeek.com/tutorials/getting-started-with-sdl/
etc....
They are either not in C or outdated
They are either not in C or outdated
The "not in C" part you'll have to cope with because of your choice to use C rather than C++.
The system by itself is C-based and all that knowledge can be directly used. Tutorials that use C++ stuff should be easily adjusted assuming you actually know C. Note that if you don't know how to program, picking a graphical game system like SDL is not the ideal place to learn the basics. If you don't already know how to program in the language you should start simple, with 'guess the number', 'tic tac toe', and other simple games instead of complex graphical games.
That out of the way, what specifically do you want to learn about SDL that is not addressed in the links or contents of their wiki (https://wiki.libsdl.org/Tutorials) or documentation?
They are either not in C or outdatedThe "not in C" part you'll have to cope with because of your choice to use C rather than C++.
The system by itself is C-based and all that knowledge can be directly used. Tutorials that use C++ stuff should be easily adjusted assuming you actually know C. Note that if you don't know how to program, picking a graphical game system like SDL is not the ideal place to learn the basics. If you don't already know how to program in the language you should start simple, with 'guess the number', 'tic tac toe', and other simple games instead of complex graphical games.
That out of the way, what specifically do you want to learn about SDL that is not addressed in the links or contents of their wiki (https://wiki.libsdl.org/Tutorials) or documentation?
I know C, I am not a pro but I know the basics and I made some basic console games like pong and snake. Its just that every tutorial on the internet is using c++. Even the ones at https://wiki.libsdl.org/Tutorials . Sure I can try to transfer it to c++, but thats kind of a pain and I dont think I am that advanced yet. I was hoping to find a tutorial like lazyfoo but in C to learn the basics of how to make a game with SDL.
The way you use SDL does not differ from language to language. If you understand what's going on in a C++ tutorial, you can (usually trivially) write the same program in C (as far as SDL goes). Sure it'd be nice if you could find tutorials that are exactly what you need, but most of the time this won't be the case; you'll always have to change things.
Its just that every tutorial on the internet is using c++. Even the ones at https://wiki.libsdl.org/Tutorials.
Hint, hint...
Its just that every tutorial on the internet is using c++. Even the ones at https://wiki.libsdl.org/Tutorials.
Hint, hint...
:D
They are either not in C or outdatedThe "not in C" part you'll have to cope with because of your choice to use C rather than C++.
The system by itself is C-based and all that knowledge can be directly used. Tutorials that use C++ stuff should be easily adjusted assuming you actually know C. Note that if you don't know how to program, picking a graphical game system like SDL is not the ideal place to learn the basics. If you don't already know how to program in the language you should start simple, with 'guess the number', 'tic tac toe', and other simple games instead of complex graphical games.
That out of the way, what specifically do you want to learn about SDL that is not addressed in the links or contents of their wiki (https://wiki.libsdl.org/Tutorials) or documentation?
The way you use SDL does not differ from language to language. If you understand what's going on in a C++ tutorial, you can (usually trivially) write the same program in C (as far as SDL goes). Sure it'd be nice if you could find tutorials that are exactly what you need, but most of the time this won't be the case; you'll always have to change things.
One doesn't have pointers as a primary feature, the other does. Hell, both a programmer and a non-programmer can tell you that the syntax in even the classic "Hello World" example does not look the same. I like to use the example that saying "C/C++" in general is like saying "this tutorial is written in Spanish/Italian" while being written in just Spanish. Now imagine people just thought it was "your problem" that you only spoke Italian, really?
This debate has been bought up before and on multiple occasions otherwise. It's not much of a discussion since it's fairly obvious, the general consensus is that the two are - surprise - different and should be respected as such. So just because you can learn Portuguese if you know Spanish and vice-versa, doesn't mean you should have to, let alone want to.
See: A Raging C/C++ Debate on /r/Programming
Now to help out the OP, hint, go back in time. It's possible on the web, read and compile a bunch of those tutorials and go from there.
One doesn't have pointers as a primary feature, the other does. Hell, both a programmer and a non-programmer can tell you that the syntax in even the classic "Hello World" example does not look the same. I like to use the example that saying "C/C++" in general is like saying "this tutorial is written in Spanish/Italian" while being written in just Spanish. Now imagine people just thought it was "your problem" that you only spoke Italian, really?
This is all well and good, but whether you like it or not SDL is still a C API. That means that it uses C datatypes (yes, even pointers) and C idioms, even in C++ and even if the rest of the C++ code is otherwise well-formed and idiomatic.
For sure a C++ SDL tutorial isn't going to give you code that you can just copy/paste to a C program, but I think we can all agree that copy/paste programming isn't learning. What it will give you is useful information like "this the API call I use to create a device" and "here are the flags I pass in to get the behaviour I need".
This book, which is excellent by the way, uses plain C, SDL and linux https://www.amazon.com/Programming-Linux-Games-Loki-Software/dp/1886411492
It's only drawback is that it explains sdl 1.2, but it shouldn't be difficult, as an excersice, to port it to sdl2
You can see youtube channels or C programming web sites.Good luck with.
Why did you decide to use C instead of C++?
(just want to know)
Why did you decide to use C instead of C++?
(just want to know)
Because I know C :D But I started learning c++ too.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.