From 658b0572d9a391e15bf3822d803ee48031d9a673 Mon Sep 17 00:00:00 2001 From: MeirGavish Date: Tue, 12 Aug 2025 03:01:02 +0300 Subject: [PATCH] Removed all uses of float for optimization --- source/game.c | 2 +- source/sprite.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/game.c b/source/game.c index f58d644..83ef525 100644 --- a/source/game.c +++ b/source/game.c @@ -1576,7 +1576,7 @@ static void played_cards_update_loop(bool* discarded_card, int* played_selection FIXED played_x = int2fx(120); FIXED played_y = int2fx(70); - FIXED played_scale = float2fx(1.0f); + FIXED played_scale = FIX_ONE; played_x = played_x + (int2fx(played_top - i) - int2fx(played_top) / 2) * -27; diff --git a/source/sprite.c b/source/sprite.c index a93b953..fb973c3 100644 --- a/source/sprite.c +++ b/source/sprite.c @@ -145,9 +145,9 @@ void sprite_object_reset_transform(SpriteObject* sprite_object) sprite_object->y = 0; sprite_object->vx = 0; sprite_object->vy = 0; - sprite_object->tscale = float2fx(1.0f); // Target scale - sprite_object->scale = float2fx(1.0f); - sprite_object->vscale = float2fx(0.0f); + sprite_object->tscale = FIX_ONE; // Target scale + sprite_object->scale = FIX_ONE; + sprite_object->vscale = 0; sprite_object->trotation = 0; // Target rotation sprite_object->rotation = 0; sprite_object->vrotation = 0; @@ -163,7 +163,7 @@ void sprite_object_update(SpriteObject* sprite_object) sprite_object->vrotation += (sprite_object->trotation - sprite_object->rotation) / 8; // Rotate the card when it's played // set velocity to 0 if it's close enough to the target - const float epsilon = float2fx(0.01f); + const FIXED epsilon = FIX_ONE>>7; // 1/(2^7) = 1/128 = 0.0078125 if (sprite_object->vx < epsilon && sprite_object->vx > -epsilon && sprite_object->vy < epsilon && sprite_object->vy > -epsilon) { sprite_object->vx = 0; @@ -211,8 +211,8 @@ void sprite_object_update(SpriteObject* sprite_object) void sprite_object_shake(SpriteObject* sprite_object, mm_word sound_id) { - sprite_object->vscale = float2fx(0.3f); // Scale down the card when it's scored - sprite_object->vrotation = float2fx(8.0f); // Rotate the card when it's scored + sprite_object->vscale = FIX_ONE >> 2; // (1/4 = 0.25) Scale down the card when it's scored + sprite_object->vrotation = FIX_ONE << 3; // (2^3 = 8) Rotate the card when it's scored if (sound_id == UNDEFINED) return; // If no sound ID is provided, do nothing