|
|
@ -282,11 +282,9 @@ void new_update_viewport(Body const * const pl) { |
|
|
|
if (last_plpos.x == 0 && last_plpos.y == 0) |
|
|
|
if (last_plpos.x == 0 && last_plpos.y == 0) |
|
|
|
last_plpos = player.physics->position; |
|
|
|
last_plpos = player.physics->position; |
|
|
|
|
|
|
|
|
|
|
|
printf("%f %f\n", pl->vel.x, pl->vel.y); |
|
|
|
|
|
|
|
static Vect lmove = {}; |
|
|
|
static Vect lmove = {}; |
|
|
|
|
|
|
|
|
|
|
|
Vect iv = in_view(pl->position); |
|
|
|
Vect iv = in_view(pl->position); |
|
|
|
printf("player pos: %f %f\n", pl->position.x, pl->position.y); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vect left_pos = {0, 2 * height / 4}; |
|
|
|
Vect left_pos = {0, 2 * height / 4}; |
|
|
|
left_pos = vect_add(pl->position, vect_scalar(left_pos, -1)); |
|
|
|
left_pos = vect_add(pl->position, vect_scalar(left_pos, -1)); |
|
|
@ -309,10 +307,8 @@ void new_update_viewport(Body const * const pl) { |
|
|
|
if (true || (recover) //|| vect_mag((Vect){pl->vel.x, 0}) > 0.4
|
|
|
|
if (true || (recover) //|| vect_mag((Vect){pl->vel.x, 0}) > 0.4
|
|
|
|
|| (dist_change > width / 100)) { |
|
|
|
|| (dist_change > width / 100)) { |
|
|
|
if (iv.x < width / 6) { |
|
|
|
if (iv.x < width / 6) { |
|
|
|
printf("RIGHT\n"); |
|
|
|
|
|
|
|
target = right_pos; |
|
|
|
target = right_pos; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
printf("LEFT\n"); |
|
|
|
|
|
|
|
target = left_pos; |
|
|
|
target = left_pos; |
|
|
|
} |
|
|
|
} |
|
|
|
lmove = target; |
|
|
|
lmove = target; |
|
|
@ -343,8 +339,6 @@ void new_update_viewport(Body const * const pl) { |
|
|
|
/*}*/ |
|
|
|
/*}*/ |
|
|
|
|
|
|
|
|
|
|
|
//target.y = pl->position.y - height/2; // + y;
|
|
|
|
//target.y = pl->position.y - height/2; // + y;
|
|
|
|
printf("viewport pos: %f %f\n", iv.x, iv.y); |
|
|
|
|
|
|
|
printf("target pos: %f %f\n", target.x, iv.y); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*}*/ |
|
|
|
/*}*/ |
|
|
|
/*}*/ |
|
|
|
/*}*/ |
|
|
@ -360,12 +354,10 @@ void new_update_viewport(Body const * const pl) { |
|
|
|
// move towards target a set proportion
|
|
|
|
// move towards target a set proportion
|
|
|
|
Vect urgency = vect_add(target, vect_scalar(player.physics->position, -1)); |
|
|
|
Vect urgency = vect_add(target, vect_scalar(player.physics->position, -1)); |
|
|
|
Vect p = vect_add(target, vect_scalar(viewport_pos, -1)); |
|
|
|
Vect p = vect_add(target, vect_scalar(viewport_pos, -1)); |
|
|
|
printf("drawtime: %f", time_delta); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double proportion = (sigmoid(time_delta) / 100); |
|
|
|
double proportion = (sigmoid(time_delta) / 100); |
|
|
|
proportion = 2 * player.physics->vel.x / (width); |
|
|
|
proportion = 2 * player.physics->vel.x / (width); |
|
|
|
proportion = proportion < 0 ? -proportion : proportion; |
|
|
|
proportion = proportion < 0 ? -proportion : proportion; |
|
|
|
printf("prop: %f", proportion); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proportion > 0.4 ? proportion = 0.4 : 0; |
|
|
|
proportion > 0.4 ? proportion = 0.4 : 0; |
|
|
|
proportion < 0 ? proportion = 0.000001 : 0; |
|
|
|
proportion < 0 ? proportion = 0.000001 : 0; |
|
|
|