Super-Mario-Bros-Remastered.../Scripts/Classes/Entities/Objects/Trampoline.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

42 lines
1.3 KiB
GDScript

extends AnimatableBody2D
@export var trampoline_type := "TRAMPOLINE"
var players := []
func on_area_entered(area: Area2D) -> void:
pass
func _physics_process(_delta: float) -> void:
for i in $Hitbox.get_overlapping_areas():
if i.owner is Player and i.owner.is_on_floor():
if i.owner.spring_bouncing or i.owner.velocity.y < 0:
continue
i.owner.velocity.x = 0
if players.has(i.owner) == false:
players.append(i.owner)
$Animation.play("Bounce")
i.owner.spring_bouncing = true
for i in players:
i.global_position.y = $PlayerCollision/PlayerJoint.global_position.y
func bounce_players() -> void:
var high_bounce := false
for player in players:
if Global.player_action_pressed("jump", player.player_id):
high_bounce = true
player.velocity.y = -player.physics_params(trampoline_type + "_SPEED")
player.gravity = player.calculate_speed_param("JUMP_GRAVITY")
player.has_jumped = true
player.has_spring_jumped = true
else:
player.velocity.y = -player.calculate_speed_param("JUMP_SPEED")
if high_bounce:
AudioManager.play_sfx("spring", global_position)
else:
AudioManager.play_sfx("bump", global_position)
players.clear()
func on_area_exited(area: Area2D) -> void:
if area.owner is Player:
area.owner.spring_bouncing = false