I’m creating a top-down shooting game. I need to rotate the character to always face the mouse. How do I rotate textures or surfaces? It needs to be as fast as possible, as I’m trying to make this game very optimised.
SDL_RenderCopyEx has angle and center arguments. It?s the most efficient way to do that with the SDL_Render API.On Apr 12, 2014, at 7:14 PM, Plazmotech wrote:
I’m creating a top-down shooting game. I need to rotate the character to always face the mouse. How do I rotate textures or surfaces? It needs to be as fast as possible, as I’m trying to make this game very optimised.
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
As Alex noted, you can use SDL_RenderCopyEx. Check the wiki documentation:
https://wiki.libsdl.org/SDL_RenderCopyExOn 4/12/2014 6:16 PM, Alex Szpakowski wrote:
SDL_RenderCopyEx has angle and center arguments. It’s the most
efficient way to do that with the SDL_Render API.On Apr 12, 2014, at 7:14 PM, Plazmotech <thor at daugi.com <mailto:thor at daugi.com>> wrote:
I’m creating a top-down shooting game. I need to rotate the character
to always face the mouse. How do I rotate textures or surfaces? It
needs to be as fast as possible, as I’m trying to make this game very
optimised.
SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_gpu uses an additional optimization that the SDL_Renderer system
doesn’t yet use (geometry batching). If you actually run into performance
problems, you might want to try it out.
As for implementing a facing effect in 2D, look at atan2() in the C math
library. It’s so good.
Jonny D