I’m making a 3D raycasted game in SDL, right now I’m making the 2D part to be raycasted later, but a little problem has arised. The character moves all wonkily and it’s weird. It flips randomly, wobbles when you are moving it constantly too.
Meaningful Function: bool getEvents(SDL_Window* window, SDL_Renderer* renderer){ SDL_Event event; - Pastebin.com
Whole Script: #include <iostream>#include <SDL2/SDL.h>#include <SDL2/SDL_image.h>#includ - Pastebin.com
Your conversion from degrees to radians is wrong.
radians = camera.rotation/(3.14159265/180);
^
This should be multiplication
I also noticed a lot of errors when closing the program …
Note that SDL_DestroyWindow
will destroy the renderer so you don’t really need to call SDL_DestroyRenderer
but if you do call it you should call it before SDL_DestroyWindow
.
SDL_Quit
will destroy all remaining windows so you don’t even need to call SDL_DestroyWindow
.
When the renderer is destroyed it also destroys all the textures so you shouldn’t be using them afterwards…
To fix all this I think you should just set running
to false inside the game loop and only call SDL_Quit
after exiting the game loop.