Files
Super-Mario-Bros.-Remastere…/Scripts/Classes/Entities/Items/Hammer.gd
John Cooper McDonald 8474bc3c19 Properly implement the Hammer item (#599)
* Properly implement the Hammer item

* Update Boo.gd

* Update LongFirebar.tscn
2025-10-15 18:14:19 +01:00

26 lines
682 B
GDScript

class_name Hammer
extends Node2D
var velocity := Vector2(0, -200)
var direction := -1
func _ready() -> void:
$Sprite.flip_h = direction == 1
$Animations.speed_scale = -direction
velocity.x = 120 * direction
if Settings.file.audio.extra_sfx == 1:
AudioManager.play_sfx("hammer_throw", global_position)
func _physics_process(delta: float) -> void:
global_position += velocity * delta
velocity.y += (Global.entity_gravity / delta) * delta
velocity.y = clamp(velocity.y, -INF, Global.entity_max_fall_speed)
func flag_die() -> void:
queue_free()
func on_area_entered(area: Area2D) -> void:
if area.owner is Player and area.name != "HammerHitbox":
area.owner.damage()