Super-Mario-Bros-Remastered.../Scripts/Classes/Blocks/NoteBlock.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

70 lines
1.7 KiB
GDScript

class_name NoteBlock
extends Block
var bodies: Array[CharacterBody2D] = []
signal bounced
var animating := false
@export var play_sfx := true
func bounce_up() -> void:
if bouncing or animating:
return
bounced.emit()
bouncing = true
animating = true
%Animations.play("BounceUp")
dispense_item(-1)
await %Animations.animation_finished
bouncing = false
animating = false
func _physics_process(_delta: float) -> void:
for i in %Area.get_overlapping_areas():
if i.owner is CharacterBody2D:
bounce_down(i.owner)
func bounce_down(body: PhysicsBody2D) -> void:
if bouncing or animating:
return
animating = true
bounced.emit()
if play_sfx:
AudioManager.play_sfx("note_block", global_position)
bodies.append(body)
if body is Player:
body.normal_state.jump_queued = false
body.spring_bouncing = true
%Animations.play("BounceDown")
dispense_item(1)
await %Animations.animation_finished
animating = false
bouncing = false
func bounce_bodies() -> void:
for i in bodies:
if i is Player:
i.spring_bouncing = false
if Global.player_action_pressed("jump", i.player_id):
i.jump_cancelled = false
i.has_jumped = true
i.velocity.y = -350
i.gravity = i.calculate_speed_param("JUMP_GRAVITY")
else:
i.velocity.y = -300
i.gravity = i.calculate_speed_param("FALL_GRAVITY")
else:
i.velocity.y = -200
if i is Thwomp:
i.velocity = Vector2.ZERO
bodies.clear()
func dispense_item(direction := -1) -> void:
if item == null or item_amount <= 0:
return
item_amount -= 1
var node = item.instantiate()
node.global_position = global_position + Vector2(0, 8 * direction)
node.set("velocity", Vector2(0, (100 if direction == 1 else -150)))
add_sibling(node)
AudioManager.play_sfx("item_appear", global_position)