Hi,
I’m very new to SDL2 (Uni student), so I apologise if this is something super-simple, which I suspect it will be, but here goes.
I am trying to render this texture at an angle relative to the Mouse cursor location. The texture renders in the correct place using the correct Rect, but it does not rotate . Here is my code so far:
Function for constantly updating:
void update()
{
// SDL event is temporarily stored in this variable when processing each of the
// SDL events on the SDL window events queue
SDL_Event event;
// Handle SDL events on queue, keep handling until no more events to process
while (SDL_PollEvent(&event) != 0)
{
if (event.type == SDL_MOUSEMOTION)
{
switch (event.motion.x, event.motion.y)
{
case SDL_MOUSEMOTION:
SDL_GetMouseState(&MouseX, &MouseY);
break;
}
}
}
}
Function for constantly drawing:
void draw()
{
// Clear the double buffered main window surface using the main window renderer
SDL_RenderClear(pRenderer);
// Render Challenger 1 Body & Turret
Render_Challenger1();
// Update GPU with Renderer
SDL_RenderPresent(pRenderer);
}
Function to set rect and rendering for this asset (Challenger 1)
void Render_Challenger1()
{
SDL_Rect Challenger1TurretRect = { Challenger1.Turret_XPos, Challenger1.Turret_YPos, Challenger1.Turret_Width, Challenger1.Turret_Height }; // Store the location and size of the Texture in SDL_Rect type structure and set a point to rotate
SDL_RenderCopyEx(pRenderer, Challenger1.Turret_Texture, NULL, &Challenger1TurretRect, TrueAngle, NULL, SDL_FLIP_NONE);
}
There is more code than this but I cut it out so you can see what I’m trying to do.
This is the result : The mouse was in the center of the window (Windows doesn’t capture mouse in PrintScreens )
Thanks for reading