flappychik

Silly SDL2 game
git clone git://bsandro.tech/flappychik
Log | Files | Refs

commit b4109700c5bfa6297a872f15b7d62624ddcbec80
parent 2ccfda9ab12b2f019014483fcc235a8b0ef0e602
Author: bsandro <brian.drosan@gmail.com>
Date:   Sat, 19 Mar 2022 18:23:05 +0200

scaling sprites for hidpi environment if needed

Diffstat:
Mmain.c | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/main.c b/main.c @@ -100,10 +100,17 @@ int main(int argc, char *argv[]) { SDL_GetRendererOutputSize(game.renderer, &game.scrW, &game.scrH); SDL_RenderPresent(game.renderer); + // hidpi scale + float hidpi_scale = (float)game.scrW / GAME_WIN_WIDTH; + printf("scale: %.2f\n", hidpi_scale); // initial values game.last_frame = SDL_GetTicks64(); game.ship.rect.x = 150; game.ship.rect.y = 50; + game.ship.rect.w *= hidpi_scale; + game.ship.rect.h *= hidpi_scale; + game.bg.rect.w *= hidpi_scale; + game.bg.rect.h *= hidpi_scale; game.ship.accel = 0.85; // pixels per second^2 essentially // main game loop