Account for spawn dist in missile lookahead

main
Cameron Murphy Reikes 2 years ago
parent f56be36192
commit 3ff13d5529

@ -17,7 +17,7 @@
// #define PROFILING // #define PROFILING
#define DEBUG_RENDERING #define DEBUG_RENDERING
// #define DEBUG_WORLD // #define DEBUG_WORLD
// #define UNLOCK_ALL #define UNLOCK_ALL
#define TIME_BETWEEN_WORLD_SAVE 1.0f #define TIME_BETWEEN_WORLD_SAVE 1.0f
// #define INFINITE_RESOURCES // #define INFINITE_RESOURCES
#define DEBUG_TOOLS #define DEBUG_TOOLS

@ -312,7 +312,7 @@ static void on_missile_shape(cpShape *shape, cpContactPointSet *points, void *da
// lookahead by their velocity // lookahead by their velocity
cpVect rel_velocity = cpvsub(entity_vel(gs, other), entity_vel(gs, launcher)); cpVect rel_velocity = cpvsub(entity_vel(gs, other), entity_vel(gs, launcher));
double dist = cpvdist(entity_pos(other), entity_pos(launcher)); double dist = cpvdist(entity_pos(other), entity_pos(launcher)) - MISSILE_SPAWN_DIST;
double time_of_travel = sqrt((2.0 * dist) / (MISSILE_BURN_FORCE / MISSILE_MASS)); double time_of_travel = sqrt((2.0 * dist) / (MISSILE_BURN_FORCE / MISSILE_MASS));
@ -2902,8 +2902,7 @@ void process(struct GameState *gs, double dt)
Entity *new_missile = new_entity(gs); Entity *new_missile = new_entity(gs);
create_missile(gs, new_missile); create_missile(gs, new_missile);
new_missile->owning_squad = cur_box->owning_squad; // missiles have teams and attack eachother! new_missile->owning_squad = cur_box->owning_squad; // missiles have teams and attack eachother!
double missile_spawn_dist = sqrt((BOX_SIZE / 2.0) * (BOX_SIZE / 2.0) * 2.0) + MISSILE_COLLIDER_SIZE.x / 2.0 + 0.1; cpBodySetPosition(new_missile->body, (cpvadd(entity_pos(cur_box), cpvspin((cpVect){.x = MISSILE_SPAWN_DIST, 0.0}, target.facing_angle))));
cpBodySetPosition(new_missile->body, (cpvadd(entity_pos(cur_box), cpvspin((cpVect){.x = missile_spawn_dist, 0.0}, target.facing_angle))));
cpBodySetAngle(new_missile->body, target.facing_angle); cpBodySetAngle(new_missile->body, target.facing_angle);
cpBodySetVelocity(new_missile->body, (box_vel(cur_box))); cpBodySetVelocity(new_missile->body, (box_vel(cur_box)));
} }

@ -29,6 +29,7 @@
// centered on the sprite // centered on the sprite
#define MISSILE_SPRITE_SIZE ((cpVect){.x = BOX_SIZE, .y = BOX_SIZE}) #define MISSILE_SPRITE_SIZE ((cpVect){.x = BOX_SIZE, .y = BOX_SIZE})
#define MISSILE_COLLIDER_SIZE ((cpVect){.x = BOX_SIZE * 0.5f, .y = BOX_SIZE * 0.5f}) #define MISSILE_COLLIDER_SIZE ((cpVect){.x = BOX_SIZE * 0.5f, .y = BOX_SIZE * 0.5f})
#define MISSILE_SPAWN_DIST (sqrt((BOX_SIZE / 2.0) * (BOX_SIZE / 2.0) * 2.0) + MISSILE_COLLIDER_SIZE.x / 2.0 + 0.1)
#define PLAYER_JETPACK_ROTATION_ENERGY_PER_SECOND 0.2f #define PLAYER_JETPACK_ROTATION_ENERGY_PER_SECOND 0.2f
#define PLAYER_JETPACK_SPICE_PER_SECOND 0.08f #define PLAYER_JETPACK_SPICE_PER_SECOND 0.08f
#define SCANNER_ENERGY_USE 0.05f #define SCANNER_ENERGY_USE 0.05f

Loading…
Cancel
Save