improve force feedback

efd/v1
Dominik Madarász 2023-02-03 07:31:36 +01:00
parent 410d6e5f11
commit 3e4814222e
1 changed files with 5 additions and 11 deletions

View File

@ -6,7 +6,7 @@ ZPL_DIAGNOSTIC_POP
#define WEAPON_PROJECTILE_POS_OFFSET 200.0f #define WEAPON_PROJECTILE_POS_OFFSET 200.0f
#define WEAPON_PROJECTILE_SPEED 500.0f #define WEAPON_PROJECTILE_SPEED 500.0f
#define WEAPON_PROJECTILE_RANGE_LIFETIME 800.0f #define WEAPON_PROJECTILE_RANGE_LIFETIME 800.0f
#define WEAPON_HIT_FORCE_PUSH 40.0f #define WEAPON_HIT_FORCE_PUSH 400.0f
//TODO(DavoSK): move to helpers, add srand //TODO(DavoSK): move to helpers, add srand
float get_rand_between(float min, float max) { float get_rand_between(float min, float max) {
@ -129,19 +129,13 @@ void WeaponProjectileHit(ecs_iter_t* it) {
continue; continue;
} }
c2Manifold m = { 0 };
c2AABBtoAABBManifold(box_a, box_b, &m);
float dd = zpl_sqrt(d2);
if (m.count > 0) { if (c2AABBtoAABB(box_a, box_b)) {
float dd = zpl_sqrt(d2);
mob_health[j].dmg += weapon[i].damage; mob_health[j].dmg += weapon[i].damage;
for (int k = 0; k < m.count; k++) { mob_velocity[j].x += (dx/dd)*WEAPON_HIT_FORCE_PUSH;
float d = m.depths[k]; mob_velocity[j].y += (dy/dd)*WEAPON_HIT_FORCE_PUSH;
mob_velocity[j].x += (dx/dd)*d*WEAPON_HIT_FORCE_PUSH;
mob_velocity[j].y += (dy/dd)*d*WEAPON_HIT_FORCE_PUSH;
}
} }
} }
} }