Allow rotating sprites

This commit is contained in:
Reimar 2025-10-27 09:45:26 +01:00
parent 991cff858d
commit 6bf8c2cb88
2 changed files with 9 additions and 0 deletions

View File

@ -54,6 +54,13 @@ void GameRenderer::draw_sprite(const Sprite sprite, const int x, const int y) co
SDL_RenderCopy(renderer, sprite.texture, nullptr, &rect);
}
void GameRenderer::draw_sprite_rotated(const Sprite sprite, const int x, const int y, const double angle, const int center_x, const int center_y) const
{
const SDL_Rect rect = { .x = x, .y = y, .w = sprite.width, .h = sprite.height };
const SDL_Point center = { .x = center_x, .y = center_y };
SDL_RenderCopyEx(renderer, sprite.texture, nullptr, &rect, angle, &center, SDL_FLIP_NONE);
}
void GameRenderer::clear_screen(const int r, const int g, const int b, const int a) const
{
SDL_SetRenderDrawColor(renderer, r, g, b, a);

View File

@ -25,6 +25,8 @@ public:
void draw_sprite(Sprite sprite, int x, int y) const;
void draw_sprite_rotated(Sprite sprite, int x, int y, double angle, int center_x, int center_y) const;
void clear_screen(int r, int g, int b, int a) const;
void flush() const;