|
|
|
@ -97,7 +97,7 @@ player_st get_player(int x, int y) {
@@ -97,7 +97,7 @@ player_st get_player(int x, int y) {
|
|
|
|
|
rect[2].x = 5; rect[2].y = 20; |
|
|
|
|
rect[3].x = -5; rect[3].y = 20; |
|
|
|
|
|
|
|
|
|
//set_motor_newtons(player.physics, M_GRAVITY, 0.0, player.physics->obj_mass * 5);
|
|
|
|
|
set_motor_newtons(player.physics, M_GRAVITY, 0.0, player.physics->obj_mass * 5); |
|
|
|
|
|
|
|
|
|
// walking motor
|
|
|
|
|
add_motor(player.physics, 0.0, player.physics->obj_mass * 9.81); |
|
|
|
@ -239,11 +239,8 @@ bool sat_collision_check(Body *one, Body *two) {
@@ -239,11 +239,8 @@ bool sat_collision_check(Body *one, Body *two) {
|
|
|
|
|
proj_one = project_col_poly(one, axes[i]); |
|
|
|
|
proj_two = project_col_poly(two, axes[i]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*if (!(proj_one[1] >= proj_two[1] && proj_one[0] <= proj_two[0]) */ |
|
|
|
|
/*&& !(proj_one[1] <= proj_two[1] && proj_one[0] >= proj_two[0])) {*/ |
|
|
|
|
if ((proj_one[1] >= proj_two[1] && proj_one[0] >= proj_two[1])
|
|
|
|
|
|| (proj_one[0] >= proj_two[1] && proj_one[1] >= proj_two[1])) { |
|
|
|
|
if ((proj_one[0] >= proj_two[1])
|
|
|
|
|
|| (proj_two[0] >= proj_one[1])) { |
|
|
|
|
printf("not overlapping\n"); |
|
|
|
|
free(axes); |
|
|
|
|
free(proj_one); |
|
|
|
@ -425,13 +422,17 @@ void advance_thing(Body * thing) {
@@ -425,13 +422,17 @@ void advance_thing(Body * thing) {
|
|
|
|
|
|
|
|
|
|
thing->updateCollisionPoly(thing); |
|
|
|
|
|
|
|
|
|
if (process_collisions(thing)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!thing->dynamics) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uint32_t time_delta = SDL_GetTicks() - thing->last_advance_time ; |
|
|
|
|
thing->last_advance_time = SDL_GetTicks(); // in milliseconds
|
|
|
|
|
time_delta = 17; |
|
|
|
|
//time_delta = 17;
|
|
|
|
|
|
|
|
|
|
// motors
|
|
|
|
|
for (int i = 0; i < thing->num_motors; i++) { |
|
|
|
@ -497,8 +498,6 @@ void advance_thing(Body * thing) {
@@ -497,8 +498,6 @@ void advance_thing(Body * thing) {
|
|
|
|
|
(*thing).y_vel = 0;
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int oldx = thing->x_pos; |
|
|
|
|
int oldy = thing->y_pos; |
|
|
|
|
(*thing).x_pos += (int)((*thing).x_vel * 1/2 * (float)time_delta);
|
|
|
|
@ -506,12 +505,12 @@ void advance_thing(Body * thing) {
@@ -506,12 +505,12 @@ void advance_thing(Body * thing) {
|
|
|
|
|
|
|
|
|
|
// revert if this caused collision
|
|
|
|
|
thing->updateCollisionPoly(thing); |
|
|
|
|
if (process_collisions(thing)) { |
|
|
|
|
/*if (process_collisions(thing)) {*/ |
|
|
|
|
/*thing->x_pos = oldx;*/ |
|
|
|
|
/*thing->y_pos = oldy;*/ |
|
|
|
|
thing->updateCollisionPoly(thing); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
/*thing->updateCollisionPoly(thing);*/ |
|
|
|
|
/*return;*/ |
|
|
|
|
/*}*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// wrap screen
|
|
|
|
|