mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-23 07:58:09 +00:00
Merge branch 'main' into custom-level-loading-rewrite
This commit is contained in:
@@ -14,6 +14,10 @@ func die() -> void:
|
||||
|
||||
func die_from_object(_node: Node2D) -> void:
|
||||
destroy()
|
||||
|
||||
func die_from_hammer(_node: Node2D) -> void:
|
||||
AudioManager.play_sfx("hammer_hit", global_position)
|
||||
destroy()
|
||||
|
||||
func summon_particle() -> void:
|
||||
var node = BARREL_DESTRUCTION_PARTICLE.instantiate()
|
||||
|
@@ -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:
|
||||
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:
|
||||
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:
|
||||
area.owner.damage()
|
||||
$Sprite.scale.x = -direction
|
||||
|
||||
func play_sfx() -> void:
|
||||
AudioManager.play_sfx("bowser_flame", global_position)
|
||||
|
@@ -53,3 +53,8 @@ func flag_die() -> void:
|
||||
func die() -> void:
|
||||
killed.emit()
|
||||
queue_free()
|
||||
|
||||
func die_from_hammer() -> void:
|
||||
AudioManager.play_sfx("hammer_hit", global_position)
|
||||
killed.emit()
|
||||
queue_free()
|
||||
|
@@ -37,3 +37,12 @@ func flag_die() -> void:
|
||||
Global.score += 500
|
||||
if score_note_adder != null:
|
||||
score_note_adder.spawn_note(500)
|
||||
|
||||
func die_from_hammer(obj: Node2D) -> void:
|
||||
var dir = sign(global_position.x - obj.global_position.x)
|
||||
if dir == 0:
|
||||
dir = [-1, 1].pick_random()
|
||||
DiscoLevel.combo_amount += 1
|
||||
AudioManager.play_sfx("hammer_hit", global_position)
|
||||
killed.emit(dir)
|
||||
queue_free()
|
||||
|
@@ -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
|
||||
|
@@ -24,8 +24,8 @@ func collect() -> void:
|
||||
$Sprite.queue_free()
|
||||
else:
|
||||
queue_free()
|
||||
if get_parent() is TileMapLayer:
|
||||
get_parent().erase_cell(get_parent().local_to_map(position))
|
||||
if get_parent() is TileMapLayer:
|
||||
get_parent().erase_cell(get_parent().local_to_map(position))
|
||||
|
||||
func summon_block_coin() -> void:
|
||||
var node = spinning_coin_scene.instantiate()
|
||||
|
@@ -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:
|
||||
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")
|
||||
|
@@ -24,6 +24,7 @@ func explode() -> void:
|
||||
|
||||
func kick(object: Node2D) -> void:
|
||||
AudioManager.play_sfx("kick", global_position)
|
||||
object.kick_anim()
|
||||
var kick_dir = sign(global_position.x - object.global_position.x)
|
||||
velocity.x = 150 * kick_dir
|
||||
direction = kick_dir
|
||||
|
@@ -10,9 +10,9 @@ func do_cycle() -> void:
|
||||
AudioManager.play_sfx("burner", global_position)
|
||||
do_animation()
|
||||
await get_tree().create_timer(0.25, false).timeout
|
||||
%Hitbox.set_deferred("disabled", false)
|
||||
%Shape.set_deferred("disabled", false)
|
||||
await get_tree().create_timer(1.5, false).timeout
|
||||
%Hitbox.set_deferred("disabled", true)
|
||||
%Shape.set_deferred("disabled", true)
|
||||
$Timer.start()
|
||||
|
||||
func do_animation() -> void:
|
||||
|
@@ -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:
|
||||
area.owner.damage()
|
||||
|
@@ -43,7 +43,7 @@ func on_area_entered(area: Area2D) -> void:
|
||||
if area.owner.has_node("ShellDetection"):
|
||||
area.owner.die_from_object(self)
|
||||
elif area.owner is Player:
|
||||
if area.owner.is_invincible:
|
||||
if area.owner.is_invincible or area.name == "HammerHitbox":
|
||||
destroy()
|
||||
else:
|
||||
area.owner.damage()
|
||||
|
@@ -64,14 +64,17 @@ func update_visuals() -> void:
|
||||
hide()
|
||||
|
||||
func exit_pipe() -> void:
|
||||
can_enter = false
|
||||
pipe_exited.emit()
|
||||
await get_tree().physics_frame
|
||||
for i in get_tree().get_nodes_in_group("Players"):
|
||||
if i.is_node_ready() == false:
|
||||
await i.ready
|
||||
i.go_to_exit_pipe(self)
|
||||
for i in get_tree().get_nodes_in_group("Players"):
|
||||
await get_tree().create_timer(0.5, false).timeout
|
||||
await i.exit_pipe(self)
|
||||
exiting_pipe_id = -1
|
||||
can_enter = true
|
||||
|
||||
func get_vector(direction := 0) -> Vector2:
|
||||
match direction:
|
||||
|
@@ -52,6 +52,7 @@ var input_direction := 0
|
||||
var flight_meter := 0.0
|
||||
|
||||
var velocity_direction := 1
|
||||
var velocity_x_jump_stored := 0
|
||||
|
||||
var total_keys := 0
|
||||
|
||||
@@ -74,6 +75,9 @@ var can_bump_crouch = false
|
||||
var can_bump_swim = false
|
||||
var can_bump_fly = false
|
||||
|
||||
var kicking = false
|
||||
var can_kick_anim = false
|
||||
|
||||
@export var player_id := 0
|
||||
const ONE_UP_NOTE = preload("uid://dopxwjj37gu0l")
|
||||
var gravity := FALL_GRAVITY
|
||||
@@ -146,31 +150,39 @@ const ANIMATION_FALLBACKS := {
|
||||
"Pipe": "Idle",
|
||||
"Walk": "Move",
|
||||
"Run": "Move",
|
||||
"PipeWalk": "Move",
|
||||
"PipeWalk": "Walk",
|
||||
"LookUp": "Idle",
|
||||
"WaterLookUp": "LookUp",
|
||||
"WingLookUp": "WaterLookUp",
|
||||
"Crouch": "Idle",
|
||||
"WaterCrouch": "Crouch",
|
||||
"WingCrouch": "WaterCrouch",
|
||||
"CrouchFall": "Crouch",
|
||||
"CrouchJump": "Crouch",
|
||||
"CrouchBump": "Bump",
|
||||
"CrouchMove": "Crouch",
|
||||
"IdleAttack": "Attack",
|
||||
"IdleAttack": "MoveAttack",
|
||||
"CrouchAttack": "IdleAttack",
|
||||
"MoveAttack": "IdleAttack",
|
||||
"MoveAttack": "Attack",
|
||||
"WalkAttack": "MoveAttack",
|
||||
"RunAttack": "MoveAttack",
|
||||
"SkidAttack": "MoveAttack",
|
||||
"FlyIdle": "SwimIdle",
|
||||
"WingIdle": "WaterIdle",
|
||||
"FlyUp": "SwimUp",
|
||||
"FlyMove": "SwimMove",
|
||||
"WingMove": "WaterMove",
|
||||
"FlyAttack": "SwimAttack",
|
||||
"FlyBump": "SwimBump",
|
||||
"FlagSlide": "Climb",
|
||||
"WaterMove": "Move",
|
||||
"WaterIdle": "Idle",
|
||||
"FlyIdle": "SwimIdle",
|
||||
"SwimBump": "Bump",
|
||||
"DieFreeze": "Die",
|
||||
"RunJump": "Jump",
|
||||
"RunJumpFall": "JumpFall",
|
||||
"RunJumpBump": "JumpBump",
|
||||
"StarJump": "Jump",
|
||||
"StarFall": "StarJump"
|
||||
"StarFall": "JumpFall"
|
||||
}
|
||||
|
||||
var palette_transform := true
|
||||
@@ -270,6 +282,7 @@ func _physics_process(delta: float) -> void:
|
||||
set_power_state_frame()
|
||||
if Input.is_action_just_pressed("debug_noclip") and Global.debug_mode:
|
||||
state_machine.transition_to("NoClip")
|
||||
Global.log_comment("NOCLIP Enabled")
|
||||
up_direction = -gravity_vector
|
||||
handle_directions()
|
||||
handle_block_collision_detection()
|
||||
@@ -317,6 +330,7 @@ func _process(delta: float) -> void:
|
||||
if is_invincible:
|
||||
DiscoLevel.combo_meter = 100
|
||||
%Hammer.visible = has_hammer
|
||||
%HammerHitbox.collision_layer = has_hammer
|
||||
|
||||
func apply_gravity(delta: float) -> void:
|
||||
if in_water or flight_meter > 0:
|
||||
@@ -448,6 +462,11 @@ func bump_ceiling() -> void:
|
||||
await get_tree().create_timer(0.1).timeout
|
||||
bumping = false
|
||||
|
||||
func kick_anim() -> void:
|
||||
kicking = true
|
||||
await get_tree().create_timer(0.2).timeout
|
||||
kicking = false
|
||||
|
||||
func super_star() -> void:
|
||||
DiscoLevel.combo_meter += 1
|
||||
is_invincible = true
|
||||
@@ -670,6 +689,7 @@ func set_power_state_frame() -> void:
|
||||
can_bump_crouch = %Sprite.sprite_frames.has_animation("CrouchBump")
|
||||
can_bump_swim = %Sprite.sprite_frames.has_animation("SwimBump")
|
||||
can_bump_fly = %Sprite.sprite_frames.has_animation("FlyBump")
|
||||
can_kick_anim = %Sprite.sprite_frames.has_animation("Kick")
|
||||
|
||||
func get_power_up(power_name := "") -> void:
|
||||
if is_dead:
|
||||
@@ -796,7 +816,7 @@ func hide_pipe_animation() -> void:
|
||||
func go_to_exit_pipe(pipe: PipeArea) -> void:
|
||||
Global.can_time_tick = false
|
||||
pipe_enter_direction = Vector2.ZERO
|
||||
state_machine.transition_to("Pipe")
|
||||
state_machine.transition_to("Freeze")
|
||||
global_position = pipe.global_position + (pipe.get_vector(pipe.enter_direction) * 32)
|
||||
if pipe.enter_direction == 1:
|
||||
global_position = pipe.global_position + Vector2(0, -8)
|
||||
@@ -821,6 +841,7 @@ func jump() -> void:
|
||||
if spring_bouncing:
|
||||
return
|
||||
velocity.y = calculate_jump_height() * gravity_vector.y
|
||||
velocity_x_jump_stored = velocity.x
|
||||
gravity = JUMP_GRAVITY
|
||||
AudioManager.play_sfx("small_jump" if power_state.hitbox_size == "Small" else "big_jump", global_position)
|
||||
has_jumped = true
|
||||
@@ -873,9 +894,6 @@ func hammer_get() -> void:
|
||||
$HammerTimer.start()
|
||||
AudioManager.set_music_override(AudioManager.MUSIC_OVERRIDES.HAMMER, 0, false)
|
||||
|
||||
func on_hammer_area_entered(area: Area2D) -> void:
|
||||
pass
|
||||
|
||||
func wing_get() -> void:
|
||||
AudioManager.set_music_override(AudioManager.MUSIC_OVERRIDES.WING, 0, false, false)
|
||||
flight_meter = 10
|
||||
|
@@ -94,6 +94,7 @@ func kick(hit_player: Player) -> void:
|
||||
DiscoLevel.combo_meter += 25
|
||||
moving = true
|
||||
moving_time = 0.0
|
||||
hit_player.kick_anim()
|
||||
if can_air_kick:
|
||||
$ScoreNoteSpawner.spawn_note(8000)
|
||||
else:
|
||||
|
Reference in New Issue
Block a user