[Solved] How do I spawn more enemies? SDL2/C++

I suggest placing your enemies into a std::vector or std::queue. Each enemy should have it’s own coordinates (for easy placement). In your update or refresh loop, iterator over the enemy list, processing them as necessary. In another timing loop or thread, you can add enemies to the container. This should not affect the code of … Read more

[Solved] SDL2 Exporting to linux

Well I solved the problem i was installing wrong SDL2 libraries: used these: sudo apt-get install libsdl2-dev sudo apt-get install libsdl2-image-dev sudo apt-get install libsdl2-ttf-dev 1 solved SDL2 Exporting to linux

[Solved] C equivalent of C++’s double colons?

In C, loadSurface would be declared as simply SDL_Surface *loadSurface(const char *path) which means the call to SDL_LoadBMP can be written as SDL_Surface *loadedSurface = SDL_LoadBMP(path); The details of what std::string does and why .c_str() is needed are not relevant if you are not interested in learning C++, and in this case are not relevant … Read more

[Solved] why get I segmentation fault (core dumped) on compiling my code C (linux) [closed]

you declared the function: int blit_image(char chemin[15],SDL_Surface *fenetre,int posx,int posy) { So that that parameter #1 has 15 characters. But when you call it, you call it with: blit_image(“resources/images/fondblanc.bmp”,fenetre,0,0); That filename is 31-characters by my counting, and will not fit into 15 characters. I also added some printf-statements to your code which will help you … Read more

[Solved] C/SDL – Segmentation fault when program run multiple times in succession [closed]

Let me break down a debugging session for you, but in future you better do that yourself. If the problem can be easily reproduced, it is quite trivial to fix it: gdb ./GAME (gdb) r Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7b2d10c in ?? () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 (gdb) bt #0 0x00007ffff7b2d10c in ?? () from … Read more

[Solved] Error multiple definition when compiling using headers [closed]

Do not mix declaration with definition/instantiation in a .h file. Your are instantiating g_font, g_window and g_renderer in isolation.h file. The correct is instantiating only once, usually, in a .cpp To solve your problem, change isolation.h to declare those variables as external linkage: //load global front extern TTF_Font* g_font; //window extern SDL_Window* g_window; //renderer extern … Read more