mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-22 15:38:14 +00:00
26 lines
682 B
GDScript
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()
|