Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backwheel drive #97

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public class game_state
private Vector wheel_back_position = new Vector(0, 0);

public bool is_touching_ground = false;

public bool back_wheel_is_touching_ground = false;

public double acceleration = 0.1;
public double deceleration = 0.07;
Expand Down Expand Up @@ -368,7 +368,7 @@ private static void forward_movement(game_state game_State)
{
Vector rel_movement = helper.abs_movement_rel_movement(game_State.car_velocity_abs, game_State.actual_rotation);

if (rel_movement.X < game_State.max_speed)
if (rel_movement.X < game_State.max_speed &&game_State.back_wheel_is_touching_ground)
{
rel_movement.X += Math.Cos(helper.degree_to_rad(game_State.actual_rotation - 25)) * 1.2 * game_State.acceleration;

Expand All @@ -379,7 +379,7 @@ private static void backward_movement(game_state game_State)
{
Vector rel_movement = helper.abs_movement_rel_movement(game_State.car_velocity_abs, game_State.actual_rotation);

if (rel_movement.X > -game_State.max_speed)
if (rel_movement.X > -game_State.max_speed && game_State.back_wheel_is_touching_ground)
{
rel_movement.X -= Math.Cos(helper.degree_to_rad(game_State.actual_rotation+25))*1.2 * game_State.acceleration;
}
Expand Down Expand Up @@ -596,12 +596,22 @@ public static void movement(game_state game_State, Game_objects game_objects)

double collision_depth_front = collision_depth(game_objects, game_objects.wheel_front, game_State);
double collision_depth_back = collision_depth(game_objects, game_objects.wheel_back, game_State);
if (collision_depth_front > 0 || collision_depth_back >0)
if (collision_depth_front > -8 || collision_depth_back > -8)
{
game_State.back_wheel_is_touching_ground = true;

}
else game_State.back_wheel_is_touching_ground = false;

if (collision_depth_front > 0 || collision_depth_back >0)
{
game_State.is_touching_ground = true ;
bool front_or_back;
game_State.is_touching_ground = true;
double collision_depth_other =0;
double largest_collision_depth;
if (collision_depth_back > 0)
{
}
if (collision_depth_front >= collision_depth_back)
{
largest_collision_depth=collision_depth_front;
Expand All @@ -619,7 +629,8 @@ public static void movement(game_state game_State, Game_objects game_objects)
solve_collision(game_State, game_objects, largest_collision_depth, front_or_back, collision_depth_other);
}else
{
game_State.is_touching_ground=false ;
game_State.is_touching_ground=false;
//game_State.back_wheel_is_touching_ground = false;
}


Expand Down