Making A Game #1: Making The Game Loop : C++ And SDL2 Tutorial

Let's Make Games · 511K views · 2017 · 25:32

Open on YouTube

Game programming & enginesC, C++, Rust, Go & systems languagestutorial

Why Stack Overflow recommends it

Stack Overflow users link it as the tutorial they are following when they ask about SDL2 setup, include paths and linker errors in their own game projects.

Recommended by 2 people across 2 different months, 2019 to 2024.

What it is

The first episode of a C++ and SDL2 game programming series. It builds the game loop and a Game class from scratch, covering init, handleEvents, update, render and clean, and promises a texture manager and pixel art next. Presented by the Let's Make Games channel.

What people said

Recommends Dayskie · 2019-11 · Stack Overflow · on “SDL2/SDL.H file not found”

I'm following this tutorial on youtube: [this video] and he links a video on how to install SDL2, I follow that video, and I followed this one as well. But when I compile it keeps coming up with SDL2/SDL not found? I'm not sure how to fix this Here is my code so far MAIN.CPP #include "Game.hpp" Game *game =nullptr; int main(int argc, const char * argv[]) { game = new Game(); game->init("Nijigen-Engine", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, false); while (game->running()) { game->handleEvents(); game->update(); game->render(); } game->clean(); return 0; } Game.cpp #include "Game.hpp" Game::Game() {} Game::~Game() {} void Game::init(const char *title, int xpos, int ypos, int wi

Recommends Light Love Peace · 2022-11 · Stack Overflow · on “In an XCode C++ project how do you access the project assets from inside the application?”

Try to reference to the complete path of the image, atleast that's how I got it working: SDL_Surface* tmpSurface = IMG_Load("/Users/markcash/Documents/C++ Code/SDL_test/Assets/player.png"); playerTex = SDL_CreateTextureFromSurface(renderer, tmpSurface); SDL_FreeSurface(tmpSurface); I should note that I'm using the libraries: #include "SDL2/SDL.h" #include "SDL_image.h" in my project to make use of the IMG_Load() function. Try to see how you can implement those libraries into Xcode: here's a video that should help you in implementing SDL.h into your 'framework': [this video] The process for adding the "SDL_image.h" library into your framework should be the same. SDL2 can be downloaded from here: [

Cites Mac Programmer · 2019-08 · Stack Overflow · on “How to fix SDL2 'Assertion failure at SDL_RenderClear_REAL' in C++?”

I did initialize the window and the renderer while following the tutorial, but it didn't still gave the same error. Also, here is the tutorial in question: [this video] Going to go over it again to see if I missed something along the way.

Cites Tomato3 · 2019-10 · Stack Overflow · on “LNK1120 error and LNK2019 error inside include line game dev?”

I'm currently using this tutorial: [this video] But I've been getting this error on the first line that I don't know how to address as a beginner. It says it's unresolved externals [LINK] I've been trying to look at some of the windows config advice, [LINK] but I don't know how to apply it to this tutorial. here's the code: #include "Header.hpp" Game::Game(){} Game::~Game(){} void Game::init(const char* title, int xpos, int ypos, int width, int height, bool fullscreen) { int flags = 0; if (fullscreen) { flags = SDL_WINDOW_FULLSCREEN; } if (SDL_Init(SDL_INIT_EVERYTHING) == 0) { std::cout << "Subsystems initialized" << std::endl; window = SDL_CreateWindow(title, xpos, ypos, width, height, flags); i

Cites Drake Johnson · 2024-01 · Stack Overflow · on “Getting a linker issue with SDL2 and vcpkg about "invoke_main(void)"”

I am aware there are questions with similar posed questions, and I have checked both here [LINK] and here [LINK] , but neither question has posed solutions that seem to solve my problem. My subsystem is set to Windows (as suggested in the other posts). I am using Visual Studio 2022 and installed vcpkg [LINK] and its libraries today. Some of the solutions suggested making changes to CMake, but I am using vcpkg and am totally unsure how to implement these solutions. I apologize if this is something simple; I am new to SDL, and am following a YouTube series to learn. This is the exact same code as the series I'm following along with, but the code compiles correctly in the video [this video] . I'll i