Al881
September 21, 2026, 5:43pm
1
Hi, I’m hacking together code from Lazy Foo' Productions - Beginning Game Programming v2.0 and SDL2 - Creating a 2D Shoot 'Em Up - parallelrealities.co.uk
I have changed some strucys in t classes and replaced free and malloc with new and delete but apart from that my code is identical to that on the website. Why are my enemy sprites not appearing on the screen?
compiled with:$ g++ main.cpp -g -lSDL2_image -lSDL2
https://www.dropbox.com/scl/fo/ms1m121kzswnya26opajz/ADQKFlVlj9irlL-tKkts__o?rlkey=i12g23vvxckvl6ie3loq5joh7&st=c0bz47ic&dl=0
Paste the code directly in your post(s) instead of some dropbox link.
If it’s too much code, create a github repository, put the code there and paste the link here.
Peter87
September 22, 2026, 7:17am
3
You need to debug your code. Add temporary print statements or step through the code with a debugger to make sure the code does what it’s supposed to.
Make sure that the spawn enemy function actually gets called.
Make sure the enemy render function gets called.
Make sure the enemies are spawned within the screen area.
Make sure the enemies are being drawn where their x and y coordinates say they should be.
And so on…
Eventually you should be able to pinpoint where the problem is.