allow error in aim angle

This commit is contained in:
jacob 2024-08-15 14:41:01 -05:00
parent f48a059397
commit bd4e560f67
4 changed files with 9 additions and 6 deletions

BIN
res/graphics/gun.ase (Stored with Git LFS)

Binary file not shown.

View File

@ -108,7 +108,7 @@ INTERNAL void spawn_test_entities(void)
/* Player */ /* Player */
struct entity *player_ent; struct entity *player_ent;
{ {
struct v2 pos = V2(1, 1); struct v2 pos = V2(-1, -1);
struct v2 size = V2(1, 1); struct v2 size = V2(1, 1);
f32 r = 0; f32 r = 0;
@ -596,7 +596,10 @@ INTERNAL void game_update(struct game_cmd_array game_cmds)
} }
if (!F32_IS_NAN(final_xf_angle)) { 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));
}
} }
} }

View File

@ -36,7 +36,7 @@ b32 string_ends_with(struct string str, struct string substring);
* Format * Format
* ========================== */ * ========================== */
#define DEFAULT_FMT_PRECISION 5 #define DEFAULT_FMT_PRECISION 6
enum fmt_type { enum fmt_type {
FMT_TYPE_NONE, FMT_TYPE_NONE,

View File

@ -902,7 +902,7 @@ INTERNAL void user_update(void)
/* Draw focus arrow */ /* Draw focus arrow */
if (entity_has_prop(ent, ENTITY_PROP_PLAYER_CONTROLLED)) { 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 *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); struct v2 start = xform_mul_v2(sprite_xform, slice.center);
start = xform_mul_v2(G.world_view, start); start = xform_mul_v2(G.world_view, start);
struct v2 end = v2_add(xf.og, ent->control.focus); struct v2 end = v2_add(xf.og, ent->control.focus);