Thrusters do damage

main
Cameron Murphy Reikes 2 years ago
parent e98c524ac0
commit 78fcdde982

@ -702,8 +702,10 @@ int platonic_detection_compare(const void *a, const void *b)
PlatonicDetection *b_detection = (PlatonicDetection *)b; PlatonicDetection *b_detection = (PlatonicDetection *)b;
double a_intensity = a_detection->intensity; double a_intensity = a_detection->intensity;
double b_intensity = b_detection->intensity; double b_intensity = b_detection->intensity;
if(a_detection->intensity == 0.0) a_intensity = INFINITY; if (a_detection->intensity == 0.0)
if(b_detection->intensity == 0.0) b_intensity = INFINITY; a_intensity = INFINITY;
if (b_detection->intensity == 0.0)
b_intensity = INFINITY;
double result = (a_intensity - b_intensity); double result = (a_intensity - b_intensity);
if (result < 0.0) if (result < 0.0)
{ {
@ -3152,8 +3154,20 @@ void process(struct GameState *gs, double dt)
{ {
cur_box->energy_effectiveness = batteries_use_energy(gs, grid, &non_battery_energy_left_over, cur_box->wanted_thrust * THRUSTER_ENERGY_USED_PER_SECOND * dt); cur_box->energy_effectiveness = batteries_use_energy(gs, grid, &non_battery_energy_left_over, cur_box->wanted_thrust * THRUSTER_ENERGY_USED_PER_SECOND * dt);
cur_box->thrust = cur_box->energy_effectiveness * cur_box->wanted_thrust; cur_box->thrust = cur_box->energy_effectiveness * cur_box->wanted_thrust;
if (cur_box->thrust >= 0.0) if (cur_box->thrust > 0.0)
{
cpBodyApplyForceAtWorldPoint(grid->body, (thruster_force(cur_box)), (entity_pos(cur_box))); cpBodyApplyForceAtWorldPoint(grid->body, (thruster_force(cur_box)), (entity_pos(cur_box)));
rect_query(gs->space, (BoxCentered){
.pos = cpvadd(entity_pos(cur_box), cpvmult(box_facing_vector(cur_box), BOX_SIZE)),
.rotation = box_rotation(cur_box),
.size = cpv(BOX_SIZE/2.0 - 0.03, BOX_SIZE/2.0 - 0.03),
});
QUEUE_ITER(&query_result, QueryResult, res)
{
flight_assert(cp_shape_entity(res->shape) != NULL);
cp_shape_entity(res->shape)->damage += THRUSTER_DAMAGE_PER_SEC * dt;
}
}
} }
if (cur_box->box_type == BoxGyroscope) if (cur_box->box_type == BoxGyroscope)
{ {

@ -50,12 +50,13 @@
#define VISION_RADIUS 20.0f #define VISION_RADIUS 20.0f
#define MAX_HAND_REACH 1.0f #define MAX_HAND_REACH 1.0f
#define GOLD_COLLECT_RADIUS 0.3f #define GOLD_COLLECT_RADIUS 0.3f
#define BUILD_BOX_SNAP_DIST_TO_SHIP 0.2f #define BUILD_BOX_SNAP_DIST_TO_SHIP 0.2
#define BOX_MASS 1.0f #define BOX_MASS 1.0
#define COLLISION_DAMAGE_SCALING 0.15f #define COLLISION_DAMAGE_SCALING 0.15
#define THRUSTER_FORCE 24.0f #define THRUSTER_FORCE 24.0
#define THRUSTER_ENERGY_USED_PER_SECOND 0.005f #define THRUSTER_ENERGY_USED_PER_SECOND 0.005
#define THRUSTER_DAMAGE_PER_SEC 2.0
#define GYROSCOPE_ENERGY_USED_PER_SECOND 0.005f #define GYROSCOPE_ENERGY_USED_PER_SECOND 0.005f
#define GYROSCOPE_TORQUE 1.5f #define GYROSCOPE_TORQUE 1.5f

Loading…
Cancel
Save