Compare commits

...

4 Commits

Binary file not shown.

@ -2793,7 +2793,7 @@ void process(struct GameState *gs, double dt)
#if 1 // building
if (player->input.dobuild)
{
player->input.dobuild = false; // handle the input. if didn't do this, after destruction of hovered box, would try to build on its grid with grid_index...
player->input.dobuild = false; // handle the input. if didn't do this, after destruction of hovered box, would try to build on it again the next frame
cpPointQueryInfo info = {0};
cpVect world_build = world_hand_pos;
@ -2888,7 +2888,7 @@ void process(struct GameState *gs, double dt)
}
}
// sun processing for this current entity
// sun processing for this current entity
#ifndef NO_SUNS
PROFILE_SCOPE("this entity sun processing")
{
@ -2897,16 +2897,18 @@ void process(struct GameState *gs, double dt)
cpVect pos_rel_sun = (cpvsub(entity_pos(e), (entity_pos(i.sun))));
cpFloat sqdist = cpvlengthsq(pos_rel_sun);
bool is_entity_dangerous = false;
is_entity_dangerous |= e->is_missile;
if (e->is_box)
if (i.sun->sun_is_safe)
{
is_entity_dangerous |= e->box_type == BoxExplosive;
}
if (is_entity_dangerous && sqdist < sun_dist_no_gravity(i.sun) * sun_dist_no_gravity(i.sun))
{
e->flag_for_destruction = true;
break;
bool is_entity_dangerous = false;
is_entity_dangerous |= e->is_missile;
if (e->is_box)
{
is_entity_dangerous |= e->box_type == BoxExplosive;
}
if (is_entity_dangerous && sqdist < sun_dist_no_gravity(i.sun) * sun_dist_no_gravity(i.sun))
{
e->flag_for_destruction = true;
}
}
if (!e->is_grid) // grids aren't damaged (this edge case sucks!)
@ -3279,24 +3281,36 @@ void process(struct GameState *gs, double dt)
for (int i = 0; i < MAX_BOX_TYPES; i++)
{
cpVect cur_pos = gs->platonic_positions[i];
if (cpvlength(cur_pos) > 0.0) // zero is uninitialized, the platonic solid doesn't exist (probably) @Robust do better
if (cpvlengthsq(cur_pos) > 0.0) // zero is uninitialized, the platonic solid doesn't exist (probably) @Robust do better
{
cpVect towards = cpvsub(cur_pos, from_pos);
double length_to_cur = cpvlength(towards);
detections[i].direction = cpvnormalize(towards);
detections[i].of_type = i;
detections[i].intensity = length_to_cur; // so it sorts correctly, changed to intensity correctly after sorting
}
}
qsort(detections, MAX_BOX_TYPES, sizeof(detections[0]), platonic_detection_compare);
for (int i = 0; i < SCANNER_MAX_PLATONICS; i++)
{
cur_box->detected_platonics[i] = detections[i];
if (cur_box->detected_platonics[i].intensity > 0.0)
for (int detections_i = 0; detections_i < MAX_BOX_TYPES; detections_i++)
{
cur_box->detected_platonics[i].intensity = max(0.1, 1.0 - clamp01(cur_box->detected_platonics[i].intensity / 100.0));
// so can be viewed in debugger what causes it not to be used
bool use_this_detection = true;
use_this_detection &= detections[detections_i].intensity > 0.0;
use_this_detection &= !detections[detections_i].used_in_scanner_closest_lightning_bolts;
use_this_detection &= !learned_boxes_has_box(cur_box->blueprints_learned, detections[detections_i].of_type);
if (use_this_detection)
{
detections[detections_i].used_in_scanner_closest_lightning_bolts = true;
cur_box->detected_platonics[i] = detections[detections_i];
cur_box->detected_platonics[i].intensity = max(0.1, 1.0 - clamp01(cur_box->detected_platonics[i].intensity / 100.0));
}
}
}
// after the above logic detections has been modified, do not use
circle_query(gs->space, entity_pos(cur_box), SCANNER_MAX_RANGE);
cpBody *body_results[512] = {0};
size_t cur_results_len = 0;

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

@ -272,7 +272,7 @@ typedef struct Particle
double scaling;
} Particle;
#define MAX_PARTICLES 1000
#define MAX_PARTICLES 2000
static Particle particles[MAX_PARTICLES] = {0};
#define PARTICLES_ITER(p) for (Particle *p = &particles[0]; p < particles + MAX_PARTICLES; p++)
@ -911,6 +911,7 @@ static void set_pipeline_and_pull_color(sg_pipeline pip)
sgp_set_uniform(&sgp_query_state()->color, sizeof(sgp_query_state()->color));
}
// set uniforms after beginning of scope
#define pipeline_scope(pipeline) DeferLoop(set_pipeline_and_pull_color(pipeline), sgp_reset_pipeline())
static void draw_color_rect_centered(cpVect center, double size)
@ -2315,9 +2316,7 @@ static void frame(void)
transform_scope()
{
rotate_at(build_preview.grid_rotation +
rotangle(cur_editing_rotation),
global_hand_pos.x, global_hand_pos.y);
rotate_at(build_preview.grid_rotation + rotangle(cur_editing_rotation), global_hand_pos.x, global_hand_pos.y);
sgp_set_image(0, boxinfo(currently_building()).image);
set_color_values(0.5, 0.5, 0.5, (sin((float)exec_time * 9.0) + 1.0) / 3.0 + 0.2);
pipeline_scope(goodpixel_pipeline)
@ -2715,7 +2714,7 @@ static void frame(void)
set_color(RED);
draw_circle((cpVect){0}, INSTANT_DEATH_DISTANCE_FROM_CENTER);
// the SUN
// the suns
SUNS_ITER(&gs)
{
transform_scope()

@ -257,8 +257,12 @@ typedef struct InputFrame
typedef struct PlatonicDetection
{
// only these two are serialized
cpVect direction;
double intensity;
enum BoxType of_type;
bool used_in_scanner_closest_lightning_bolts;
} PlatonicDetection;
typedef struct Entity

Loading…
Cancel
Save