Platonic fixes, platonic can't be destroyed

main
Cameron Murphy Reikes 2 years ago
parent e8ed1b25b4
commit d1e705dc5c

Binary file not shown.

@ -94,7 +94,8 @@ void unlock_box(Player *player, enum BoxType box)
bool box_unlocked(Player *player, enum BoxType box)
{
assert(box < MAX_BOX_TYPES);
if(box == BoxInvalid) return false;
if (box == BoxInvalid)
return false;
return learned_boxes_has_box(player->box_unlocks, box);
}
@ -618,7 +619,8 @@ float entity_angular_velocity(Entity *grid)
}
Entity *box_grid(Entity *box)
{
if(box == NULL) return NULL;
if (box == NULL)
return NULL;
assert(box->is_box);
return (Entity *)cpBodyGetUserData(cpShapeGetBody(box->shape));
}
@ -1774,7 +1776,7 @@ void process(GameState *gs, float dt)
if (maybe_box_to_destroy != NULL)
{
Entity *cur_box = cp_shape_entity(maybe_box_to_destroy);
if (!cur_box->indestructible)
if (!cur_box->indestructible && !cur_box->is_platonic)
{
Entity *cur_grid = cp_body_entity(cpShapeGetBody(maybe_box_to_destroy));
p->damage -= DAMAGE_TO_PLAYER_PER_BLOCK * ((BATTERY_CAPACITY - cur_box->energy_used) / BATTERY_CAPACITY);
@ -1806,7 +1808,8 @@ void process(GameState *gs, float dt)
grid_correct_for_holes(gs, target_grid); // no holey ship for you!
new_box->box_type = player->input.build_type;
new_box->compass_rotation = player->input.build_rotation;
if(new_box->box_type == BoxScanner) new_box->blueprints_learned = player->box_unlocks;
if (new_box->box_type == BoxScanner)
new_box->blueprints_learned = player->box_unlocks;
if (new_box->box_type == BoxBattery)
new_box->energy_used = BATTERY_CAPACITY;
}
@ -1834,8 +1837,30 @@ void process(GameState *gs, float dt)
cpVect p = cpvsub(cpBodyGetPosition(e->body), v2_to_cp(SUN_POS));
cpFloat sqdist = cpvlengthsq(p);
if (sqdist > (INSTANT_DEATH_DISTANCE_FROM_SUN * INSTANT_DEATH_DISTANCE_FROM_SUN))
{
bool platonic_found = false;
if(e->is_grid)
{
BOXES_ITER(gs, cur_box, e)
{
if(cur_box->is_platonic)
{
platonic_found = true;
break;
}
}
}
if (platonic_found)
{
cpBody *body = e->body;
cpBodySetVelocity(body, cpvmult(cpBodyGetVelocity(body), -1.0));
cpVect rel_to_sun = cpvsub(cpBodyGetPosition(body), v2_to_cp(SUN_POS));
cpBodySetPosition(body, cpvadd(v2_to_cp(SUN_POS), cpvmult(cpvnormalize(rel_to_sun), INSTANT_DEATH_DISTANCE_FROM_SUN)));
}
else
{
entity_destroy(gs, e);
}
continue;
}
if (sqdist < (SUN_RADIUS * SUN_RADIUS))

@ -1772,6 +1772,9 @@ static void frame(void)
if (b->indestructible)
{
sgp_set_color(0.2f, 0.2f, 0.2f, 1.0f);
} else if(b->is_platonic)
{
set_color(GOLD);
}
pipeline_scope(goodpixel_pipeline)
draw_texture_centered(entity_pos(b), BOX_SIZE);

Loading…
Cancel
Save