MENU

Fun & Interesting

Creating a Game Loop with C & SDL (Tutorial)

pikuma 69,965 2 years ago
Video Not Working? Fix It Now

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: https://github.com/gustavopezzi/sdl-gameloop 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: https://gafferongames.com/post/fix_your_timestep/ For comprehensive courses on computer science, retro programming, and mathematics, visit: http://www.pikuma.com. Also, don't forget to subscribe to receive updates and news about new lectures and tutorials: https://www.youtube.com/channel/UC8GR0g1deJB_gxWxi_vuxhA?sub_confirmation=1 Enjoy!

Comment