Allow rotating sprites
This commit is contained in:
parent
991cff858d
commit
6bf8c2cb88
@ -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, ¢er, 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);
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user