mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-22 15:38:14 +00:00
Merge remote-tracking branch 'upstream/main' into pulls/small-crouch-hitbox-fix
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
@icon("res://Assets/Sprites/Editor/Block.png")
|
||||
@icon("res://Assets/Sprites/Editor/Block.svg")
|
||||
class_name Block
|
||||
extends AnimatableBody2D
|
||||
signal player_block_hit(player: Player)
|
||||
|
@@ -11,11 +11,9 @@ signal sprites_updated
|
||||
|
||||
static var cache := {}
|
||||
|
||||
func _enter_tree() -> void:
|
||||
func _ready() -> void:
|
||||
Global.level_theme_changed.connect(update_sprites)
|
||||
Global.level_time_changed.connect(update_sprites)
|
||||
|
||||
func _ready() -> void:
|
||||
update_sprites()
|
||||
|
||||
func update_sprites() -> void:
|
||||
|
@@ -18,7 +18,7 @@ static var property_cache := {}
|
||||
|
||||
var current_json_path := ""
|
||||
|
||||
static var state := [0, 0]
|
||||
static var state := [0, 0, 0]
|
||||
|
||||
static var pack_configs := {}
|
||||
|
||||
@@ -36,31 +36,33 @@ var update_on_spawn := true
|
||||
func _init() -> void:
|
||||
set_process_mode(Node.PROCESS_MODE_ALWAYS)
|
||||
|
||||
func _ready() -> void:
|
||||
Global.level_time_changed.connect(update_resource)
|
||||
Global.level_theme_changed.connect(update_resource)
|
||||
|
||||
func _enter_tree() -> void:
|
||||
safety_check()
|
||||
if update_on_spawn:
|
||||
update_resource()
|
||||
Global.level_time_changed.connect(update_resource)
|
||||
Global.level_theme_changed.connect(update_resource)
|
||||
|
||||
|
||||
func safety_check() -> void:
|
||||
if Settings.file.visuals.resource_packs.has("BaseAssets") == false:
|
||||
Settings.file.visuals.resource_packs.append("BaseAssets")
|
||||
if Settings.file.visuals.resource_packs.has(Global.ROM_PACK_NAME) == false:
|
||||
Settings.file.visuals.resource_packs.insert(Global.ROM_PACK_NAME, 0)
|
||||
|
||||
func update_resource() -> void:
|
||||
randomize()
|
||||
if is_inside_tree() == false or is_queued_for_deletion() or resource_json == null or node_to_affect == null:
|
||||
return
|
||||
if state != [Global.level_theme, Global.theme_time]:
|
||||
if state != [Global.level_theme, Global.theme_time, Global.current_room]:
|
||||
cache.clear()
|
||||
property_cache.clear()
|
||||
if node_to_affect != null:
|
||||
print(resource_json.data)
|
||||
var resource = get_resource(resource_json)
|
||||
node_to_affect.set(property_name, resource)
|
||||
if node_to_affect is AnimatedSprite2D:
|
||||
node_to_affect.play()
|
||||
state = [Global.level_theme, Global.theme_time]
|
||||
state = [Global.level_theme, Global.theme_time, Global.current_room]
|
||||
updated.emit()
|
||||
|
||||
func get_resource(json_file: JSON) -> Resource:
|
||||
@@ -244,6 +246,15 @@ func get_variation_json(json := {}) -> Dictionary:
|
||||
else:
|
||||
json = get_variation_json(json[level_string])
|
||||
|
||||
var room = Global.room_strings[Global.current_room]
|
||||
if json.has(room) == false:
|
||||
room = Global.room_strings[0]
|
||||
if json.has(room):
|
||||
if json.get(room).has("link"):
|
||||
json = get_variation_json(json[json.get(room).get("link")])
|
||||
else:
|
||||
json = get_variation_json(json[room])
|
||||
|
||||
var game_mode = "GameMode:" + Global.game_mode_strings[Global.current_game_mode]
|
||||
if json.has(game_mode) == false:
|
||||
game_mode = "GameMode:" + Global.game_mode_strings[0]
|
||||
@@ -336,4 +347,6 @@ func load_audio_from_path(path := "") -> AudioStream:
|
||||
stream = AudioStreamWAV.load_from_file(path)
|
||||
elif path.contains(".mp3"):
|
||||
stream = AudioStreamMP3.load_from_file(path)
|
||||
elif path.contains(".ogg"):
|
||||
stream = AudioStreamOggVorbis.load_from_file(path)
|
||||
return stream
|
||||
|
@@ -16,6 +16,7 @@ func _ready() -> void:
|
||||
texture_changed.connect(update)
|
||||
|
||||
func update() -> void:
|
||||
print(name)
|
||||
var source = tile_map.tile_set.get_source(atlas_id)
|
||||
if source != null:
|
||||
source.texture = texture
|
||||
|
@@ -7,7 +7,6 @@ func open_menu() -> void:
|
||||
editing_start.emit()
|
||||
$CanvasLayer.show()
|
||||
|
||||
|
||||
func on_pressed() -> void:
|
||||
set_value(Global.sanitize_string($CanvasLayer/Panel/VBoxContainer/TextEdit.text))
|
||||
editing_finished.emit()
|
||||
|
@@ -21,7 +21,11 @@ func rise_tween() -> void:
|
||||
var dir = sign(target_player.global_position.x - global_position.x)
|
||||
var target_position := Vector2(32 * dir, -32)
|
||||
var final_position = global_position + target_position
|
||||
final_position.y = clamp(final_position.y, -176, 64)
|
||||
var top_point = -176
|
||||
if Global.current_level != null:
|
||||
top_point = Global.current_level.vertical_height + 32
|
||||
final_position.y = clamp(final_position.y, top_point, 64)
|
||||
|
||||
tween.tween_property(self, "global_position", final_position, 0.75)
|
||||
await tween.finished
|
||||
falling = true
|
||||
|
@@ -82,7 +82,7 @@ func throw_spiny() -> void:
|
||||
node.velocity = Vector2(0, -150)
|
||||
if fixed_throw:
|
||||
node.velocity.x = 50 * (sign(player.global_position.x - global_position.x))
|
||||
node.set("direction", sign(node.velocity.x))
|
||||
node.set("direction", sign(node.velocity.x))
|
||||
add_sibling(node)
|
||||
if Settings.file.audio.extra_sfx == 1:
|
||||
AudioManager.play_sfx("lakitu_throw", global_position)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
@icon("res://Assets/Sprites/Editor/Enemy.png")
|
||||
@icon("res://Assets/Sprites/Editor/Enemy.svg")
|
||||
class_name Enemy
|
||||
extends CharacterBody2D
|
||||
|
||||
|
@@ -57,6 +57,7 @@ func run_door_check() -> void:
|
||||
if same_scene_exiting_door != null:
|
||||
if same_scene_exiting_door != self and exiting_door_id == door_id:
|
||||
door_found = true
|
||||
get_tree().call_group("CameraLimits", "return_camera_to_normal")
|
||||
for i in get_tree().get_nodes_in_group("Players"):
|
||||
player_exit(i)
|
||||
return
|
||||
|
@@ -1,5 +1,5 @@
|
||||
@tool
|
||||
@icon("res://Assets/Sprites/Editor/Pipe.png")
|
||||
@icon("res://Assets/Sprites/Editor/Pipe.svg")
|
||||
class_name PipeArea
|
||||
extends Node2D
|
||||
|
||||
|
@@ -605,7 +605,7 @@ func death_load() -> void:
|
||||
Global.death_load = true
|
||||
|
||||
# Handle lives decrement for CAMPAIGN and MARATHON
|
||||
if [Global.GameMode.CAMPAIGN, Global.GameMode.MARATHON, Global.GameMode.LEVEL_EDITOR, Global.GameMode.CUSTOM_LEVEL].has(Global.current_game_mode):
|
||||
if [Global.GameMode.CAMPAIGN, Global.GameMode.MARATHON].has(Global.current_game_mode):
|
||||
if Settings.file.difficulty.inf_lives == 0:
|
||||
Global.lives -= 1
|
||||
|
||||
@@ -617,6 +617,7 @@ func death_load() -> void:
|
||||
|
||||
Global.GameMode.LEVEL_EDITOR: func():
|
||||
owner.stop_testing(),
|
||||
|
||||
|
||||
Global.GameMode.CHALLENGE: func():
|
||||
Global.transition_to_scene("res://Scenes/Levels/ChallengeMiss.tscn"),
|
||||
@@ -643,10 +644,10 @@ func death_load() -> void:
|
||||
# Determine which action to take
|
||||
if death_actions.has(Global.current_game_mode):
|
||||
death_actions[Global.current_game_mode].call()
|
||||
elif Global.time <= 0:
|
||||
death_actions["time_up"].call()
|
||||
elif Global.lives <= 0 and Settings.file.difficulty.inf_lives == 0:
|
||||
death_actions["game_over"].call()
|
||||
elif Global.time <= 0:
|
||||
death_actions["time_up"].call()
|
||||
else:
|
||||
death_actions["default_reload"].call()
|
||||
|
||||
@@ -682,11 +683,13 @@ func get_power_up(power_name := "") -> void:
|
||||
await power_up_animation(power_name)
|
||||
else:
|
||||
return
|
||||
check_for_block()
|
||||
power_state = new_power_state
|
||||
Global.player_power_states[player_id] = str(power_state.get_index())
|
||||
handle_power_up_states(0)
|
||||
can_hurt = true
|
||||
refresh_hitbox()
|
||||
await get_tree().physics_frame
|
||||
check_for_block()
|
||||
|
||||
func check_for_block() -> void:
|
||||
if test_move(global_transform, (Vector2.UP * gravity_vector) * 4):
|
||||
|
@@ -1,4 +1,4 @@
|
||||
@icon("res://Assets/Sprites/Editor/Level.png")
|
||||
@icon("res://Assets/Sprites/Editor/Level.svg")
|
||||
class_name Level
|
||||
extends Node
|
||||
|
||||
@@ -51,6 +51,13 @@ const SMBS_THEMES := {
|
||||
8: "Overworld"
|
||||
}
|
||||
|
||||
const BONUS_ROOMS := {
|
||||
"SMB1": ["1-1a", "1-2a", "2-1a", "3-1a", "4-1a", "4-2a", "5-1a", "6-2a", "6-2c", "7-1a", "8-1a", "8-2a"],
|
||||
"SMBLL": ["1-1a", "2-1a", "2-2a", "3-1b", "4-2a", "5-1a", "5-3a", "7-1c", "7-2a", "10-1a", "12-1a", "13-1a", "13-2a", "13-4b"],
|
||||
"SMBS": ["1-1a", "1-2a", "6-2a", "6-2b", "6-2c", "6-2d", "6-3a", "7-1a", "7-3a"],
|
||||
"SMBANN": ["1-1a", "1-2a", "2-1a", "3-1a", "4-1a", "4-2a", "5-1a", "6-2a", "6-2c", "7-1a", "8-1a", "8-2a"]
|
||||
}
|
||||
|
||||
@export var auto_set_theme := false
|
||||
|
||||
@export var time_limit := 400
|
||||
@@ -119,11 +126,16 @@ func update_theme() -> void:
|
||||
if Global.current_campaign == "SMBANN":
|
||||
theme_time = "Night"
|
||||
ResourceSetterNew.cache.clear()
|
||||
if self is CoinHeaven:
|
||||
Global.current_room = Global.Room.COIN_HEAVEN
|
||||
else:
|
||||
Global.current_room = get_room_type()
|
||||
Global.current_campaign = campaign
|
||||
Global.level_theme = theme
|
||||
Global.theme_time = theme_time
|
||||
TitleScreen.last_theme = theme
|
||||
$LevelBG.update_visuals()
|
||||
if get_node_or_null("LevelBG") != null:
|
||||
$LevelBG.update_visuals()
|
||||
|
||||
func update_next_level_info() -> void:
|
||||
next_level = wrap(level_id + 1, 1, 5)
|
||||
@@ -164,3 +176,8 @@ func reload_level() -> void:
|
||||
Global.transition_to_scene(LevelTransition.level_to_transition_to)
|
||||
else:
|
||||
Global.transition_to_scene("res://Scenes/Levels/LevelTransition.tscn")
|
||||
|
||||
func get_room_type() -> Global.Room:
|
||||
if BONUS_ROOMS[campaign].has(scene_file_path.get_file().get_basename()):
|
||||
return Global.Room.BONUS_ROOM
|
||||
return Global.Room.MAIN_ROOM
|
||||
|
@@ -5,6 +5,7 @@ const DEFAULT_SFX_LIBRARY := {
|
||||
"big_jump": ("res://Assets/Audio/SFX/BigJump.wav"),
|
||||
"coin": ("res://Assets/Audio/SFX/Coin.wav"),
|
||||
"bump": ("res://Assets/Audio/SFX/Bump.wav"),
|
||||
"skid": ("res://Assets/Audio/SFX/Skid.wav"),
|
||||
"pipe": ("res://Assets/Audio/SFX/Pipe.wav"),
|
||||
"damage": ("res://Assets/Audio/SFX/Damage.wav"),
|
||||
"power_up": ("res://Assets/Audio/SFX/Powerup.wav"),
|
||||
|
@@ -89,6 +89,12 @@ var world_num := 1
|
||||
var level_num := 1
|
||||
var disco_mode := false
|
||||
|
||||
enum Room{MAIN_ROOM, BONUS_ROOM, COIN_HEAVEN, PIPE_CUTSCENE, TITLE_SCREEN}
|
||||
|
||||
const room_strings := ["MainRoom", "BonusRoom", "CoinHeaven", "PipeCutscene", "TitleScreen"]
|
||||
|
||||
var current_room: Room = Room.MAIN_ROOM
|
||||
|
||||
signal transition_finished
|
||||
var transitioning_scene := false
|
||||
var awaiting_transition := false
|
||||
@@ -327,6 +333,8 @@ func reset_values() -> void:
|
||||
Level.in_vine_level = false
|
||||
Level.vine_return_level = ""
|
||||
Level.vine_warp_level = ""
|
||||
p_switch_active = false
|
||||
p_switch_timer = 0.0
|
||||
|
||||
func clear_saved_values() -> void:
|
||||
coins = 0
|
||||
|
@@ -81,8 +81,6 @@ func write_save(campaign: String = Global.current_campaign, force := false) -> v
|
||||
save_json = SAVE_TEMPLATE.duplicate(true)
|
||||
match Global.current_game_mode:
|
||||
Global.GameMode.CAMPAIGN:
|
||||
if Global.world_num < 0:
|
||||
Global.world_num = 1
|
||||
if Global.high_score < Global.score:
|
||||
Global.high_score = Global.score
|
||||
save_json["World"] = Global.world_num
|
||||
@@ -117,7 +115,10 @@ func write_save_to_file(json := {}, path := "") -> void:
|
||||
file.close()
|
||||
|
||||
func apply_save(json := {}) -> void:
|
||||
|
||||
Global.world_num = json.get_or_add("World", 1)
|
||||
if Global.world_num < 1:
|
||||
Global.world_num = 1
|
||||
Global.level_num = json.get_or_add("Level", 1)
|
||||
Global.lives = json["Lives"]
|
||||
Global.coins = json["Coins"]
|
||||
|
@@ -12,9 +12,9 @@ var file := {
|
||||
"frame_limit" : 0,
|
||||
},
|
||||
"audio": {
|
||||
"master": 10.0,
|
||||
"music": 10.0,
|
||||
"sfx": 10.0,
|
||||
"master": 10,
|
||||
"music": 10,
|
||||
"sfx": 10,
|
||||
"athletic_bgm": 1,
|
||||
"extra_bgm": 1,
|
||||
"skid_sfx": 1,
|
||||
@@ -24,8 +24,7 @@ var file := {
|
||||
},
|
||||
"game": {
|
||||
"campaign": "SMB1",
|
||||
"lang": "en",
|
||||
"character": "0000"
|
||||
"lang": "en"
|
||||
},
|
||||
"keyboard":
|
||||
{
|
||||
|
@@ -25,5 +25,5 @@ func physics_update(delta: float) -> void:
|
||||
player.velocity.y += (player.JUMP_GRAVITY / delta) * delta
|
||||
player.velocity.y = clamp(player.velocity.y, -INF, player.MAX_FALL_SPEED)
|
||||
player.move_and_slide()
|
||||
if Input.is_action_just_pressed("jump_0"):
|
||||
if Input.is_action_just_pressed("ui_accept") or Input.is_action_just_pressed("jump_0"):
|
||||
player.death_load()
|
||||
|
@@ -268,8 +268,9 @@ func get_animation_name() -> String:
|
||||
return "StarFall"
|
||||
return "JumpFall"
|
||||
else:
|
||||
player.sprite.speed_scale = 0
|
||||
player.sprite.frame = walk_frame
|
||||
# guzlad: Fixes characters with fall anims not playing them, but also prevents old characters without that anim not being accurate
|
||||
if !player.sprite.sprite_frames.has_animation("Fall"):
|
||||
player.sprite.frame = walk_frame
|
||||
return "Fall"
|
||||
|
||||
func exit() -> void:
|
||||
|
@@ -47,6 +47,8 @@ func handle_main_hud() -> void:
|
||||
world_num = ["A", "B", "C", "D"][int(world_num) % 10]
|
||||
elif int(world_num) < 1:
|
||||
world_num = " "
|
||||
else:
|
||||
print(Global.world_num)
|
||||
%LevelNum.text = world_num + "-" + str(Global.level_num)
|
||||
%Crown.visible = Global.second_quest
|
||||
%Time.text = " " + str(Global.time).pad_zeros(3)
|
||||
|
@@ -5,6 +5,7 @@ extends Node2D
|
||||
@export var lock_camera := false
|
||||
|
||||
func _enter_tree() -> void:
|
||||
add_to_group("CameraLimits")
|
||||
Player.camera_right_limit = int(global_position.x)
|
||||
|
||||
func _exit_tree() -> void:
|
||||
@@ -13,6 +14,7 @@ func _exit_tree() -> void:
|
||||
|
||||
func return_camera_to_normal() -> void:
|
||||
for i in get_tree().get_nodes_in_group("Players"):
|
||||
Player.camera_right_limit = int(9999999)
|
||||
CameraHandler.cam_locked = false
|
||||
i.reset_camera_to_center()
|
||||
|
||||
|
@@ -115,7 +115,7 @@ func show_best_time() -> void:
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if can_transition:
|
||||
if Input.is_action_just_pressed("ui_accept"):
|
||||
if Input.is_action_just_pressed("ui_accept") or Input.is_action_just_pressed("jump_0"):
|
||||
transition()
|
||||
|
||||
func _exit_tree() -> void:
|
||||
|
@@ -10,6 +10,7 @@ func _enter_tree() -> void:
|
||||
theme_time = "Night"
|
||||
else:
|
||||
theme_time = "Day"
|
||||
Global.current_room = get_room_type()
|
||||
Global.level_theme = theme
|
||||
Global.theme_time = theme_time
|
||||
|
||||
@@ -27,4 +28,7 @@ func go_to_level() -> void:
|
||||
Global.transition_to_scene(LevelTransition.level_to_transition_to)
|
||||
|
||||
func play_pipe_sfx() -> void:
|
||||
AudioManager.play_global_sfx("pipe")
|
||||
AudioManager.play_sfx("pipe", $Player1.global_position)
|
||||
|
||||
func get_room_type() -> Global.Room:
|
||||
return Global.Room.PIPE_CUTSCENE
|
||||
|
@@ -240,7 +240,7 @@ func new_game_selected() -> void:
|
||||
func continue_game() -> void:
|
||||
SaveManager.apply_save(SaveManager.load_save(Global.current_campaign))
|
||||
Global.current_game_mode = Global.GameMode.CAMPAIGN
|
||||
if Global.game_beaten:
|
||||
if Global.game_beaten or Global.debug_mode:
|
||||
$CanvasLayer/StoryMode/ContinueBeatenGame/WorldSelect.open()
|
||||
else:
|
||||
$CanvasLayer/StoryMode/ContinueUnbeatenGame/CharacterSelect.open()
|
||||
@@ -263,3 +263,6 @@ func check_for_unlocked_achievements() -> void:
|
||||
has_achievements_to_unlock = true
|
||||
%AchievementUnlock.show_popup(new_achievements)
|
||||
AchievementMenu.unlocked_achievements = Global.achievements
|
||||
|
||||
func get_room_type() -> Global.Room:
|
||||
return Global.Room.TITLE_SCREEN
|
||||
|
@@ -48,7 +48,7 @@ func open() -> void:
|
||||
AudioManager.play_global_sfx("pause")
|
||||
get_tree().paused = true
|
||||
show()
|
||||
await get_tree().physics_frame
|
||||
await get_tree().create_timer(0.1).timeout
|
||||
active = true
|
||||
|
||||
func close() -> void:
|
||||
@@ -56,7 +56,6 @@ func close() -> void:
|
||||
selected_index = 0
|
||||
hide()
|
||||
closed.emit()
|
||||
for i in 2:
|
||||
await get_tree().physics_frame
|
||||
await get_tree().create_timer(0.1).timeout
|
||||
Global.game_paused = false
|
||||
get_tree().paused = false
|
||||
|
@@ -69,7 +69,8 @@ func add_properties() -> void:
|
||||
property.property_step = float(values[2])
|
||||
elif i.type == TYPE_BOOL:
|
||||
property = preload("uid://diqn7e5hqpbsk").instantiate()
|
||||
|
||||
elif i.type == TYPE_COLOR:
|
||||
property = preload("uid://o3ya33lcbn7y").instantiate()
|
||||
|
||||
if property != null:
|
||||
property.exit_changed.connect(set_can_exit)
|
||||
|
Reference in New Issue
Block a user