diff --git a/src/Actors/Actor.gd b/src/Actors/Actor.gd index 51e161e..b2f3c64 100644 --- a/src/Actors/Actor.gd +++ b/src/Actors/Actor.gd @@ -26,9 +26,11 @@ var max_velocity := { "fall": Vector2(120, 420), "walljump": 200, "idle": 12000, - "duck": 160, - "duck_walk": 160 + "duck": 165, + "duck_walk": 165 } +# x is applied directly to velocity and y is multiplied with acceleration +var duck_boost = Vector2(2.5, 0.75) var velocity_jump_boost_ratio := 10 # This is added to the acceleration force initially var init_acceleration_force := {"": 0, "idle_walk": 4181, "idle_run": 5765, "walk_run": 1000} diff --git a/src/Actors/Blobby/Blobby.gd b/src/Actors/Blobby/Blobby.gd index c4b173a..44f31eb 100644 --- a/src/Actors/Blobby/Blobby.gd +++ b/src/Actors/Blobby/Blobby.gd @@ -20,6 +20,7 @@ onready var init_boost_type = player_state_machine.init_boost_type var wall_touch_direction = 1 var stomping = false +var duck_jumping = false var floor_angle = Vector2(0, 0) var previous_rotation = 0 var snap_possible = true @@ -251,10 +252,17 @@ func calculate_jump_velocity(linear_velocity: Vector2, delta: float, direction: if stomping: additive_jump_force += calculate_stomp_velocity(delta) + var y_acceleration_force = acceleration_force[state].y + var x_acceleration_force = acceleration_force[state].x + + if duck_jumping: + y_acceleration_force *= duck_boost.y + linear_velocity.x += duck_boost.x * direction.x + if state != "jump": linear_velocity.y = PhysicsFunc.two_step_euler( linear_velocity.y, - (acceleration_force[state].y / delta + additive_jump_force) * -1, + (y_acceleration_force / delta + additive_jump_force) * -1, mass, delta ) @@ -281,7 +289,7 @@ func calculate_jump_velocity(linear_velocity: Vector2, delta: float, direction: var movement_factor = absolut + abs(velocity.x) / (max_velocity["fall"].x * divisor) linear_velocity.x = PhysicsFunc.two_step_euler( linear_velocity.x, - acceleration_force[state].x * movement_factor * direction.x, + x_acceleration_force * movement_factor * direction.x, mass, delta ) diff --git a/src/StateMachines/BlobbyStateMachine.gd b/src/StateMachines/BlobbyStateMachine.gd index 958979c..ce93d2a 100644 --- a/src/StateMachines/BlobbyStateMachine.gd +++ b/src/StateMachines/BlobbyStateMachine.gd @@ -217,6 +217,12 @@ func _enter_state(new_state, old_state): if new_state == "run": running_particles.emitting = true + + if new_state == "duck" || new_state == "duck_walk": + parent.duck_jumping = true + + if new_state == "wallslide": + parent.duck_jumping = false if new_state == "jump": jump_point_particles.position.x = 0 if facing == 1 else 24 @@ -224,6 +230,8 @@ func _enter_state(new_state, old_state): jump_point_particles.restart() if !["run", "walk", "idle", "duck"].has(old_state) && parent.is_on_floor(): + if(new_state != "duck" && new_state != "duck_walk"): + parent.duck_jumping = false emit_signal("got_grounded") match new_state: