proper pos offset

efd/v1
DavoSK 2023-02-02 19:22:12 +01:00
parent c21cb39140
commit ea9b201a08
1 changed files with 9 additions and 9 deletions

View File

@ -38,16 +38,16 @@ void WeaponKnifeMechanic(ecs_iter_t *it) {
.y=input[i].hy*WEAPON_PROJECTILE_SPEED*-1 .y=input[i].hy*WEAPON_PROJECTILE_SPEED*-1
}); });
Position *dest = ecs_get_mut(world_ecs(), e, Position); zpl_vec2 input_vec = {
const float offset = get_rand_between(-WEAPON_PROJECTILE_POS_OFFSET, WEAPON_PROJECTILE_POS_OFFSET); .x = input[i].hy,
dest->x=pos[i].x; .y = input[i].hx
dest->y=pos[i].y; };
if(zpl_abs(input[i].hx) > 0) zpl_vec2 pos_offset;
dest->y += offset; zpl_vec2_mul(&pos_offset, input_vec, get_rand_between(-WEAPON_PROJECTILE_POS_OFFSET, WEAPON_PROJECTILE_POS_OFFSET));
Position *dest = ecs_get_mut(world_ecs(), e, Position);
if(zpl_abs(input[i].hy) > 0) dest->x = pos[i].x + pos_offset.x;
dest->x += offset; dest->y = pos[i].y + pos_offset.y;
} }
weapon[i].spawn_delay = WEAPON_KNIFE_SPAWN_DELAY; weapon[i].spawn_delay = WEAPON_KNIFE_SPAWN_DELAY;