Creating a Game Loop with C & SDL (Tutorial)

preview_player
Показать описание
This video is a beginner-friendly introduction on how to create a game loop using C & SDL.

We'll start by discussing how to install SDL on Linux, macOS, and Windows, and we'll then proceed to create a very simple C application that uses SDL to control game objects.

We'll briefly discuss how to create an SDL window, render simple objects on the screen, cap our framerate, and achieve framerate-independent movement.

Download the source code:

Chapters:
00:00:00 Introduction
00:07:28 C & the SDL Library
00:09:37 Installing SDL on Linux
00:11:33 Installing SDL on macOS
00:12:26 Installing SDL on Windows
00:27:44 Starting our code
00:33:12 Using a Makefile
00:37:08 Including SDL in our C code
00:43:17 Creating an SDL window
00:58:59 Handling Process Input
01:04:53 Adding SDL Linker Flags
01:09:11 Drawing a filled rectangle with SDL
01:19:49 Capping our Framerate
01:32:37 Moving game objects as a function of delta-time
01:40:05 Using SDL_Delay
01:47:37 Deciding not to cap our framerate
01:49:26 Conclusion & next steps

As always, this is just the initial conversation about a potentially complex topic. For a more detailed overview of fixing our time step, Glenn Fiedler's blog post is a mandatory read:

Also, don't forget to subscribe to receive updates and news about new lectures and tutorials:

Enjoy!
Рекомендации по теме
Комментарии
Автор

truly the best sdl explanation i have seen clear and concise thx very much!

SirenSeph
Автор

This is very well explained. And the code is beautiful. I love the simplicity of C. Thanks a lot, Gustavo!

pavelnezamayev
Автор

This was a rather nice introduction to SDL, thanks for making this

demon_hunter
Автор

Amazing video! Thanks for sharing your knowledge here. I learned about capping and delta time in the past but the concepts never consolidated in my mind, now I really understand.

Thanks again.

lusca_
Автор

Thank you. I am writing an emulator for the first time in C with SDL and this was a very useful resource!

cybergizmo
Автор

Fantastic video. You are a great teacher - I look forward to doing your 2d game engine course soon!

ChrisMabryTV
Автор

this is one of the best channels on youtube for gamedev. thanks for your content!

gordonmccrary
Автор

What a great class! Great explanation of important points in game development concepts.

BryanChance
Автор

Pretty well explained tutorial, Keep going! Helped me a lot to solve some problems i've been having during my journey on learning about SDL-based game dev :)

alpha
Автор

Many thanks, Gustavo. I studied a lot from this very brief explanation.

hapboyman
Автор

I'm saving money to enroll in the 3D Computer Graphics Programming course. I love your videos!

ulysses_grant
Автор

The best explanation so far, thanks for this content!

rodrick
Автор

Great explanation! Thanks for making this video.

jayaganthan
Автор

this has helped me a LOT thanks for the lecture!

oytun
Автор

Thanks Gustavo. You are always so helpful man <3

AnkitSinghKushwah
Автор

Thanks a lot, you saved me a lot of time and effort!, GREAT EXPLANATION!, and so far the best video that really helped me on this topic!

dhruvasambhoo
Автор

Just what I needed. Thank you very much

jyuart
Автор

I created a relatively simple game without an engine using Electron (Typescript) which ended up around 200mb. Feedback was the game consumed too much resources (I actually expected this from an Electron app running at 60fps on the Chromium browser).

Ive started learning C and will port the project over to C and SDL. I think I can do way way better. Thanks for this amazing guide... ❤

kwameopareasiedu
Автор

Haven't touched C before. Only some bare C++. I loved this eitheray and learned a lot.

Exotic
Автор

Damm! this was awesome! learned soo much from this video! look forward to follow along ;)

a.v