Super-Mario-Bros-Remastered.../Scripts/Classes/Entities/Objects/Bumper.gd
SkyanUltra 17a4e04766 Classic physics implemented, more params + tweaks
A big thank you to @jdaster64 and @DeadSyntaxdev for their work on the previous classic physics PRs, as without them I would not have been able to pull the values used in those PRs and recreate them at all.
- Implements CLASSIC_PARAMETERS, an alternate set of parameters to PHYSICS_PARAMETERS which is utilized based on your current Physics Behavior setting.
  - The values used in CLASSIC_PARAMETERS were lifted from #646, but they may need more tweaking.
- Implements a setting under Difficulty for Physics Behavior, with options for Modern and Classic (the default being modern)
- Many, many new physics parameters.
  - Jump Speed, Jump Gravity and Fall Gravity are all split up into Idle, Walk and Run variants based on your current speed.
    - Those thresholds have their own parameters, being "Jump Walk/Run Threshold"
  - Implemented "Classic Bounce Behavior" which replicates the original SMB's bounce mechanics when active, disabling the ability to bounce higher on enemies unless you have upwards velocity.
  - Implemented "Skid Stop Threshold", used for determining when the game considers your velocity low enough to stop you from skidding.
  - Implemented "Can Instant Stop Skid", which implements the classic SMB behavior of setting your velocity to 0 if the player's speed is low enough while skidding (determined by Skid Stop Threshold)
  - Implemented "Lock Air Accel", which implements the classic SMB behavior that prevents the player from surpassing walking speed while in the air when enabled (unless they're jumping off of a trampoline)
  - Split up "Air Accel" into "Air Walk/Run Accel", which do exactly what they sound like they do.
  - Implemented "Can Backwards Accel Run", which when disabled implements the classic SMB behavior of using your air walk acceleration at running speed while backwards accelerating.
  - Implemented "Air Backwards Accel Mult" which controls a multiplier linked to your acceleration while moving backwards, which is ported behavior from classic SMB.
  - Split up "Climb Speed" into variants for "Climb Up/Down Speed" which work exactly how you think they do. (Note: Climbing down in the original SMB is far faster, which is why this is here. I tried my best to eyeball the speed, change it however you want, though.)
  - Implemented "Swim Decel" which does exactly what it sounds like it does.
- Renamed a few parameters to be more accurate (namely "Bounce Height" to "Bounce Speed", "Power State Range" to "Power Tier Range", etc.
- New projectile parameters.
  - Rework of the "destroy on hit" param into its own "pierce count" parameter against enemies, with negative values serving as infinite pierce.
  - New hitrate parameter, to grant piercing projectiles a cooldown rate to hit the same enemy multiple times (i.e. SMB3 Hammer Suit hammers,) with negative values serving as original behavior to only hit an enemy once in its area.
  - New move speed cap parameter, which lets you set a minimum and maximum speed a projectile can travel horizontally.
  - New bounce count parameter, to set a maximum bounce count to prevent a projectile from sticking around for too long.
  - Removed folder limitation on projectile/particle file pathing. Go wild.

(Also, commented a debug print in AudioManager.)
2025-11-22 08:22:48 -05:00

38 lines
1.3 KiB
GDScript

extends Node2D
const LOW_STRENGTH := -300
const HIGH_STRENGTH := -450
func bounce_player(player: Player) -> void:
$Sprite.play("Bounce")
$AnimationPlayer.stop()
if player.global_position.y + 8 < global_position.y:
player.velocity.x *= 0.8
if Global.player_action_pressed("jump", player.player_id):
player.gravity = player.calculate_speed_param("JUMP_GRAVITY")
player.jump_cancelled = false
player.velocity.y = HIGH_STRENGTH
player.has_jumped = true
AudioManager.play_sfx("bumper_high", global_position)
else:
AudioManager.play_sfx("bumper", global_position)
player.velocity.y = LOW_STRENGTH
else:
player.velocity = global_position.direction_to(player.global_position) * 200
if Global.player_action_pressed("jump", player.player_id):
player.gravity = player.calculate_speed_param("JUMP_GRAVITY")
player.velocity.y = LOW_STRENGTH
player.has_jumped = true
AudioManager.play_sfx("bumper_high", global_position)
else:
AudioManager.play_sfx("bumper", global_position)
refresh_hitbox()
$AnimationPlayer.play("Bounce")
await $AnimationPlayer.animation_finished
$Sprite.play("Idle")
func refresh_hitbox() -> void:
$PlayerDetection/CollisionShape2D.set_deferred("disabled", true)
await get_tree().physics_frame
$PlayerDetection/CollisionShape2D.set_deferred("disabled", false)