From f2961a006b429104be5024d0725b8a3796f5dac3 Mon Sep 17 00:00:00 2001 From: IXtreme Date: Sat, 21 Dec 2024 22:50:02 -0500 Subject: [PATCH] Centered image --- src/main.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4af4f75..beae60d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -259,11 +259,16 @@ int main(int argc, char *argv[]) { } BeginDrawing(); - ClearBackground(DARKGRAY); + ClearBackground(BLACK); Vector2 winwidth = (Vector2) {(float) GetScreenWidth(), (float) GetScreenHeight()}; Vector2 imagesize = (Vector2) {(float) current_player.tex.tex.width, (float) current_player.tex.tex.height}; - DrawTextureEx(current_player.tex.tex, (Vector2) {0,0}, 0, ScaleToFit(imagesize, winwidth), WHITE); + + Vector2 scaledsize = Vector2Scale(imagesize, ScaleToFit(imagesize, winwidth)); + Vector2 fpos; + fpos.x = (winwidth.x *0.5) - (scaledsize.x * 0.5f); + fpos.y = (winwidth.y *0.5) - (scaledsize.y * 0.5f); + DrawTextureEx(current_player.tex.tex, fpos, 0, ScaleToFit(imagesize, winwidth), WHITE); @@ -370,4 +375,4 @@ int main(int argc, char *argv[]) { //-------------------------------------------------------------------------------------- curl_global_cleanup(); return 0; -} +} \ No newline at end of file