diff --git a/README.md b/README.md index fec97bb..bfe30c3 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # ScrapFrontier -Second Gotot game +Second Godot game diff --git a/export_presets.cfg b/export_presets.cfg index 28c5eeb..75fea05 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -65,3 +65,46 @@ Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorActi ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue Remove-Item -Recurse -Force '{temp_dir}'" + +[preset.1] + +name="Linux" +platform="Linux" +runnable=true +advanced_options=false +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="export/Linux/Scrap Frontier" +patches=PackedStringArray() +encryption_include_filters="" +encryption_exclude_filters="" +seed=0 +encrypt_pck=false +encrypt_directory=false +script_export_mode=2 + +[preset.1.options] + +custom_template/debug="" +custom_template/release="" +debug/export_console_wrapper=1 +binary_format/embed_pck=true +texture_format/s3tc_bptc=true +texture_format/etc2_astc=false +shader_baker/enabled=false +binary_format/architecture="x86_64" +ssh_remote_deploy/enabled=false +ssh_remote_deploy/host="user@host_ip" +ssh_remote_deploy/port="22" +ssh_remote_deploy/extra_args_ssh="" +ssh_remote_deploy/extra_args_scp="" +ssh_remote_deploy/run_script="#!/usr/bin/env bash +export DISPLAY=:0 +unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\" +\"{temp_dir}/{exe_name}\" {cmd_args}" +ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash +kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\") +rm -rf \"{temp_dir}\"" diff --git a/game/entities/player.gd b/game/entities/player.gd new file mode 100644 index 0000000..95a1309 --- /dev/null +++ b/game/entities/player.gd @@ -0,0 +1,10 @@ +extends Node2D + + +func _process(delta: float) -> void: + var speed := 100 + var input_direction := Input.get_vector("move_left", "move_right", "move_up", "move_down") + var velocity := input_direction * speed + position += velocity * delta + var screen_size := get_viewport_rect().size + position = position.clamp(Vector2.ZERO, screen_size) diff --git a/game/entities/player.gd.uid b/game/entities/player.gd.uid new file mode 100644 index 0000000..ba7d986 --- /dev/null +++ b/game/entities/player.gd.uid @@ -0,0 +1 @@ +uid://c2uf62j1im13p diff --git a/game/entities/player.tscn b/game/entities/player.tscn new file mode 100644 index 0000000..7ca49b3 --- /dev/null +++ b/game/entities/player.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=3 format=3 uid="uid://xpj7f3l1l51l"] + +[ext_resource type="Script" uid="uid://c2uf62j1im13p" path="res://game/entities/player.gd" id="1_xkeht"] +[ext_resource type="PackedScene" uid="uid://dn44qgg4coedd" path="res://game/entities/ship.tscn" id="2_3a8sv"] + +[node name="Player" type="Node2D"] +script = ExtResource("1_xkeht") + +[node name="Ship" parent="." instance=ExtResource("2_3a8sv")] diff --git a/game/entities/ship.gd b/game/entities/ship.gd new file mode 100644 index 0000000..a83c002 --- /dev/null +++ b/game/entities/ship.gd @@ -0,0 +1,9 @@ +extends Node2D + +@export var size : Vector2 + + +func _ready() -> void: + var texture := PlaceholderTexture2D.new() + texture.size = size + $Sprite2D.texture = texture diff --git a/game/entities/ship.gd.uid b/game/entities/ship.gd.uid new file mode 100644 index 0000000..9beb4cf --- /dev/null +++ b/game/entities/ship.gd.uid @@ -0,0 +1 @@ +uid://cesibaqtrgotl diff --git a/game/entities/ship.tscn b/game/entities/ship.tscn new file mode 100644 index 0000000..1ed7c41 --- /dev/null +++ b/game/entities/ship.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=3 uid="uid://dn44qgg4coedd"] + +[sub_resource type="GDScript" id="GDScript_3a8sv"] +script/source = "class_name Ship + +extends Node2D +" + +[node name="Ship" type="Node2D"] +script = SubResource("GDScript_3a8sv") + +[node name="Sprite2D" type="Sprite2D" parent="."] diff --git a/game/game.gd b/game/game.gd index 5679c56..4847c82 100644 --- a/game/game.gd +++ b/game/game.gd @@ -7,32 +7,32 @@ var _current_passage: Node func _ready() -> void: - _current_passage = load("res://game/passage.tscn").instantiate() - add_child(_current_passage) - - -func _input(event: InputEvent) -> void: - if event.is_action_pressed("pause"): - _pause_game() + _current_passage = load("res://game/passage.tscn").instantiate() + add_child(_current_passage) + +func _input(event: InputEvent) -> void: + if event.is_action_pressed("pause"): + _pause_game() + func _create_pause_menu() -> void: - _pause_menu = load("res://menu/pause_menu.tscn").instantiate() - add_child(_pause_menu) - _pause_menu.continue_game.connect(_unpause_game) - _pause_menu.show_main_menu.connect(_show_main_menu) - + _pause_menu = load("res://menu/pause_menu.tscn").instantiate() + add_child(_pause_menu) + _pause_menu.continue_game.connect(_unpause_game) + _pause_menu.show_main_menu.connect(_show_main_menu) + func _pause_game() -> void: - get_tree().paused = true - _create_pause_menu.call_deferred() - + get_tree().paused = true + _create_pause_menu.call_deferred() + func _unpause_game() -> void: - get_tree().paused = false - _pause_menu.queue_free() - + get_tree().paused = false + _pause_menu.queue_free() + func _show_main_menu() -> void: - get_tree().paused = false - show_main_menu.emit() + get_tree().paused = false + show_main_menu.emit() diff --git a/game/passage.gd b/game/passage.gd index 61510e1..7a0b6cd 100644 --- a/game/passage.gd +++ b/game/passage.gd @@ -1 +1,8 @@ extends Node + + +func _ready() -> void: + var player : Node2D = load("res://game/entities/player.tscn").instantiate() + player.position = Vector2(100, 100) + add_child(player) + diff --git a/main.gd b/main.gd index 94771d1..27678b6 100644 --- a/main.gd +++ b/main.gd @@ -4,34 +4,34 @@ var _current_scene: Node func _ready() -> void: - _show_main_menu() + _show_main_menu() func _show_main_menu() -> void: - if _current_scene != null: - _current_scene.queue_free() - - var scene : Node = load("res://title_screen.tscn").instantiate() - add_child(scene) - scene.continue_game.connect(_continue_game) - scene.new_game.connect(_new_game) - scene.quit_game.connect(_quit) - _current_scene = scene - + if _current_scene != null: + _current_scene.queue_free() + + var scene : Node = load("res://title_screen.tscn").instantiate() + add_child(scene) + scene.continue_game.connect(_continue_game) + scene.new_game.connect(_new_game) + scene.quit_game.connect(_quit) + _current_scene = scene + func _continue_game() -> void: - print("continue_game") - + print("continue_game") + func _new_game() -> void: - if _current_scene != null: - _current_scene.queue_free() - - var scene : Node = load("res://game/game.tscn").instantiate() - add_child(scene) - scene.show_main_menu.connect(_show_main_menu) - _current_scene = scene - + if _current_scene != null: + _current_scene.queue_free() + + var scene : Node = load("res://game/game.tscn").instantiate() + add_child(scene) + scene.show_main_menu.connect(_show_main_menu) + _current_scene = scene + func _quit() -> void: - get_tree().quit() + get_tree().quit() diff --git a/managers/settings_manager.gd b/managers/settings_manager.gd index e2dfca5..944bdfc 100644 --- a/managers/settings_manager.gd +++ b/managers/settings_manager.gd @@ -12,93 +12,94 @@ var _config: ConfigFile var _fullscreen := false var fullscreen : bool: - get: - return _fullscreen - set(value): - _fullscreen = value - _apply_video_settings() - _save_settings() - + get: + return _fullscreen + set(value): + _fullscreen = value + _apply_video_settings() + _save_settings() + + var _window_factor := 0 var window_factor : int: - get: - return _window_factor - set(value): - _window_factor = value - _apply_video_settings() - _save_settings() + get: + return _window_factor + set(value): + _window_factor = value + _apply_video_settings() + _save_settings() func _ready() -> void: - _load_settings() - _apply_all_settings() + _load_settings() + _apply_all_settings() func _load_settings() -> void: - _config = ConfigFile.new() - - if _config.load(CONFIG_FILE) == OK: - _fullscreen = _config.get_value(CATEGORY_VIDEO, SETTING_FULLSCREEN, false) - _window_factor = _config.get_value(CATEGORY_VIDEO, SETTING_WINDOW_FACTOR, 0) + _config = ConfigFile.new() + + if _config.load(CONFIG_FILE) == OK: + _fullscreen = _config.get_value(CATEGORY_VIDEO, SETTING_FULLSCREEN, false) + _window_factor = _config.get_value(CATEGORY_VIDEO, SETTING_WINDOW_FACTOR, 0) - _save_settings() + _save_settings() func _save_settings() -> void: - if _config == null: - _config = ConfigFile.new() - - _config.set_value(CATEGORY_VIDEO, SETTING_FULLSCREEN, _fullscreen) - _config.set_value(CATEGORY_VIDEO, SETTING_WINDOW_FACTOR, _window_factor) - - _config.save(CONFIG_FILE) + if _config == null: + _config = ConfigFile.new() + + _config.set_value(CATEGORY_VIDEO, SETTING_FULLSCREEN, _fullscreen) + _config.set_value(CATEGORY_VIDEO, SETTING_WINDOW_FACTOR, _window_factor) + + _config.save(CONFIG_FILE) func _apply_all_settings() -> void: - _apply_video_settings() + _apply_video_settings() func _apply_video_settings() -> void: - if _fullscreen: - DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN) - else: - DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED) - _apply_window_scale() + if _fullscreen: + DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN) + else: + DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED) + _apply_window_scale() func _apply_window_scale() -> void: - if _fullscreen: return - - var factors := [1, 2, 3, 4, 5, 6] - - var factor_index := _window_factor - if factor_index >= factors.size(): - factor_index = 0 - - var scale : int = factors[factor_index] - var new_size := BASE_SIZE * scale - - var current_position := DisplayServer.window_get_position() - var current_size := DisplayServer.window_get_size() - - var current_center := current_position + current_size / 2 - var new_position := current_center - new_size / 2 - - DisplayServer.window_set_size(new_size) - DisplayServer.window_set_position(new_position) - - _ensure_window_on_screen() + if _fullscreen: return + + var factors := [1, 2, 3, 4, 5, 6] + + var factor_index := _window_factor + if factor_index >= factors.size(): + factor_index = 0 + + var scale : int = factors[factor_index] + var new_size := BASE_SIZE * scale + + var current_position := DisplayServer.window_get_position() + var current_size := DisplayServer.window_get_size() + + var current_center := current_position + current_size / 2 + var new_position := current_center - new_size / 2 + + DisplayServer.window_set_size(new_size) + DisplayServer.window_set_position(new_position) + + _ensure_window_on_screen() func _ensure_window_on_screen() -> void: - if _fullscreen: return - - var window_position := DisplayServer.window_get_position() - var window_size := DisplayServer.window_get_size() - var screen_size := DisplayServer.screen_get_size() - - var new_x : int = clamp(window_position.x, 0, screen_size.x - window_size.x) - var new_y : int = clamp(window_position.y, 0, screen_size.y - window_size.y) - - if new_x != window_position.x or new_y != window_position.y: - DisplayServer.window_set_position(Vector2i(new_x, new_y)) + if _fullscreen: return + + var window_position := DisplayServer.window_get_position() + var window_size := DisplayServer.window_get_size() + var screen_size := DisplayServer.screen_get_size() + + var new_x : int = clamp(window_position.x, 0, screen_size.x - window_size.x) + var new_y : int = clamp(window_position.y, 0, screen_size.y - window_size.y) + + if new_x != window_position.x or new_y != window_position.y: + DisplayServer.window_set_position(Vector2i(new_x, new_y)) diff --git a/menu/credits.gd b/menu/credits.gd index 1d460fd..e071c54 100644 --- a/menu/credits.gd +++ b/menu/credits.gd @@ -4,8 +4,8 @@ signal show_main_menu func _ready() -> void: - $%MainMenuButton.grab_focus() - + $%MainMenuButton.grab_focus() + func _on_main_menu_button_pressed() -> void: - show_main_menu.emit() + show_main_menu.emit() diff --git a/menu/main_menu.gd b/menu/main_menu.gd index e455073..4e13d4f 100644 --- a/menu/main_menu.gd +++ b/menu/main_menu.gd @@ -6,39 +6,39 @@ signal quit_game signal show_options func _ready() -> void: - _init_focus() - _setup_neighbors() + _init_focus() + _setup_neighbors() func _init_focus() -> void: - if $%ContinueButton.disabled: - $%StartButton.grab_focus() - else: - $%ContinueButton.grab_focus() + if $%ContinueButton.disabled: + $%StartButton.grab_focus() + else: + $%ContinueButton.grab_focus() func _setup_neighbors() -> void: - if $%ContinueButton.disabled: - $%ContinueButton.focus_neighbor_top = "" - $%StartButton.focus_neighbor_top = $%QuitButton.get_path() - $%QuitButton.focus_neighbor_bottom = $%StartButton.get_path() - else: - $%ContinueButton.focus_neighbor_top = $%QuitButton.get_path() - $%StartButton.focus_neighbor_top = "" - $%QuitButton.focus_neighbor_bottom = $%ContinueButton.get_path() + if $%ContinueButton.disabled: + $%ContinueButton.focus_neighbor_top = "" + $%StartButton.focus_neighbor_top = $%QuitButton.get_path() + $%QuitButton.focus_neighbor_bottom = $%StartButton.get_path() + else: + $%ContinueButton.focus_neighbor_top = $%QuitButton.get_path() + $%StartButton.focus_neighbor_top = "" + $%QuitButton.focus_neighbor_bottom = $%ContinueButton.get_path() func _on_continue_button_pressed() -> void: - continue_game.emit() + continue_game.emit() func _on_start_button_pressed() -> void: - new_game.emit() + new_game.emit() func _on_options_button_pressed() -> void: - show_options.emit() + show_options.emit() func _on_quit_button_pressed() -> void: - quit_game.emit() + quit_game.emit() diff --git a/menu/options.gd b/menu/options.gd index 78c23af..7ce7a01 100644 --- a/menu/options.gd +++ b/menu/options.gd @@ -5,43 +5,43 @@ signal show_main_menu func _ready() -> void: - _load_current_settings() - _init_focus() - _setup_neighbors() - + _load_current_settings() + _init_focus() + _setup_neighbors() + func _init_focus() -> void: - $%FullscreenCheckButton.grab_focus() + $%FullscreenCheckButton.grab_focus() func _setup_neighbors() -> void: - $%CreditsButton.focus_neighbor_left = $%BackButton.get_path() - $%BackButton.focus_neighbor_right = $%CreditsButton.get_path() + $%CreditsButton.focus_neighbor_left = $%BackButton.get_path() + $%BackButton.focus_neighbor_right = $%CreditsButton.get_path() func _load_current_settings() -> void: - $%FullscreenCheckButton.button_pressed = SettingsManager.fullscreen - $%WindowFactorOptionButton.selected = SettingsManager.window_factor - _update_window_factor_disabled() + $%FullscreenCheckButton.button_pressed = SettingsManager.fullscreen + $%WindowFactorOptionButton.selected = SettingsManager.window_factor + _update_window_factor_disabled() func _update_window_factor_disabled() -> void: - $%WindowFactorOptionButton.disabled = SettingsManager.fullscreen + $%WindowFactorOptionButton.disabled = SettingsManager.fullscreen func _on_fullscreen_check_button_toggled(toggled: bool) -> void: - SettingsManager.fullscreen = toggled - _update_window_factor_disabled() + SettingsManager.fullscreen = toggled + _update_window_factor_disabled() func _on_window_factor_option_button_item_selected(index: int) -> void: - if not SettingsManager.fullscreen: - SettingsManager.window_factor = index + if not SettingsManager.fullscreen: + SettingsManager.window_factor = index func _on_credits_button_pressed() -> void: - show_credits.emit() + show_credits.emit() func _on_back_button_pressed() -> void: - show_main_menu.emit() + show_main_menu.emit() diff --git a/menu/pause_menu.gd b/menu/pause_menu.gd index 291b56e..efb40e9 100644 --- a/menu/pause_menu.gd +++ b/menu/pause_menu.gd @@ -5,22 +5,22 @@ signal show_main_menu func _ready() -> void: - _init_focus() - _setup_neighbors() + _init_focus() + _setup_neighbors() func _init_focus() -> void: - $%ContinueButton.grab_focus() + $%ContinueButton.grab_focus() func _setup_neighbors() -> void: - $%ContinueButton.focus_neighbor_top = $%MainMenuButton.get_path() - $%MainMenuButton.focus_neighbor_bottom = $%ContinueButton.get_path() + $%ContinueButton.focus_neighbor_top = $%MainMenuButton.get_path() + $%MainMenuButton.focus_neighbor_bottom = $%ContinueButton.get_path() func _on_continue_button_pressed() -> void: - continue_game.emit() + continue_game.emit() func _on_main_menu_button_pressed() -> void: - show_main_menu.emit() + show_main_menu.emit() diff --git a/title_screen.gd b/title_screen.gd index ec8dc92..a4e2337 100644 --- a/title_screen.gd +++ b/title_screen.gd @@ -8,51 +8,50 @@ var _current_scene: Node func _ready() -> void: - _show_main_menu() + _show_main_menu() func _show_main_menu() -> void: - if _current_scene != null: - _current_scene.queue_free() - - var scene : Node = load("res://menu/main_menu.tscn").instantiate() - add_child(scene) - scene.continue_game.connect(_continue_game) - scene.new_game.connect(_new_game) - scene.show_options.connect(_show_options) - scene.quit_game.connect(_quit_game) - _current_scene = scene - + if _current_scene != null: + _current_scene.queue_free() + + var scene : Node = load("res://menu/main_menu.tscn").instantiate() + add_child(scene) + scene.continue_game.connect(_continue_game) + scene.new_game.connect(_new_game) + scene.show_options.connect(_show_options) + scene.quit_game.connect(_quit_game) + _current_scene = scene + func _continue_game() -> void: - continue_game.emit() - + continue_game.emit() + func _new_game() -> void: - new_game.emit() - - + new_game.emit() + + func _quit_game() -> void: - quit_game.emit() - + quit_game.emit() + func _show_options() -> void: - if _current_scene != null: - _current_scene.queue_free() - - var scene : Node = load("res://menu/options.tscn").instantiate() - add_child(scene) - scene.show_main_menu.connect(_show_main_menu) - scene.show_credits.connect(_show_credits) - _current_scene = scene + if _current_scene != null: + _current_scene.queue_free() + + var scene : Node = load("res://menu/options.tscn").instantiate() + add_child(scene) + scene.show_main_menu.connect(_show_main_menu) + scene.show_credits.connect(_show_credits) + _current_scene = scene func _show_credits() -> void: - if _current_scene != null: - _current_scene.queue_free() - - var scene : Node = load("res://menu/credits.tscn").instantiate() - add_child(scene) - scene.show_main_menu.connect(_show_main_menu) - _current_scene = scene - + if _current_scene != null: + _current_scene.queue_free() + + var scene : Node = load("res://menu/credits.tscn").instantiate() + add_child(scene) + scene.show_main_menu.connect(_show_main_menu) + _current_scene = scene