mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-22 07:28:14 +00:00
Update hitboxes for consistency (#608)
Co-authored-by: Joe H <97353363+JHDev2006@users.noreply.github.com>
This commit is contained in:

committed by
GitHub

parent
ed297891fd
commit
9a17f140e0
@@ -1,20 +1,14 @@
|
||||
extends Node2D
|
||||
extends Enemy
|
||||
|
||||
var target_player: Player = null
|
||||
|
||||
var velocity := Vector2.ZERO
|
||||
|
||||
const MOVE_SPEED := 30
|
||||
const SMOKE_PARTICLE = preload("uid://d08nv4qtfouv1")
|
||||
var direction := -1
|
||||
|
||||
signal killed
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
target_player = get_tree().get_first_node_in_group("Players")
|
||||
if $TrackJoint.is_attached == false:
|
||||
handle_movement(delta)
|
||||
$Sprite.scale.x = direction
|
||||
$Sprite.scale.x = -direction
|
||||
|
||||
func handle_movement(delta: float) -> void:
|
||||
var target_direction = sign(target_player.global_position.x - global_position.x)
|
||||
@@ -30,22 +24,6 @@ func handle_movement(delta: float) -> void:
|
||||
velocity = lerp(velocity, Vector2.ZERO, delta * 5)
|
||||
global_position += velocity * delta
|
||||
|
||||
|
||||
func on_area_entered(area: Area2D) -> void:
|
||||
if area.owner is Player:
|
||||
if area.owner.is_invincible or area.name == "HammerHitbox":
|
||||
die()
|
||||
else:
|
||||
area.owner.damage()
|
||||
|
||||
func die() -> void:
|
||||
summon_smoke_particle()
|
||||
queue_free()
|
||||
killed.emit()
|
||||
|
||||
func flag_die() -> void:
|
||||
die()
|
||||
|
||||
func summon_smoke_particle() -> void:
|
||||
var particle = SMOKE_PARTICLE.instantiate()
|
||||
particle.global_position = global_position
|
||||
|
@@ -1,7 +1,6 @@
|
||||
extends Node2D
|
||||
extends Enemy
|
||||
|
||||
@export_range(25, 180) var length := 80
|
||||
@export_enum("Clockwise", "C-Clockwise") var direction := 0
|
||||
@export_range(4, 12) var boo_amount := 10
|
||||
@export var spread_boos := false
|
||||
|
||||
@@ -9,10 +8,3 @@ func _physics_process(delta: float) -> void:
|
||||
%RotationJoint.global_rotation_degrees = wrap(%RotationJoint.global_rotation_degrees + (45 * [1, -1][direction]) * delta, 0, 360)
|
||||
for i in $Boos.get_children():
|
||||
i.get_node("Sprite").scale.x = sign(get_tree().get_first_node_in_group("Players").global_position.x + 1 - i.global_position.x)
|
||||
|
||||
func on_area_entered(area: Area2D) -> void:
|
||||
if area.owner is Player and area.name != "HammerHitbox":
|
||||
area.owner.damage()
|
||||
|
||||
func flag_die() -> void:
|
||||
queue_free()
|
||||
|
@@ -1,10 +1,9 @@
|
||||
class_name BowserFlame
|
||||
extends Node2D
|
||||
extends Enemy
|
||||
|
||||
@export_enum("Straight", "Aimed") var mode := 0
|
||||
|
||||
var target_y := 0
|
||||
var direction := -1
|
||||
|
||||
func _ready() -> void:
|
||||
pass
|
||||
@@ -16,14 +15,7 @@ func movement(delta: float) -> void:
|
||||
if mode == 1:
|
||||
global_position.y = move_toward(global_position.y, target_y, delta * 50)
|
||||
global_position.x += (100 * direction) * delta
|
||||
$Sprite.scale.x = direction
|
||||
|
||||
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()
|
||||
$Sprite.scale.x = -direction
|
||||
|
||||
func play_sfx() -> void:
|
||||
AudioManager.play_sfx("bowser_flame", global_position)
|
||||
|
@@ -1,7 +1,8 @@
|
||||
extends PowerUpItem
|
||||
|
||||
func collect_item(_player: Player) -> void:
|
||||
AudioManager.play_sfx("clock_get", global_position)
|
||||
$Label/AnimationPlayer.play("Appear")
|
||||
Global.time = clamp(Global.time + 100, 0, 999)
|
||||
Global.score += 1000
|
||||
func on_area_entered(area: Area2D) -> void:
|
||||
if area.owner is Player:
|
||||
AudioManager.play_sfx("clock_get", global_position)
|
||||
$Label/AnimationPlayer.play("Appear")
|
||||
Global.time = clamp(Global.time + 100, 0, 999)
|
||||
Global.score += 1000
|
||||
|
@@ -1,4 +1,8 @@
|
||||
extends PowerUpItem
|
||||
|
||||
func play_sfx() -> void:
|
||||
AudioManager.play_sfx("hachisuke", global_position)
|
||||
func on_area_entered(area: Area2D) -> void:
|
||||
if area.owner is Player:
|
||||
AudioManager.play_sfx("hachisuke", global_position)
|
||||
Global.score += 8000
|
||||
$ScoreNoteSpawner.spawn_note(8000)
|
||||
queue_free()
|
||||
|
@@ -1,11 +1,8 @@
|
||||
class_name Hammer
|
||||
extends Node2D
|
||||
|
||||
var velocity := Vector2(0, -200)
|
||||
|
||||
var direction := -1
|
||||
extends Enemy
|
||||
|
||||
func _ready() -> void:
|
||||
velocity = Vector2(0, -200)
|
||||
$Sprite.flip_h = direction == 1
|
||||
$Animations.speed_scale = -direction
|
||||
velocity.x = 120 * direction
|
||||
@@ -16,10 +13,3 @@ 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()
|
||||
|
@@ -1,8 +1,6 @@
|
||||
extends PowerUpItem
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func on_player_entered(player: Player) -> void:
|
||||
player.hammer_get()
|
||||
queue_free()
|
||||
func on_area_entered(area: Area2D) -> void:
|
||||
if area.owner is Player:
|
||||
area.owner.hammer_get()
|
||||
queue_free()
|
||||
|
@@ -6,11 +6,12 @@ const SMOKE_PARTICLE = preload("uid://d08nv4qtfouv1")
|
||||
func _ready() -> void:
|
||||
$AnimationPlayer.play("Float")
|
||||
|
||||
func collected() -> void:
|
||||
total_collected += 1
|
||||
AudioManager.play_sfx("key_collect", global_position)
|
||||
summon_smoke_particle()
|
||||
queue_free()
|
||||
func on_area_entered(area: Area2D) -> void:
|
||||
if area.owner is Player:
|
||||
total_collected += 1
|
||||
AudioManager.play_sfx("key_collect", global_position)
|
||||
summon_smoke_particle()
|
||||
queue_free()
|
||||
|
||||
func summon_smoke_particle() -> void:
|
||||
var node = SMOKE_PARTICLE.instantiate()
|
||||
|
@@ -14,8 +14,9 @@ func _ready() -> void:
|
||||
$Sprite.play("Collected")
|
||||
set_visibility_layer_bit(0, false)
|
||||
|
||||
func on_player_entered(_player: Player) -> void:
|
||||
collected()
|
||||
func on_area_entered(area: Area2D) -> void:
|
||||
if area.owner is Player:
|
||||
collected()
|
||||
|
||||
func collected() -> void:
|
||||
if already_collected:
|
||||
|
@@ -72,6 +72,6 @@ func on_player_entered(_player: Player) -> void:
|
||||
|
||||
|
||||
func on_area_exited(area: Area2D) -> void:
|
||||
if area.owner is Player:
|
||||
if area.owner is Player and area.name != "HammerHitbox":
|
||||
if area.owner.state_machine.state.name == "Climb":
|
||||
area.owner.state_machine.transition_to("Normal")
|
||||
|
@@ -1,18 +1,9 @@
|
||||
class_name Explosion
|
||||
extends Node2D
|
||||
extends Enemy
|
||||
|
||||
const destructable_tiles := {Vector2i(4, 0): Rect2(32, 160, 16, 16), Vector2i(4, 2): Rect2(48, 160, 16, 16)}
|
||||
const BLOCK_DESTRUCTION_PARTICLES = preload("uid://cyw7kk1em8h16")
|
||||
|
||||
|
||||
func on_body_entered(body: Node2D) -> void:
|
||||
if body is Block:
|
||||
if body.destructable: body.destroy()
|
||||
if body is Player:
|
||||
body.damage()
|
||||
|
||||
|
||||
|
||||
func on_area_entered(area: Area2D) -> void:
|
||||
if area.owner is Player and area.name != "HammerHitbox":
|
||||
area.owner.damage()
|
||||
|
Reference in New Issue
Block a user