|
|
|
@ -36,8 +36,8 @@ player_st get_player(int x, int y) {
@@ -36,8 +36,8 @@ player_st get_player(int x, int y) {
|
|
|
|
|
|
|
|
|
|
player.max_walking_speed = 1001;
|
|
|
|
|
|
|
|
|
|
player.physics.glob_gravity = true; |
|
|
|
|
player.physics.glob_friction = 0.0; |
|
|
|
|
player.physics.glob_gravity = false; |
|
|
|
|
player.physics.glob_friction = 0.0000005; |
|
|
|
|
|
|
|
|
|
player.physics.obj_mass = 100; |
|
|
|
|
//kgs
|
|
|
|
@ -88,28 +88,42 @@ int advance_glob(physics_thing * thing) {
@@ -88,28 +88,42 @@ int advance_glob(physics_thing * thing) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((*thing).glob_friction != 0.0) { |
|
|
|
|
logwrite(DEBUG, "Friction\n"); |
|
|
|
|
/* god this is so jank */ |
|
|
|
|
float normal = (*thing).obj_mass * 9.81; |
|
|
|
|
float F_force = normal * (*thing).glob_friction; |
|
|
|
|
float dir = atan2((*thing).y_acc, (*thing).x_acc); |
|
|
|
|
float dir = atan2((*thing).y_vel, (*thing).x_vel); |
|
|
|
|
|
|
|
|
|
dir += M_PI; |
|
|
|
|
|
|
|
|
|
float f_x = (float)(cos((double)dir)) * F_force; |
|
|
|
|
float f_y = (float)(sin((double)dir)) * F_force; |
|
|
|
|
|
|
|
|
|
if (abs((*thing).x_acc ) <= abs(f_x)) { |
|
|
|
|
(*thing).x_acc = 0; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
|
|
|
|
|
printf("Friction %f, %f", f_x, f_y); |
|
|
|
|
|
|
|
|
|
if (fabs((*thing).x_vel) > 0.0000001) { |
|
|
|
|
(*thing).x_acc += f_x; |
|
|
|
|
} |
|
|
|
|
if (abs((*thing).y_acc) <= abs(f_y)) { |
|
|
|
|
(*thing).y_acc = 0; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
|
|
|
|
|
if (fabs((*thing).y_vel) > 0.0000001) { |
|
|
|
|
(*thing).y_acc += f_y; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* if (fabs((*thing).x_acc ) < fabs(f_x)) { |
|
|
|
|
* (*thing).x_acc = 0; |
|
|
|
|
* } |
|
|
|
|
* else { |
|
|
|
|
* (*thing).x_acc += f_x; |
|
|
|
|
* } |
|
|
|
|
* if (fabs((*thing).y_acc) < fabs(f_y)) { |
|
|
|
|
* (*thing).y_acc = 0; |
|
|
|
|
* |
|
|
|
|
* } |
|
|
|
|
* else { |
|
|
|
|
* (*thing).y_acc += f_y; |
|
|
|
|
* } |
|
|
|
|
*/ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -120,7 +134,6 @@ void advance_thing(physics_thing * thing) {
@@ -120,7 +134,6 @@ void advance_thing(physics_thing * thing) {
|
|
|
|
|
|
|
|
|
|
(*thing).x_acc = 0; |
|
|
|
|
(*thing).y_acc = 0; |
|
|
|
|
advance_glob(thing); |
|
|
|
|
|
|
|
|
|
static uint32_t last_advance_time; |
|
|
|
|
|
|
|
|
@ -134,6 +147,7 @@ void advance_thing(physics_thing * thing) {
@@ -134,6 +147,7 @@ void advance_thing(physics_thing * thing) {
|
|
|
|
|
float motor_y = (float)(*thing).motor_y / (float)(*thing).obj_mass ; |
|
|
|
|
|
|
|
|
|
accel_thing(thing, motor_x, motor_y); |
|
|
|
|
advance_glob(thing); |
|
|
|
|
|
|
|
|
|
// accelerate based on accel
|
|
|
|
|
|
|
|
|
@ -147,6 +161,15 @@ void advance_thing(physics_thing * thing) {
@@ -147,6 +161,15 @@ void advance_thing(physics_thing * thing) {
|
|
|
|
|
printf("player position: %d, %d \n", (*thing).x_pos, (*thing).y_pos ); |
|
|
|
|
printf("player acc: %f, %f \n", (*thing).x_acc, (*thing).y_acc); |
|
|
|
|
|
|
|
|
|
if (fabs((*thing).x_vel) < 0.00001) { |
|
|
|
|
(*thing).x_vel = 0;
|
|
|
|
|
} |
|
|
|
|
if (fabs((*thing).y_vel) < 0.00001) { |
|
|
|
|
(*thing).y_vel = 0;
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// apply global forces
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|