Writing 2D Games in C using SDL by Thomas Lively

preview_player
Показать описание
SDL, the Simple DirectMedia Layer, is the cross-platform game library used in everything from small indie games to Valve’s blockbuster triple-A games to other applications with rich media needs. This seminar will teach you how to use this powerful C library to write your own 2D games. We will talk about the structure of game code and cover the installation and initialization of the SDL library, the creation and management of the game window, how to draw images onto the window, and how to handle keyboard and mouse input. By the end of the seminar you will have created a small demo that you can later build on as much as you want.
Рекомендации по теме
Комментарии
Автор

There are nearly no competent sdl c teachers on youtube. This is the only sdl c tutorial i found which actually helped me build something useful and become familiar with the library and documentation. Thanks.

reconmaster
Автор

Most SDL demo video I find on the youtube is C++ in Windows, and thank you for making a demo in C and Linux.

hsinhunglin
Автор

5 years later, still useful. Thumbs up.

PatrioticGestalt
Автор

By far the best video I’ve watched so far on SDL with C. Quick, and easy.

qwerty
Автор

This has rendered great help and allowed me to surface above a lot of troubles, thank you. Deserves better applause at the end.

joshli
Автор

If you're on macOS and your window doesn't seem to be popping up (as it was not for me), it's because you need to poll for events. It seems that on the creation of the window there are a few events that are queued before the window appear event. So try something like this:


SDL_Event event;
bool isRunning = true;


while (isRunning) {
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
isRunning = false;
}
}
}


instead of using the delay method. Hope this helps!

harriscrews
Автор

Loved it man. This is the best SDL tutorial with C language!

a.v
Автор

Awesome presentation! I am new to SDL 2 programming and loved it. Thank you!

vaslot
Автор

Awesome introduction to sdl and great teacher, made it easy to understand :-)

_trion
Автор

So I'm planning to make a small platformer for my Data Structure class, this tutorial helped me A LOT to understand and begin the development.
Next step, reading the documentation!

nyume
Автор

As of today (2022) your code still works, and I use a mac. Thanks!

yusufmalikul
Автор

Note: If you stick in a *default:* for the switch statements, that will get rid of the warnings.
If you wanted, you could put some code in the default to output the key that was pressed to the console for debugging.

To compile this for Windows I recommend Code::Blocks which comes with MinGW, or grab MinGW and Notepad++ which will colourize the text like gedit and you can compile as he does in a console. Personally I prefer Code::Blocks as you can also download it for Linux which makes it VERY nice for cross platform stuff. It fits perfectly with SDL.

The only differences with compiling this with Windows is you have to create your main function like:

int main(int argc, char *argv[]) {

and you have to link in SDL2main BEFORE you link in anything else -lSDL2main -lSDL2 -lSDL2_Image

Otherwise, everything else works as expected.

NeilRoy
Автор

Hey thanks guy. I've been using lazy foo's tutorial to get farmiliar with sdl, but I think I'll start using the wiki now.

michaelwoodruff
Автор

cs5 does it again. thank you guys so much for everything

karimkohel
Автор

This tutorial was great, thank you for this!

atiedebee
Автор

Wow! This lesson is overwhelmingly informative. Thanks a lot! Superb work!!!

FernandoBasso
Автор

Thanks, man! Really really helpful introduction to SDL!

lmjunct
Автор

Me: Im gonna write a game with SDL!
Segmentation fault (core dumped): Hello

beb
Автор

Super, super helpful! Thank you so much!

lev
Автор

very good presentation
thank you very much

altaghyeer