Merge branch 'main' into custom-level-loading-rewrite

This commit is contained in:
JHDev2006
2025-10-26 12:33:16 +00:00
158 changed files with 2106 additions and 1148 deletions

View File

@@ -26,8 +26,9 @@ const SCROLL_DIFFERENCE := 48.0
var can_diff := true
# guzlad: old Special scrolling variables kept for reference purposes
static var sp_screen_scroll := false
static var sp_scroll_style := 1
#static var sp_scroll_style := 1
var sp_scrolling := false
@@ -35,6 +36,7 @@ func _exit_tree() -> void:
cam_locked = false
func _physics_process(delta: float) -> void:
sp_screen_scroll = Settings.file.visuals.smbs_scroll > 0
handle_camera(delta)
last_position = global_position
@@ -127,11 +129,13 @@ func do_sp_scroll(direction := 1) -> void:
process_mode = Node.PROCESS_MODE_ALWAYS
get_tree().paused = true
var distance = get_viewport().get_visible_rect().size.x - 32
if sp_scroll_style == 0:
if Settings.file.visuals.smbs_scroll == 1: #Sharp X1 (smooth)
var tween = create_tween()
tween.tween_property(self, "camera_position:x", camera_position.x + (distance * direction), 1)
await tween.finished
else:
else: #PC-8801 (black screen)
if Settings.file.visuals.transition_animation:
Global.get_node("Transition").get_node("TransitionBlock").modulate.a = 1
Global.get_node("Transition").show()
await get_tree().create_timer(0.5).timeout
camera_position.x += distance * direction

View File

@@ -27,13 +27,17 @@ func _enter_tree() -> void:
LevelPersistance.active_nodes = old_state.duplicate(true)
func _ready() -> void:
if [Global.GameMode.CHALLENGE, Global.GameMode.MARATHON_PRACTICE].has(Global.current_game_mode) or Global.current_campaign == "SMBANN":
if [Global.GameMode.CHALLENGE, Global.GameMode.MARATHON_PRACTICE].has(Global.current_game_mode) or Global.current_campaign == "SMBANN" or (Settings.file.difficulty.extra_checkpoints == 0 and optional):
queue_free()
return
if has_meta("is_flag") == false:
hide()
if Settings.file.difficulty.checkpoint_style != 0:
queue_free()
return
elif Settings.file.difficulty.checkpoint_style == 0 and [Global.GameMode.CUSTOM_LEVEL, Global.GameMode.LEVEL_EDITOR].has(Global.current_game_mode) == false:
queue_free()
return
if passed and PipeArea.exiting_pipe_id == -1 and Global.current_game_mode != Global.GameMode.LEVEL_EDITOR and Level.vine_return_level == "" and passed_checkpoints[passed_checkpoints.size() - 1] == id:
for i in nodes_to_delete:
i.queue_free()
@@ -64,7 +68,7 @@ func on_area_entered(area: Area2D) -> void:
sublevel_id = Global.current_level.sublevel_id
if Settings.file.difficulty.checkpoint_style == 2 and has_meta("is_flag"):
if player.power_state.state_name == "Small":
player.get_power_up("Big")
player.get_power_up("Big", false)
respawn_position = global_position
crossed.emit(area.owner)
@@ -73,6 +77,3 @@ func get_id() -> String:
return str(Global.level_editor.sub_level_id) + "," + str(Vector2i(global_position)) + "," + get_parent().name
else:
return Global.current_level.scene_file_path + "," + str(Vector2i(global_position)) + "," + get_parent().name
func on_tree_exiting() -> void:
pass # Replace with function body.

View File

@@ -37,6 +37,7 @@ func set_value(value_name := "", value := 0) -> void:
"inf_lives": inf_lives_changed,
"flagpole_lives": flag_lives_changed,
"game_over": game_over_changed,
"game_over_behaviour": game_over_changed,
"level_design": level_design_changed,
"extra_checkpoints": extra_checkpoints_changed,
"back_scroll": backscroll_changed

View File

@@ -85,9 +85,13 @@ func do_lost_levels_firework_check() -> void:
else:
await show_fireworks(3)
if Global.coins % 11 == 0:
spawn_one_up_note()
AudioManager.play_sfx("1_up", global_position)
Global.lives += 1
if [Global.GameMode.CHALLENGE, Global.GameMode.BOO_RACE].has(Global.current_game_mode) or Settings.file.difficulty.inf_lives:
Global.score += 2000
$ScoreNoteSpawner.spawn_note(2000)
else:
Global.lives += 1
spawn_one_up_note()
const ONE_UP_NOTE = preload("uid://dopxwjj37gu0l")

View File

@@ -2,21 +2,16 @@ extends Node2D
const FLAG_POINTS := [100, 400, 800, 2000, 5000]
const FLAG_POINTS_MODERN := [100, 200, 800, 4000, 8000]
signal player_reached
signal sequence_begin
func _ready() -> void:
if Settings.file.difficulty.flagpole_lives == 0:
print(Settings.file.difficulty)
$Top.queue_free()
func on_area_entered(area: Area2D) -> void:
if area.owner is Player:
player_touch(area.owner)
func player_touch(player: Player) -> void:
player_reached.emit()
if Global.current_game_mode == Global.GameMode.MARATHON_PRACTICE:
@@ -49,11 +44,13 @@ func player_touch(player: Player) -> void:
func give_points(player: Player) -> void:
var value = clamp(int(lerp(0, 4, (player.global_position.y / -144))), 0, 4)
var nearest_value = FLAG_POINTS[value]
if Settings.file.difficulty.flagpole_lives:
nearest_value = FLAG_POINTS_MODERN[value]
$Score.text = str(nearest_value)
Global.score += nearest_value
$Score/Animation2.play("ScoreRise")
func on_player_entered(player: Player) -> void:
player_touch(player)
Global.lives += 1
AudioManager.play_sfx("1_up", global_position)
if nearest_value == 8000 and not [Global.GameMode.CHALLENGE, Global.GameMode.BOO_RACE].has(Global.current_game_mode) and not Settings.file.difficulty.inf_lives:
AudioManager.play_sfx("1_up", global_position)
Global.lives += 1
$ScoreNoteSpawner.spawn_one_up_note()
else:
Global.score += nearest_value
$Score/Animation2.play("ScoreRise")

View File

@@ -8,6 +8,8 @@ var active := false
@export_enum("Right", "Bottom") var direction := 0
@export var entity_scene: PackedScene = null
signal activated
func _physics_process(delta: float) -> void:
if active:
spawn_meter += delta
@@ -20,6 +22,7 @@ func activate() -> void:
active = true
spawn_meter = 0
spawn_entity()
activated.emit()
func deactivate_all_generators() -> void:
for i in get_tree().get_nodes_in_group("EntityGenerators"):
@@ -39,6 +42,9 @@ func spawn_entity() -> void:
if y_pos == 0:
node.global_position.y = get_tree().get_first_node_in_group("Players").global_position.y + randi_range(-4, 4)
else:
node.global_position.y = randf_range(-56, -120)
node.global_position.x = get_viewport().get_camera_2d().get_screen_center_position().x + ((get_viewport().get_visible_rect().size.x / 2) + 4)
add_sibling(node)
node.global_position.y = randf_range(0, -152)
node.global_position.x = get_viewport().get_camera_2d().get_screen_center_position().x + ((get_viewport().get_visible_rect().size.x / 2) + 8)
if get_parent() is EntityGenerator:
get_parent().add_sibling(node)
else:
add_sibling(node)

View File

@@ -120,7 +120,7 @@ func handle_challenge_mode_transition() -> void:
%ChallengeScoreText/Target.show()
%ChallengeCoins2.show()
%ChallengeCoins.show()
%ChallengeScoreText.text = str(Global.score)
%ChallengeScoreText.text = str(int(ChallengeModeHandler.top_challenge_scores[Global.world_num - 1][Global.level_num - 1]))
var idx = 0
for i in %ChallengeCoins.get_children():
if ChallengeModeHandler.is_coin_collected(idx, ChallengeModeHandler.red_coins_collected[Global.world_num - 1][Global.level_num - 1]):

View File

@@ -33,5 +33,7 @@ func update() -> void:
offset.y = -(sprite_frames.get_frame_texture(animation, frame).get_height() / 2.0)
func on_animation_changed() -> void:
if sprite_frames.has_animation(animation) == false and Player.ANIMATION_FALLBACKS.has(animation):
play(Player.ANIMATION_FALLBACKS[animation])
var fallback = animation
while not sprite_frames.has_animation(fallback) and Player.ANIMATION_FALLBACKS.has(fallback):
fallback = Player.ANIMATION_FALLBACKS[fallback]
play(fallback)

View File

@@ -3,13 +3,23 @@ extends Node
var files := []
var directories := []
signal fnt_file_downloaded(text: String)
var downloaded_fnt_text := []
signal pack_created
const base_info_json := {
"name": "New Pack",
"description": "Template, give me a description!",
"author": "Me, until you change it"
"author": "Me, until you change it",
"version": "1.0"
}
const disallowed_files := ["bgm","ctex","json","fnt", "svg"]
func create_template() -> void:
await get_tree().process_frame
get_directories("res://Assets", files, directories)
for i in directories:
DirAccess.make_dir_recursive_absolute(i.replace("res://Assets", Global.config_path.path_join("resource_packs/new_pack")))
@@ -19,14 +29,52 @@ func create_template() -> void:
destination = i.replace("res://Assets", Global.config_path.path_join("resource_packs/new_pack"))
else:
destination = i.replace(Global.config_path.path_join("resource_packs/BaseAssets"), Global.config_path.path_join("resource_packs/new_pack"))
print("Copying '" + i + "' to: '" + destination)
var old_file = FileAccess.open(i, FileAccess.READ)
if old_file != null:
var new_file = FileAccess.open(destination, FileAccess.WRITE)
new_file.store_buffer(old_file.get_buffer(old_file.get_length()))
var data = []
if i.contains(".fnt") or i.contains("ScoreFont"):
data = await download_fnt_text(i)
## Imagine being one of the best open source game engines, yet not able to get the FUCKING CONTENTS
## OF AN FNT FILE SO INSTEAD YOU HAVE TO WRITE THE MOST BULLSHIT CODE TO DOWNLOAD THE FUCKING FILE
## FROM THE FUCKING GITHUB REPO. WHY? BECAUSE GODOT IS SHIT. FUCK GODOT.
elif i.contains(".svg"):
## DON'T import SVGs
continue
elif disallowed_files.has(i.get_extension()) == false and i.contains("res://"):
var resource = load(i)
if resource is Texture:
if OS.is_debug_build(): print("texture:" + i)
var image: Image = resource.get_image()
image.convert(Image.FORMAT_RGBA8)
data = image.save_png_to_buffer()
elif resource is AudioStream:
match i.get_extension():
"mp3":
if OS.is_debug_build(): print("mp3:" + i)
data = resource.get_data()
"wav":
## guzlad: CAN NOT BE format FORMAT_IMA_ADPCM or FORMAT_QOA as they don't support the save function
## guzlad: Should be FORMAT_16_BITS like most of our other .wav files
if OS.is_debug_build(): print("wav:" + i)
var wav_file: AudioStreamWAV = load(i)
if !OS.is_debug_build():
wav_file.save_to_wav(destination)
else:
print(error_string(wav_file.save_to_wav(destination)))
## guzlad: No OGG yet
_:
data = resource.get_data()
else:
if OS.is_debug_build(): print("else:" + i)
var old_file = FileAccess.open(i, FileAccess.READ)
data = old_file.get_buffer(old_file.get_length())
if OS.is_debug_build(): print("else error: " + error_string(old_file.get_error()))
old_file.close()
if !data.is_empty():
if OS.is_debug_build(): print("saving:" + i)
var new_file = FileAccess.open(destination, FileAccess.WRITE)
new_file.store_buffer(data)
if OS.is_debug_build(): print("saving error: " + error_string(new_file.get_error()))
new_file.close()
var pack_info_path = Global.config_path.path_join("resource_packs/new_pack/pack_info.json")
DirAccess.make_dir_recursive_absolute(pack_info_path.get_base_dir())
@@ -34,10 +82,26 @@ func create_template() -> void:
file.store_string(JSON.stringify(base_info_json, "\t"))
file.close()
print("Done")
pack_created.emit()
func download_fnt_text(file_path := "") -> PackedByteArray:
var http = HTTPRequest.new()
const GITHUB_URL = "https://raw.githubusercontent.com/JHDev2006/Super-Mario-Bros.-Remastered-Public/refs/heads/main/"
var url = GITHUB_URL + file_path.replace("res://", "")
add_child(http)
http.request_completed.connect(file_downloaded)
http.request(url, [], HTTPClient.METHOD_GET)
await fnt_file_downloaded
http.queue_free()
return downloaded_fnt_text
func file_downloaded(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray) -> void:
downloaded_fnt_text = body
fnt_file_downloaded.emit(downloaded_fnt_text)
func get_directories(base_dir := "", files := [], directories := []) -> void:
for i in DirAccess.get_directories_at(base_dir):
if base_dir.contains("LevelGuides") == false:
if base_dir.contains("LevelGuides") == false and base_dir.contains(".godot") == false:
directories.append(base_dir + "/" + i)
get_directories(base_dir + "/" + i, files, directories)
get_files(base_dir + "/" + i, files)
@@ -46,7 +110,7 @@ func get_files(base_dir := "", files := []) -> void:
for i in DirAccess.get_files_at(base_dir):
if base_dir.contains("LevelGuides") == false:
i = i.replace(".import", "")
print(i)
#print(i)
var target_path = base_dir + "/" + i
var rom_assets_path = target_path.replace("res://Assets", Global.config_path.path_join("resource_packs/BaseAssets"))
if FileAccess.file_exists(rom_assets_path):

View File

@@ -41,6 +41,9 @@ func resource_pack_loaded(new_value := []) -> void:
func colourful_pipes_changed(new_value := 0) -> void:
Settings.file.visuals.colour_pipes = new_value
func smbs_scroll_changed(new_value := 0) -> void:
Settings.file.visuals.smbs_scroll = new_value
func visible_timers_changed(new_value := 0) -> void:
Settings.file.visuals.visible_timers = new_value
@@ -69,6 +72,7 @@ func set_value(value_name := "", value = null) -> void:
"resource_packs": resource_pack_loaded,
"bridge_animation": bridge_changed,
"transition_animation": transform_style_changed,
"smbs_scroll": smbs_scroll_changed,
"colour_pipes": colourful_pipes_changed,
"firebar_style": firebar_style_changed,
"extra_particles": extra_particles