diff --git a/project.godot b/project.godot index f0633b5..fd9719d 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="Semi-Idle ARPG" -run/main_scene="res://scenes/testInstanceScene.tscn" +run/main_scene="res://scenes/testScrollScene.tscn" config/features=PackedStringArray("4.3", "Forward Plus") config/icon="res://assets/icon.svg" diff --git a/scenes/testScrollScene.tscn b/scenes/testScrollScene.tscn new file mode 100644 index 0000000..a04d5ac --- /dev/null +++ b/scenes/testScrollScene.tscn @@ -0,0 +1,93 @@ +[gd_scene load_steps=2 format=3 uid="uid://0h3dpe6fuhe8"] + +[ext_resource type="Script" path="res://scripts/test_scroll_scene.gd" id="1_gc1kb"] + +[node name="TestInstanceScene" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_gc1kb") +debug = true + +[node name="SpawnArea" type="PanelContainer" parent="."] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +grow_horizontal = 2 + +[node name="SpawnTimer" type="Timer" parent="SpawnArea"] + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 10 +theme_override_constants/margin_top = 10 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 10 + +[node name="Menus" type="VBoxContainer" parent="MarginContainer"] +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 8 + +[node name="MenuButtons" type="HBoxContainer" parent="MarginContainer/Menus"] +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 8 + +[node name="MainMenuButton" type="Button" parent="MarginContainer/Menus/MenuButtons"] +layout_mode = 2 +text = "Menu" + +[node name="MapMenuButton" type="Button" parent="MarginContainer/Menus/MenuButtons"] +layout_mode = 2 +text = "Map" + +[node name="SkillsMenuButton" type="Button" parent="MarginContainer/Menus/MenuButtons"] +layout_mode = 2 +text = "Skills" + +[node name="InvMenuButton" type="Button" parent="MarginContainer/Menus/MenuButtons"] +layout_mode = 2 +text = "Inventory" + +[node name="LogMenuButton" type="Button" parent="MarginContainer/Menus/MenuButtons"] +layout_mode = 2 +text = "Log" + +[node name="CraftMenuButton" type="Button" parent="MarginContainer/Menus/MenuButtons"] +layout_mode = 2 +text = "Crafting" + +[node name="DebugMenu" type="HBoxContainer" parent="MarginContainer/Menus/MenuButtons"] +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 8 + +[node name="ButtonTest" type="Button" parent="MarginContainer/Menus/MenuButtons/DebugMenu"] +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 8 +text = "Spawn Enemies" + +[node name="TouchScreenButton" type="TouchScreenButton" parent="MarginContainer/Menus/MenuButtons/DebugMenu/ButtonTest"] + +[node name="ButtonExit" type="Button" parent="MarginContainer/Menus/MenuButtons/DebugMenu"] +layout_mode = 2 +size_flags_horizontal = 4 +size_flags_vertical = 8 +text = "Exit" + +[node name="TouchScreenButton" type="TouchScreenButton" parent="MarginContainer/Menus/MenuButtons/DebugMenu/ButtonExit"] + +[connection signal="timeout" from="SpawnArea/SpawnTimer" to="." method="_on_spawn_timer_timeout"] +[connection signal="pressed" from="MarginContainer/Menus/MenuButtons/DebugMenu/ButtonTest" to="." method="_on_button_test_pressed"] +[connection signal="pressed" from="MarginContainer/Menus/MenuButtons/DebugMenu/ButtonExit" to="." method="_on_button_exit_pressed"] diff --git a/scripts/test_scroll_scene.gd b/scripts/test_scroll_scene.gd new file mode 100644 index 0000000..1744f80 --- /dev/null +++ b/scripts/test_scroll_scene.gd @@ -0,0 +1,64 @@ +extends Control + + +@export var debug = false +@export var spawnTimerValue = 5.0 + +var deltaCount := 0 +var enemyMoveSpeed := 5.0 +var questsComplete := false + + +func _ready() -> void: + if not debug: + $MarginContainer/Menus/MenuButtons/DebugMenu.hide() + $SpawnArea/SpawnTimer.start(spawnTimerValue) + +func _create_enemy(): + var enemy = load("res://scenes/npc.tscn").instantiate() + enemy.scale = Vector2.ONE*0.5 + enemy.position = Vector2(randi_range(0, get_viewport_rect().size.x), -50) + #enemy.get_node("%NPCNameLabel").text = "Test" + + return enemy + + +func _spawn_enemies() -> void: + #await get_tree().create_timer(time).timeout + var middleX := get_viewport_rect().size.x/2 + var targetPosition = Vector2(middleX, get_viewport_rect().size.y*(0.75)) + var numEnemies = randi_range(1, 5) + for i in range(numEnemies): + var enemy = _create_enemy() + %SpawnArea.add_child(enemy) + var randEnemyMoveSpeed := randf_range(0.5, 2.0)*enemyMoveSpeed + create_tween().tween_property(enemy, "position", targetPosition, randEnemyMoveSpeed) + + +func _process(delta: float) -> void: + deltaCount += 1 + var enemies := %SpawnArea.get_children() + var numEnemies := %SpawnArea.get_child_count() + if numEnemies != 0 and (deltaCount % 60) == 0: + # change movement test, not sure it's working right... + #create_tween().tween_property(enemies[randi_range(0, numEnemies-1)], "position", Vector2(100, 100), 1.0) + pass + if questsComplete: + %SpawnArea/SpawnTimer.stop() + + +func _on_button_test_pressed() -> void: + # remove all existing enemies from scene and array + #for enemy in enemies: + #remove_child(enemy) + #enemies = [] + + questsComplete = true + + +func _on_button_exit_pressed() -> void: + get_tree().quit() + + +func _on_spawn_timer_timeout() -> void: + _spawn_enemies()