From bd4e560f6741e6941202113c8e208525819176e9 Mon Sep 17 00:00:00 2001 From: jacob Date: Thu, 15 Aug 2024 14:41:01 -0500 Subject: [PATCH] allow error in aim angle --- res/graphics/gun.ase | 4 ++-- src/game.c | 7 +++++-- src/string.h | 2 +- src/user.c | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/res/graphics/gun.ase b/res/graphics/gun.ase index 980a602d..277e84e2 100644 --- a/res/graphics/gun.ase +++ b/res/graphics/gun.ase @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6eb03261e8abdb3729c65a0f65b12c9771c92bb1ab5b8ee07bcc0f7025d664df -size 816 +oid sha256:8a3754df8319d1bcd89bb5a4c5610f32bfbce013a1108562088b5d6a028be40f +size 812 diff --git a/src/game.c b/src/game.c index 98abf2d5..3b3ea045 100644 --- a/src/game.c +++ b/src/game.c @@ -108,7 +108,7 @@ INTERNAL void spawn_test_entities(void) /* Player */ struct entity *player_ent; { - struct v2 pos = V2(1, 1); + struct v2 pos = V2(-1, -1); struct v2 size = V2(1, 1); f32 r = 0; @@ -596,7 +596,10 @@ INTERNAL void game_update(struct game_cmd_array game_cmds) } if (!F32_IS_NAN(final_xf_angle)) { - entity_set_xform(ent, xform_with_rotation(xf, final_xf_angle)); + const f32 angle_error_allowed = 0.001; + if (math_fabs(final_xf_angle - v2_angle(xf.bx)) > angle_error_allowed) { + entity_set_xform(ent, xform_with_rotation(xf, final_xf_angle)); + } } } diff --git a/src/string.h b/src/string.h index 97a35219..ae77eea5 100644 --- a/src/string.h +++ b/src/string.h @@ -36,7 +36,7 @@ b32 string_ends_with(struct string str, struct string substring); * Format * ========================== */ -#define DEFAULT_FMT_PRECISION 5 +#define DEFAULT_FMT_PRECISION 6 enum fmt_type { FMT_TYPE_NONE, diff --git a/src/user.c b/src/user.c index e54ae56c..aac118cb 100644 --- a/src/user.c +++ b/src/user.c @@ -902,7 +902,7 @@ INTERNAL void user_update(void) /* Draw focus arrow */ if (entity_has_prop(ent, ENTITY_PROP_PLAYER_CONTROLLED)) { struct sprite_sheet *sheet = sprite_sheet_from_tag_async(sprite_frame_scope, ent->sprite); - struct sprite_sheet_slice slice = sprite_sheet_get_slice(sheet, STR("hold"), ent->animation_frame); + struct sprite_sheet_slice slice = sprite_sheet_get_slice(sheet, STR("attach.wep"), ent->animation_frame); struct v2 start = xform_mul_v2(sprite_xform, slice.center); start = xform_mul_v2(G.world_view, start); struct v2 end = v2_add(xf.og, ent->control.focus);