Compare commits
6 Commits
84da2ba48e
...
ffaee18654
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ffaee18654 | ||
|
|
50cea7f096 | ||
|
|
3b254ea1f7 | ||
|
|
28ac1753ec | ||
|
|
1116487c10 | ||
|
|
1fae8c07d3 |
9
.idea/.idea.Ecosystem/.idea/libraries/GdSdk.xml
generated
Normal file
9
.idea/.idea.Ecosystem/.idea/libraries/GdSdk.xml
generated
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="GdSdk" type="GdScript">
|
||||||
|
<CLASSES />
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES>
|
||||||
|
<root url="file://$APPLICATION_HOME_DIR$/plugins/rider-gdscript/sdk/extracted/4.4.1" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="GdSdk Master" type="GdScript">
|
|
||||||
<properties path="$USER_HOME$/.cache/JetBrains/Rider2025.1/projects/.idea.ecosystem.daf914ba/sdk/GdSdk Master" version="Master" date="2024-06-01T15:14:16.000+02:00" />
|
|
||||||
<CLASSES />
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES>
|
|
||||||
<root url="file://$USER_HOME$/.cache/JetBrains/Rider2025.1/projects/.idea.ecosystem.daf914ba/sdk/GdSdk Master" />
|
|
||||||
</SOURCES>
|
|
||||||
</library>
|
|
||||||
</component>
|
|
||||||
121
scenes/HUD/hud.tscn
Normal file
121
scenes/HUD/hud.tscn
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
[gd_scene load_steps=4 format=3 uid="uid://djgeio24bm6i4"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://ce6mehx86c03f" path="res://scenes/main/hud.gd" id="1_jjobl"]
|
||||||
|
[ext_resource type="Script" uid="uid://8vkyddmxqfaf" path="res://scenes/HUD/menu_bar.gd" id="2_epp0c"]
|
||||||
|
[ext_resource type="Script" uid="uid://cmoqidhmxlccq" path="res://scenes/HUD/options_menu.gd" id="3_r7rnh"]
|
||||||
|
|
||||||
|
[node name="HUD" type="CanvasLayer"]
|
||||||
|
script = ExtResource("1_jjobl")
|
||||||
|
|
||||||
|
[node name="MenuBar" type="MenuBar" parent="."]
|
||||||
|
anchors_preset = 10
|
||||||
|
anchor_right = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
script = ExtResource("2_epp0c")
|
||||||
|
|
||||||
|
[node name="Entity" type="PopupMenu" parent="MenuBar"]
|
||||||
|
auto_translate_mode = 1
|
||||||
|
size = Vector2i(109, 100)
|
||||||
|
|
||||||
|
[node name="Spawn" type="PopupMenu" parent="MenuBar"]
|
||||||
|
auto_translate_mode = 1
|
||||||
|
size = Vector2i(109, 100)
|
||||||
|
item_count = 2
|
||||||
|
item_0/text = "Fly"
|
||||||
|
item_0/id = 0
|
||||||
|
item_1/text = "Bumblebee"
|
||||||
|
item_1/id = 1
|
||||||
|
|
||||||
|
[node name="Options" type="PopupMenu" parent="MenuBar"]
|
||||||
|
auto_translate_mode = 1
|
||||||
|
item_count = 2
|
||||||
|
item_0/text = "Camera"
|
||||||
|
item_0/id = 0
|
||||||
|
item_1/text = "World"
|
||||||
|
item_1/id = 1
|
||||||
|
script = ExtResource("3_r7rnh")
|
||||||
|
|
||||||
|
[node name="Camera" type="PopupMenu" parent="MenuBar/Options"]
|
||||||
|
auto_translate_mode = 1
|
||||||
|
item_count = 2
|
||||||
|
item_0/text = "Speed"
|
||||||
|
item_0/id = 0
|
||||||
|
item_1/text = "Position"
|
||||||
|
item_1/id = 1
|
||||||
|
|
||||||
|
[node name="World" type="PopupMenu" parent="MenuBar/Options"]
|
||||||
|
auto_translate_mode = 1
|
||||||
|
item_count = 1
|
||||||
|
item_0/text = "Generate"
|
||||||
|
item_0/id = 0
|
||||||
|
|
||||||
|
[node name="Info" type="PopupMenu" parent="MenuBar"]
|
||||||
|
auto_translate_mode = 1
|
||||||
|
item_count = 2
|
||||||
|
item_0/text = "Camera"
|
||||||
|
item_0/id = 0
|
||||||
|
item_1/text = "World"
|
||||||
|
item_1/id = 1
|
||||||
|
|
||||||
|
[node name="SpawnMenuButton" type="MenuButton" parent="."]
|
||||||
|
visible = false
|
||||||
|
anchors_preset = 2
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_top = -31.0
|
||||||
|
offset_right = 60.0
|
||||||
|
grow_vertical = 0
|
||||||
|
text = "Spawn"
|
||||||
|
item_count = 2
|
||||||
|
popup/item_0/text = "Fly"
|
||||||
|
popup/item_0/id = 0
|
||||||
|
popup/item_1/text = "Bumblebee"
|
||||||
|
popup/item_1/id = 1
|
||||||
|
|
||||||
|
[node name="Button" type="Button" parent="."]
|
||||||
|
visible = false
|
||||||
|
anchors_preset = 7
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_left = -42.5
|
||||||
|
offset_top = -31.0
|
||||||
|
offset_right = 42.5
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 0
|
||||||
|
text = "Spawn Fly"
|
||||||
|
|
||||||
|
[node name="GenerateWorldButton" type="Button" parent="."]
|
||||||
|
anchors_preset = 3
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_left = -131.0
|
||||||
|
offset_top = -31.0
|
||||||
|
grow_horizontal = 0
|
||||||
|
grow_vertical = 0
|
||||||
|
text = "Regenerate World"
|
||||||
|
|
||||||
|
[node name="InformationPanel" type="MarginContainer" parent="."]
|
||||||
|
anchors_preset = 12
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 0
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="InformationPanel"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="InformationPanel/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="EntityInformationContainer" type="VBoxContainer" parent="InformationPanel/VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="NameLabel" type="Label" parent="InformationPanel/VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[connection signal="index_pressed" from="MenuBar/Options" to="MenuBar" method="options_index_pressed"]
|
||||||
29
scenes/HUD/information_panel.gd
Normal file
29
scenes/HUD/information_panel.gd
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
extends MarginContainer
|
||||||
|
|
||||||
|
@onready var NameLabel: Label = $VBoxContainer/NameLabel
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
defaultInfoPanel()
|
||||||
|
ShowInfoPanel()
|
||||||
|
|
||||||
|
func BuildInfoPanel(source: Node2D) -> void:
|
||||||
|
NameLabel.text = source.name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func defaultInfoPanel() -> void:
|
||||||
|
NameLabel.text = "Nothing to show..."
|
||||||
|
|
||||||
|
|
||||||
|
func worldInfoPanel() -> void:
|
||||||
|
NameLabel.text = "World"
|
||||||
|
var sizeLabel: Label = Label.new()
|
||||||
|
sizeLabel.text = "Viewportsize: {size}".format({"size": get_viewport_rect().size})
|
||||||
|
$VBoxContainer/HBoxContainer/EntityInformationContainer.add_child(sizeLabel)
|
||||||
|
|
||||||
|
func ShowInfoPanel() -> void:
|
||||||
|
show()
|
||||||
|
|
||||||
|
|
||||||
|
func HideInfoPanel() -> void:
|
||||||
|
hide()
|
||||||
1
scenes/HUD/information_panel.gd.uid
Normal file
1
scenes/HUD/information_panel.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://cm0m3up5ufny2
|
||||||
@@ -14,8 +14,22 @@ func options_camera_pressed(target_position):
|
|||||||
camera_menu.position = target_position
|
camera_menu.position = target_position
|
||||||
camera_menu.show()
|
camera_menu.show()
|
||||||
|
|
||||||
|
|
||||||
func options_world_pressed(target_position):
|
func options_world_pressed(target_position):
|
||||||
var world_menu = $Options/World
|
var world_menu = $Options/World
|
||||||
world_menu.position = target_position
|
world_menu.position = target_position
|
||||||
world_menu.show()
|
world_menu.show()
|
||||||
|
|
||||||
|
|
||||||
|
func info_index_pressed(index):
|
||||||
|
var infoPanel: Node = get_parent().get_node("InformationPanel")
|
||||||
|
if index == 0: #Camera
|
||||||
|
pass
|
||||||
|
elif index == 1: #World
|
||||||
|
infoPanel.call("worldInfoPanel")
|
||||||
|
infoPanel.call("ShowInfoPanel")
|
||||||
|
|
||||||
|
elif index == 2: #Close
|
||||||
|
infoPanel.call("HideInfoPanel")
|
||||||
|
|
||||||
|
|
||||||
@@ -4,10 +4,10 @@ using System;
|
|||||||
public partial class GobalCamera : Camera2D
|
public partial class GobalCamera : Camera2D
|
||||||
{
|
{
|
||||||
public Vector2 zoomSpeed = new Vector2(0.05f, 0.05f);
|
public Vector2 zoomSpeed = new Vector2(0.05f, 0.05f);
|
||||||
public float zoomMin = 0.001f;
|
public float zoomMin = 0.1f;
|
||||||
public float zoomMax = 2.0f;
|
public float zoomMax = 4.0f;
|
||||||
[Export] public float dragSensitivity = 0.35f;
|
[Export] public float dragSensitivity = 0.35f;
|
||||||
|
[Export] public float cameraStepSize = 10.0f;
|
||||||
|
|
||||||
public override void _Input(InputEvent @event)
|
public override void _Input(InputEvent @event)
|
||||||
{
|
{
|
||||||
@@ -18,6 +18,27 @@ public partial class GobalCamera : Camera2D
|
|||||||
Position -= mouseMotion.Relative * dragSensitivity / Zoom;
|
Position -= mouseMotion.Relative * dragSensitivity / Zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (@event is InputEventAction eventAction && eventAction.IsPressed())
|
||||||
|
{
|
||||||
|
switch (eventAction.AsText())
|
||||||
|
{
|
||||||
|
case "camera_up":
|
||||||
|
Position -= new Vector2(0, cameraStepSize);
|
||||||
|
break;
|
||||||
|
case "camera_down":
|
||||||
|
Position += new Vector2(0, cameraStepSize);
|
||||||
|
break;
|
||||||
|
case "camera_left":
|
||||||
|
Position -= new Vector2(cameraStepSize, 0);
|
||||||
|
break;
|
||||||
|
case "camera_right":
|
||||||
|
Position += new Vector2(cameraStepSize, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
GD.Print(eventAction.AsText());
|
||||||
|
}
|
||||||
|
|
||||||
if (@event is InputEventMouseButton mouseButton)
|
if (@event is InputEventMouseButton mouseButton)
|
||||||
{
|
{
|
||||||
switch (mouseButton.ButtonIndex)
|
switch (mouseButton.ButtonIndex)
|
||||||
|
|||||||
@@ -13,15 +13,18 @@ public partial class Main : Node
|
|||||||
screenSize = GetViewport().GetVisibleRect().Size;
|
screenSize = GetViewport().GetVisibleRect().Size;
|
||||||
camera = GetNode<Camera2D>("GlobalCamera");
|
camera = GetNode<Camera2D>("GlobalCamera");
|
||||||
spawner = GetNode("World/Spawner");
|
spawner = GetNode("World/Spawner");
|
||||||
|
Node2D grid = GetNode<Node2D>("World/Grid");
|
||||||
GetNode<Node2D>("Grid").Call("generateGrid");
|
|
||||||
|
|
||||||
camera.Position = new Vector2(screenSize.X / 2, screenSize.Y / 2);
|
camera.Position = new Vector2(screenSize.X / 2, screenSize.Y / 2);
|
||||||
|
|
||||||
var flyPosition = camera.Position;
|
var flyPosition = camera.Position;
|
||||||
spawner.Call("spawn_fly", flyPosition);
|
spawner.Call("spawn_fly", flyPosition);
|
||||||
|
|
||||||
|
Node2D fly = (Node2D)spawner.GetChild(0);
|
||||||
|
GD.Print(grid.Call("worldToGrid", fly.Position));
|
||||||
|
|
||||||
|
GetNode<MarginContainer>("HUD").Call("buildInfoPanel", (Node)fly);
|
||||||
|
GetNode<MarginContainer>("HUD").Call("ShowInfoPanel");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,27 +3,36 @@ extends Node2D
|
|||||||
|
|
||||||
@export var width: int = 12
|
@export var width: int = 12
|
||||||
@export var height: int = 12
|
@export var height: int = 12
|
||||||
@export var cell_size: int = 128
|
@export var cell_size: Vector2 = Vector2(128, 128)
|
||||||
|
|
||||||
@export var show_debug: bool = false
|
@export var show_debug: bool = false
|
||||||
|
@export var show_grid: bool = true
|
||||||
|
@export var show_label: bool = true
|
||||||
|
|
||||||
var grid: Dictionary = {}
|
var grid: Dictionary = {}
|
||||||
|
|
||||||
func generateGrid():
|
func generateGrid():
|
||||||
|
print("Generating Grid")
|
||||||
for x in width:
|
for x in width:
|
||||||
for y in height:
|
for y in height:
|
||||||
grid[Vector2(x,y)] = null
|
grid[Vector2(x,y)] = null
|
||||||
if show_debug:
|
if show_grid:
|
||||||
var rect = ReferenceRect.new()
|
var rect = ReferenceRect.new()
|
||||||
rect.position = gridToWorld(Vector2(x,y))
|
rect.position = gridToWorld(Vector2(x,y))
|
||||||
rect.size = Vector2(cell_size, cell_size)
|
rect.size = cell_size
|
||||||
rect.editor_only = false
|
rect.editor_only = false
|
||||||
$Debug.add_child(rect)
|
$Debug.add_child(rect)
|
||||||
|
# print("Adding Rect ", x, "| ", y)
|
||||||
|
if show_label:
|
||||||
var label = Label.new()
|
var label = Label.new()
|
||||||
label.position = gridToWorld(Vector2(x,y))
|
label.position = gridToWorld(Vector2(x,y))
|
||||||
label.text = str(Vector2(x,y))
|
label.text = str(Vector2(x,y))
|
||||||
$Debug.add_child(label)
|
$Debug.add_child(label)
|
||||||
|
print("Grid generation done.")
|
||||||
|
|
||||||
|
func _draw() -> void:
|
||||||
|
if show_debug:
|
||||||
|
$Debug.show()
|
||||||
|
|
||||||
func gridToWorld(_pos: Vector2) -> Vector2:
|
func gridToWorld(_pos: Vector2) -> Vector2:
|
||||||
return _pos * cell_size
|
return _pos * cell_size
|
||||||
|
|||||||
18
scenes/main/hud.gd
Normal file
18
scenes/main/hud.gd
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
extends CanvasLayer
|
||||||
|
|
||||||
|
@onready var InfoMenu = $MenuBar/Info
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
#func _process(delta: float) -> void:
|
||||||
|
# pass
|
||||||
|
|
||||||
|
func GetMenuPressed(index) -> String:
|
||||||
|
if index == 0: return "Camera"
|
||||||
|
elif index == 1: return "World"
|
||||||
|
else: return ""
|
||||||
1
scenes/main/hud.gd.uid
Normal file
1
scenes/main/hud.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://ce6mehx86c03f
|
||||||
@@ -1,34 +1,26 @@
|
|||||||
[gd_scene load_steps=8 format=3 uid="uid://bkw0abirq18mt"]
|
[gd_scene load_steps=7 format=3 uid="uid://bkw0abirq18mt"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dte8xibis5wf7" path="res://scenes/main/Main.cs" id="1_6q06x"]
|
[ext_resource type="Script" uid="uid://dte8xibis5wf7" path="res://scenes/main/Main.cs" id="1_6q06x"]
|
||||||
[ext_resource type="PackedScene" uid="uid://brbhyuelsuxyx" path="res://scenes/world/world.tscn" id="1_o5qli"]
|
[ext_resource type="PackedScene" uid="uid://brbhyuelsuxyx" path="res://scenes/world/world.tscn" id="1_o5qli"]
|
||||||
[ext_resource type="Script" uid="uid://cqrt5x30j5vm6" path="res://scenes/main/grid.gd" id="3_hujxm"]
|
|
||||||
[ext_resource type="Script" uid="uid://csmrhb44u00j" path="res://scenes/main/GobalCamera.cs" id="3_ow5a4"]
|
[ext_resource type="Script" uid="uid://csmrhb44u00j" path="res://scenes/main/GobalCamera.cs" id="3_ow5a4"]
|
||||||
[ext_resource type="Script" uid="uid://8vkyddmxqfaf" path="res://scenes/HUD/menu_bar.gd" id="4_tbgi4"]
|
[ext_resource type="PackedScene" uid="uid://djgeio24bm6i4" path="res://scenes/HUD/hud.tscn" id="4_ow5a4"]
|
||||||
[ext_resource type="Script" uid="uid://cmoqidhmxlccq" path="res://scenes/HUD/options_menu.gd" id="5_tefeu"]
|
[ext_resource type="Script" uid="uid://cm0m3up5ufny2" path="res://scenes/HUD/information_panel.gd" id="5_hujxm"]
|
||||||
[ext_resource type="Script" uid="uid://dskaddldr1q0x" path="res://scenes/main/EntityManager.cs" id="6_ow5a4"]
|
[ext_resource type="Script" uid="uid://dskaddldr1q0x" path="res://scenes/main/EntityManager.cs" id="6_ow5a4"]
|
||||||
|
|
||||||
[node name="Main" type="Node"]
|
[node name="Main" type="Node"]
|
||||||
script = ExtResource("1_6q06x")
|
script = ExtResource("1_6q06x")
|
||||||
|
|
||||||
[node name="World" parent="." instance=ExtResource("1_o5qli")]
|
[node name="World" parent="." instance=ExtResource("1_o5qli")]
|
||||||
NoiseSeed = 5
|
Algorithm = 2
|
||||||
NoiseFrequency = 0.32
|
NoiseType = 3
|
||||||
NoiseOffset = Vector3(0.04, 0, 0)
|
NoiseSeed = 521632
|
||||||
|
NoiseFrequency = 0.03
|
||||||
NoiseFractalType = 2
|
NoiseFractalType = 2
|
||||||
NoiseFractalOctaves = 10
|
|
||||||
NoiseFractalLacunarity = 0.395
|
|
||||||
NoiseFractalGain = 0.26
|
|
||||||
NoiseFractalWeightedStrength = 0.355
|
|
||||||
|
|
||||||
[node name="Spawner" parent="World" index="1"]
|
[node name="Grid" parent="World" index="3"]
|
||||||
position = Vector2(482.81, 501.18)
|
show_debug = false
|
||||||
|
show_grid = false
|
||||||
[node name="Grid" type="Node2D" parent="."]
|
show_label = false
|
||||||
script = ExtResource("3_hujxm")
|
|
||||||
show_debug = true
|
|
||||||
|
|
||||||
[node name="Debug" type="Node2D" parent="Grid"]
|
|
||||||
|
|
||||||
[node name="GlobalCamera" type="Camera2D" parent="."]
|
[node name="GlobalCamera" type="Camera2D" parent="."]
|
||||||
drag_left_margin = 0.5
|
drag_left_margin = 0.5
|
||||||
@@ -36,108 +28,23 @@ drag_top_margin = 0.5
|
|||||||
drag_right_margin = 0.5
|
drag_right_margin = 0.5
|
||||||
drag_bottom_margin = 0.5
|
drag_bottom_margin = 0.5
|
||||||
script = ExtResource("3_ow5a4")
|
script = ExtResource("3_ow5a4")
|
||||||
|
cameraStepSize = 200.0
|
||||||
|
|
||||||
[node name="HUD" type="CanvasLayer" parent="."]
|
[node name="HUD" parent="." instance=ExtResource("4_ow5a4")]
|
||||||
|
|
||||||
[node name="MenuBar" type="MenuBar" parent="HUD"]
|
[node name="Info" parent="HUD/MenuBar" index="3"]
|
||||||
anchors_preset = 10
|
item_count = 3
|
||||||
anchor_right = 1.0
|
item_2/text = "Close"
|
||||||
grow_horizontal = 2
|
item_2/id = 2
|
||||||
script = ExtResource("4_tbgi4")
|
|
||||||
|
|
||||||
[node name="Entity" type="PopupMenu" parent="HUD/MenuBar"]
|
[node name="InformationPanel" parent="HUD" index="4"]
|
||||||
auto_translate_mode = 1
|
custom_minimum_size = Vector2(100, 0)
|
||||||
size = Vector2i(109, 100)
|
script = ExtResource("5_hujxm")
|
||||||
|
|
||||||
[node name="Spawn" type="PopupMenu" parent="HUD/MenuBar"]
|
|
||||||
size = Vector2i(109, 100)
|
|
||||||
item_count = 2
|
|
||||||
item_0/text = "Fly"
|
|
||||||
item_0/id = 0
|
|
||||||
item_1/text = "Bumblebee"
|
|
||||||
item_1/id = 1
|
|
||||||
|
|
||||||
[node name="Options" type="PopupMenu" parent="HUD/MenuBar"]
|
|
||||||
item_count = 2
|
|
||||||
item_0/text = "Camera"
|
|
||||||
item_0/id = 0
|
|
||||||
item_1/text = "World"
|
|
||||||
item_1/id = 1
|
|
||||||
script = ExtResource("5_tefeu")
|
|
||||||
|
|
||||||
[node name="Camera" type="PopupMenu" parent="HUD/MenuBar/Options"]
|
|
||||||
item_count = 2
|
|
||||||
item_0/text = "Speed"
|
|
||||||
item_0/id = 0
|
|
||||||
item_1/text = "Position"
|
|
||||||
item_1/id = 1
|
|
||||||
|
|
||||||
[node name="World" type="PopupMenu" parent="HUD/MenuBar/Options"]
|
|
||||||
auto_translate_mode = 1
|
|
||||||
item_count = 1
|
|
||||||
item_0/text = "Generate"
|
|
||||||
item_0/id = 0
|
|
||||||
|
|
||||||
[node name="SpawnMenuButton" type="MenuButton" parent="HUD"]
|
|
||||||
visible = false
|
|
||||||
anchors_preset = 2
|
|
||||||
anchor_top = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
offset_top = -31.0
|
|
||||||
offset_right = 60.0
|
|
||||||
grow_vertical = 0
|
|
||||||
text = "Spawn"
|
|
||||||
item_count = 2
|
|
||||||
popup/item_0/text = "Fly"
|
|
||||||
popup/item_0/id = 0
|
|
||||||
popup/item_1/text = "Bumblebee"
|
|
||||||
popup/item_1/id = 1
|
|
||||||
|
|
||||||
[node name="Button" type="Button" parent="HUD"]
|
|
||||||
visible = false
|
|
||||||
anchors_preset = 7
|
|
||||||
anchor_left = 0.5
|
|
||||||
anchor_top = 1.0
|
|
||||||
anchor_right = 0.5
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
offset_left = -42.5
|
|
||||||
offset_top = -31.0
|
|
||||||
offset_right = 42.5
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 0
|
|
||||||
text = "Spawn Fly"
|
|
||||||
|
|
||||||
[node name="GenerateWorldButton" type="Button" parent="HUD"]
|
|
||||||
anchors_preset = 3
|
|
||||||
anchor_left = 1.0
|
|
||||||
anchor_top = 1.0
|
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
offset_left = -131.0
|
|
||||||
offset_top = -31.0
|
|
||||||
grow_horizontal = 0
|
|
||||||
grow_vertical = 0
|
|
||||||
text = "Regenerate World"
|
|
||||||
|
|
||||||
[node name="InformationMarginContainer" type="MarginContainer" parent="HUD"]
|
|
||||||
anchors_preset = 12
|
|
||||||
anchor_top = 1.0
|
|
||||||
anchor_right = 1.0
|
|
||||||
anchor_bottom = 1.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 0
|
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HBoxContainer" parent="HUD/InformationMarginContainer"]
|
|
||||||
layout_mode = 2
|
|
||||||
|
|
||||||
[node name="EntityInformationContainer" type="VBoxContainer" parent="HUD/InformationMarginContainer/HBoxContainer"]
|
|
||||||
layout_mode = 2
|
|
||||||
|
|
||||||
[node name="EntityManager" type="Node" parent="."]
|
[node name="EntityManager" type="Node" parent="."]
|
||||||
script = ExtResource("6_ow5a4")
|
script = ExtResource("6_ow5a4")
|
||||||
|
|
||||||
[connection signal="index_pressed" from="HUD/MenuBar/Options" to="HUD/MenuBar" method="options_index_pressed"]
|
[connection signal="index_pressed" from="HUD/MenuBar/Info" to="HUD/MenuBar" method="info_index_pressed"]
|
||||||
[connection signal="pressed" from="HUD/Button" to="." method="spawn_fly"]
|
|
||||||
[connection signal="pressed" from="HUD/GenerateWorldButton" to="World" method="GenerateWorld"]
|
|
||||||
|
|
||||||
[editable path="World"]
|
[editable path="World"]
|
||||||
|
[editable path="HUD"]
|
||||||
|
|||||||
@@ -1,85 +1,130 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
|
using Godot.Collections;
|
||||||
|
|
||||||
public partial class World : Node2D
|
public partial class World : Node2D
|
||||||
{
|
{
|
||||||
public enum GeneratorAlgorithm
|
public enum GeneratorAlgorithm
|
||||||
{
|
{
|
||||||
RANDOM,
|
Random,
|
||||||
FAST_NOISE_LITE,
|
Simple,
|
||||||
COMPLEX
|
Complex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Vector2I darkGras = new Vector2I(0, 0);
|
Vector2I _darkGras = new Vector2I(0, 0);
|
||||||
Vector2I brightGras = new Vector2I(1, 0);
|
Vector2I _brightGras = new Vector2I(1, 0);
|
||||||
Vector2I flower = new Vector2I(2, 0);
|
Vector2I _flower = new Vector2I(2, 0);
|
||||||
TileMapLayer tileMapLayer;
|
TileMapLayer _tileMapLayer;
|
||||||
|
|
||||||
Vector2 screenSize;
|
Vector2 _screenSize;
|
||||||
float worldWidth;
|
float _worldWidth;
|
||||||
float worldHeight;
|
float _worldHeight;
|
||||||
|
private Vector2I _tileSize;
|
||||||
|
private Timer _generationTimeout;
|
||||||
|
|
||||||
private Timer generationTimeout;
|
[Export] public GeneratorAlgorithm Algorithm = GeneratorAlgorithm.Random;
|
||||||
|
|
||||||
[Export] GeneratorAlgorithm algorithm = GeneratorAlgorithm.RANDOM;
|
private void GenerateGrid()
|
||||||
|
{
|
||||||
|
Dictionary grid = new Dictionary();
|
||||||
|
for (int x = 0; x < _worldHeight; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < _worldWidth; y++)
|
||||||
|
{
|
||||||
|
// grid[new Vector2(x, y)] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector2 gridToWorld(Vector2 pos) => pos * _tileSize.X;
|
||||||
|
// private Vector2 worldToGrid(Vector2 pos) => Godot.Mathf.Floor(pos / _tileSize.X);
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
screenSize = GetViewportRect().Size;
|
GD.Print("World Node Ready");
|
||||||
worldWidth = screenSize.X;
|
|
||||||
worldHeight = screenSize.Y;
|
|
||||||
|
|
||||||
tileMapLayer = GetNode<TileMapLayer>("TileMapLayer");
|
GD.Print("Getting Screen Size");
|
||||||
|
_screenSize = GetViewportRect().Size;
|
||||||
|
GD.Print("Setting World Size");
|
||||||
|
_worldWidth = _screenSize.X;
|
||||||
|
_worldHeight = _screenSize.Y;
|
||||||
|
|
||||||
generationTimeout = GetNode<Timer>("GenerationTimeout");
|
GD.Print("Getting Tilemap Layer and Setting Tile Size");
|
||||||
|
_tileMapLayer = GetNode<TileMapLayer>("TileMapLayer");
|
||||||
|
_tileSize = _tileMapLayer.TileSet.TileSize;
|
||||||
|
|
||||||
|
GD.Print("Getting Timer");
|
||||||
|
_generationTimeout = GetNode<Timer>("GenerationTimeout");
|
||||||
|
|
||||||
|
// Grid generation
|
||||||
|
GD.Print("Setting Grid Properties");
|
||||||
|
Node2D grid = GetNode<Node2D>("Grid");
|
||||||
|
grid.Set("width", _worldHeight / _tileSize.X);
|
||||||
|
grid.Set("height", _worldHeight / _tileSize.Y);
|
||||||
|
grid.Set("cell_size", _tileSize);
|
||||||
|
GD.Print("Calling generateGrid");
|
||||||
|
grid.Call("generateGrid");
|
||||||
|
|
||||||
|
GD.Print("Randomizing Seed");
|
||||||
GD.Randomize();
|
GD.Randomize();
|
||||||
GenerateWorld();
|
|
||||||
|
// World generation
|
||||||
|
GD.Print("Generating World");
|
||||||
|
if (_generationTimeout.IsNodeReady())
|
||||||
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
// public override void _Process(double delta)
|
||||||
{
|
// {
|
||||||
GD.Print(algorithm);
|
// GD.Print(algorithm);
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
|
||||||
private void GenerateWorld()
|
private void GenerateWorld()
|
||||||
{
|
{
|
||||||
if (generationTimeout.IsStopped())
|
try
|
||||||
{
|
{
|
||||||
switch (algorithm)
|
if (_generationTimeout.IsStopped())
|
||||||
{
|
{
|
||||||
case GeneratorAlgorithm.RANDOM:
|
switch (Algorithm)
|
||||||
GenerateWorldRandom();
|
{
|
||||||
break;
|
case GeneratorAlgorithm.Random:
|
||||||
case GeneratorAlgorithm.FAST_NOISE_LITE:
|
GenerateWorldRandom();
|
||||||
GenerateWorldSimplexNoise();
|
break;
|
||||||
break;
|
case GeneratorAlgorithm.Simple:
|
||||||
case GeneratorAlgorithm.COMPLEX:
|
GenerateWorldSimplexNoise();
|
||||||
GenerateWorldComplex();
|
break;
|
||||||
break;
|
case GeneratorAlgorithm.Complex:
|
||||||
default:
|
GenerateWorldComplex();
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_generationTimeout.Start();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
GD.PrintErr(e);
|
||||||
}
|
}
|
||||||
generationTimeout.Start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GenerateWorldRandom()
|
private void GenerateWorldRandom()
|
||||||
{
|
{
|
||||||
for (int y = 0; y < worldHeight; y++)
|
for (int y = 0; y < _worldHeight; y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < worldWidth; x++)
|
for (int x = 0; x < _worldWidth; x++)
|
||||||
{
|
{
|
||||||
float rnd = GD.Randf();
|
float rnd = GD.Randf();
|
||||||
|
|
||||||
if (rnd < .7f)
|
if (rnd < .7f)
|
||||||
tileMapLayer.SetCell(new Vector2I(x, y), 0, darkGras);
|
_tileMapLayer.SetCell(new Vector2I(x, y), 0, _darkGras);
|
||||||
else if (rnd < .9f)
|
else if (rnd < .9f)
|
||||||
tileMapLayer.SetCell(new Vector2I(x, y), 0, brightGras);
|
_tileMapLayer.SetCell(new Vector2I(x, y), 0, _brightGras);
|
||||||
else
|
else
|
||||||
tileMapLayer.SetCell(new Vector2I(x, y), 0, flower);
|
_tileMapLayer.SetCell(new Vector2I(x, y), 0, _flower);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,9 +136,9 @@ public partial class World : Node2D
|
|||||||
noise.Seed = GD.RandRange(int.MinValue, int.MaxValue);
|
noise.Seed = GD.RandRange(int.MinValue, int.MaxValue);
|
||||||
noise.FractalOctaves = 2;
|
noise.FractalOctaves = 2;
|
||||||
|
|
||||||
for (int y = 0; y < worldHeight; y++)
|
for (int y = 0; y < _worldHeight; y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < worldWidth; x++)
|
for (int x = 0; x < _worldWidth; x++)
|
||||||
{
|
{
|
||||||
var rnd = noise.GetNoise2D(x, y);
|
var rnd = noise.GetNoise2D(x, y);
|
||||||
|
|
||||||
@@ -101,11 +146,11 @@ public partial class World : Node2D
|
|||||||
// var yRnd = noise.GetNoise1D(y);
|
// var yRnd = noise.GetNoise1D(y);
|
||||||
|
|
||||||
if (rnd < .3f)
|
if (rnd < .3f)
|
||||||
tileMapLayer.SetCell(new Vector2I(x, y), 0, darkGras);
|
_tileMapLayer.SetCell(new Vector2I(x, y), 0, _darkGras);
|
||||||
else if (rnd < .6f)
|
else if (rnd < .6f)
|
||||||
tileMapLayer.SetCell(new Vector2I(x, y), 0, brightGras);
|
_tileMapLayer.SetCell(new Vector2I(x, y), 0, _brightGras);
|
||||||
else
|
else
|
||||||
tileMapLayer.SetCell(new Vector2I(x, y), 0, flower);
|
_tileMapLayer.SetCell(new Vector2I(x, y), 0, _flower);
|
||||||
|
|
||||||
|
|
||||||
// if (yRnd < .3f)
|
// if (yRnd < .3f)
|
||||||
@@ -118,18 +163,8 @@ public partial class World : Node2D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _noiseSeed;
|
|
||||||
[Export] public int NoiseSeed
|
|
||||||
{
|
|
||||||
get => _noiseSeed;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_noiseSeed = value;
|
|
||||||
GenerateWorld();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private FastNoiseLite.NoiseTypeEnum _noiseType;
|
[ExportGroup("General")]
|
||||||
[Export]
|
[Export]
|
||||||
public FastNoiseLite.NoiseTypeEnum NoiseType
|
public FastNoiseLite.NoiseTypeEnum NoiseType
|
||||||
{
|
{
|
||||||
@@ -140,205 +175,235 @@ public partial class World : Node2D
|
|||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[Export] public int NoiseSeed
|
||||||
[Export] public float NoiseFrequency
|
|
||||||
{
|
{
|
||||||
get => noiseFrequency;
|
get => _noiseSeed;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
noiseFrequency = value;
|
_noiseSeed = value;
|
||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export] public Vector3 NoiseOffset
|
[Export] public Vector3 NoiseOffset
|
||||||
{
|
{
|
||||||
get => noiseOffset;
|
get => _noiseOffset;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
noiseOffset = value;
|
_noiseOffset = value;
|
||||||
|
GenerateWorld();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[ExportGroup("Perlin and Simplex")]
|
||||||
|
[Export] public float NoiseFrequency
|
||||||
|
{
|
||||||
|
get => _noiseFrequency;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_noiseFrequency = value;
|
||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export] public FastNoiseLite.FractalTypeEnum NoiseFractalType
|
[Export] public FastNoiseLite.FractalTypeEnum NoiseFractalType
|
||||||
{
|
{
|
||||||
get => noiseFractalType;
|
get => _noiseFractalType;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
noiseFractalType = value;
|
_noiseFractalType = value;
|
||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export] public int NoiseFractalOctaves
|
[Export] public int NoiseFractalOctaves
|
||||||
{
|
{
|
||||||
get => noiseFractalOctaves;
|
get => _noiseFractalOctaves;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
noiseFractalOctaves = value;
|
_noiseFractalOctaves = value;
|
||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export] public float NoiseFractalLacunarity
|
[Export] public float NoiseFractalLacunarity
|
||||||
{
|
{
|
||||||
get => noiseFractalLacunarity;
|
get => _noiseFractalLacunarity;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
noiseFractalLacunarity = value;
|
_noiseFractalLacunarity = value;
|
||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export] public float NoiseFractalGain
|
[Export] public float NoiseFractalGain
|
||||||
{
|
{
|
||||||
get => noiseFractalGain;
|
get => _noiseFractalGain;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
noiseFractalGain = value;
|
_noiseFractalGain = value;
|
||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export] public float NoiseFractalWeightedStrength
|
[Export] public float NoiseFractalWeightedStrength
|
||||||
{
|
{
|
||||||
get => noiseFractalWeightedStrength;
|
get => _noiseFractalWeightedStrength;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
noiseFractalWeightedStrength = value;
|
_noiseFractalWeightedStrength = value;
|
||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export] public float NoiseFractalPingPongStrength
|
[Export] public float NoiseFractalPingPongStrength
|
||||||
{
|
{
|
||||||
get => noiseFractalPingPongStrength;
|
get => _noiseFractalPingPongStrength;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
noiseFractalPingPongStrength = value;
|
_noiseFractalPingPongStrength = value;
|
||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ExportGroup("Cellular")]
|
||||||
[Export] public float NoiseCellularJitter
|
[Export] public float NoiseCellularJitter
|
||||||
{
|
{
|
||||||
get => noiseCellularJitter;
|
get => _noiseCellularJitter;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
noiseCellularJitter = value;
|
_noiseCellularJitter = value;
|
||||||
|
GenerateWorld();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public FastNoiseLite.CellularDistanceFunctionEnum NoiseCellularDistanceFunction
|
||||||
|
{
|
||||||
|
get => _noiseCellularDistanceFunction;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_noiseCellularDistanceFunction = value;
|
||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export] public FastNoiseLite.CellularReturnTypeEnum NoiseCellularReturnType
|
[Export] public FastNoiseLite.CellularReturnTypeEnum NoiseCellularReturnType
|
||||||
{
|
{
|
||||||
get => noiseCellularReturnType;
|
get => _noiseCellularReturnType;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
noiseCellularReturnType = value;
|
_noiseCellularReturnType = value;
|
||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ExportGroup("Domain Warp")]
|
||||||
[Export] public bool NoiseDomainWarpEnabled
|
[Export] public bool NoiseDomainWarpEnabled
|
||||||
{
|
{
|
||||||
get => noiseDomainWarpEnabled;
|
get => _noiseDomainWarpEnabled;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
noiseDomainWarpEnabled = value;
|
_noiseDomainWarpEnabled = value;
|
||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export] public FastNoiseLite.DomainWarpTypeEnum NoiseDomainWarpType
|
[Export] public FastNoiseLite.DomainWarpTypeEnum NoiseDomainWarpType
|
||||||
{
|
{
|
||||||
get => noiseDomainWarpType;
|
get => _noiseDomainWarpType;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
noiseDomainWarpType = value;
|
_noiseDomainWarpType = value;
|
||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export] public float NoiseDomainWarpAmplitude
|
[Export] public float NoiseDomainWarpAmplitude
|
||||||
{
|
{
|
||||||
get => noiseDomainWarpAmplitude;
|
get => _noiseDomainWarpAmplitude;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
noiseDomainWarpAmplitude = value;
|
_noiseDomainWarpAmplitude = value;
|
||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export] public float NoiseDomainWarpFrequency
|
[Export] public float NoiseDomainWarpFrequency
|
||||||
{
|
{
|
||||||
get => noiseDomainWarpFrequency;
|
get => _noiseDomainWarpFrequency;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
noiseDomainWarpFrequency = value;
|
_noiseDomainWarpFrequency = value;
|
||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export] public FastNoiseLite.DomainWarpFractalTypeEnum NoiseDomainWarpFractalType
|
[Export] public FastNoiseLite.DomainWarpFractalTypeEnum NoiseDomainWarpFractalType
|
||||||
{
|
{
|
||||||
get => noiseDomainWarpFractalType;
|
get => _noiseDomainWarpFractalType;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
noiseDomainWarpFractalType = value;
|
_noiseDomainWarpFractalType = value;
|
||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export] public int NoiseDomainWarpFractalOctaves
|
[Export] public int NoiseDomainWarpFractalOctaves
|
||||||
{
|
{
|
||||||
get => noiseDomainWarpFractalOctaves;
|
get => _noiseDomainWarpFractalOctaves;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
noiseDomainWarpFractalOctaves = value;
|
_noiseDomainWarpFractalOctaves = value;
|
||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export] public float NoiseDomainWarpFractalLacunarity
|
[Export] public float NoiseDomainWarpFractalLacunarity
|
||||||
{
|
{
|
||||||
get => noiseDomainWarpFractalLacunarity;
|
get => _noiseDomainWarpFractalLacunarity;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
noiseDomainWarpFractalLacunarity = value;
|
_noiseDomainWarpFractalLacunarity = value;
|
||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export] public float NoiseDomainWarpFractalGain
|
[Export] public float NoiseDomainWarpFractalGain
|
||||||
{
|
{
|
||||||
get => noiseDomainWarpFractalGain;
|
get => _noiseDomainWarpFractalGain;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
noiseDomainWarpFractalGain = value;
|
_noiseDomainWarpFractalGain = value;
|
||||||
GenerateWorld();
|
GenerateWorld();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float noiseFrequency;
|
// General
|
||||||
public Vector3 noiseOffset;
|
private int _noiseSeed;
|
||||||
public FastNoiseLite.FractalTypeEnum noiseFractalType;
|
private FastNoiseLite.NoiseTypeEnum _noiseType;
|
||||||
public int noiseFractalOctaves;
|
|
||||||
public float noiseFractalLacunarity;
|
// Simplex and Perlin
|
||||||
public float noiseFractalGain;
|
private float _noiseFrequency = 0.01f;
|
||||||
public float noiseFractalWeightedStrength;
|
private Vector3 _noiseOffset = new(0.0f, 0.0f, 0.0f);
|
||||||
public float noiseFractalPingPongStrength;
|
private FastNoiseLite.FractalTypeEnum _noiseFractalType = FastNoiseLite.FractalTypeEnum.Fbm;
|
||||||
public float noiseCellularJitter;
|
private int _noiseFractalOctaves = 5;
|
||||||
public FastNoiseLite.CellularReturnTypeEnum noiseCellularReturnType;
|
private float _noiseFractalLacunarity = 2.0f;
|
||||||
public bool noiseDomainWarpEnabled;
|
private float _noiseFractalGain = 0.5f;
|
||||||
public FastNoiseLite.DomainWarpTypeEnum noiseDomainWarpType;
|
private float _noiseFractalWeightedStrength = 0.0f;
|
||||||
public float noiseDomainWarpAmplitude;
|
private float _noiseFractalPingPongStrength = 2.0f;
|
||||||
public float noiseDomainWarpFrequency;
|
|
||||||
public FastNoiseLite.DomainWarpFractalTypeEnum noiseDomainWarpFractalType;
|
// Cellular
|
||||||
public int noiseDomainWarpFractalOctaves;
|
private float _noiseCellularJitter = 1.0f;
|
||||||
public float noiseDomainWarpFractalLacunarity;
|
private FastNoiseLite.CellularDistanceFunctionEnum _noiseCellularDistanceFunction;
|
||||||
public float noiseDomainWarpFractalGain;
|
private FastNoiseLite.CellularReturnTypeEnum _noiseCellularReturnType = FastNoiseLite.CellularReturnTypeEnum.Distance;
|
||||||
|
|
||||||
|
// Domain Warp
|
||||||
|
private bool _noiseDomainWarpEnabled = false;
|
||||||
|
private FastNoiseLite.DomainWarpTypeEnum _noiseDomainWarpType = FastNoiseLite.DomainWarpTypeEnum.SimplexReduced;
|
||||||
|
private float _noiseDomainWarpAmplitude = 30.0f;
|
||||||
|
private float _noiseDomainWarpFrequency = 0.05f;
|
||||||
|
private FastNoiseLite.DomainWarpFractalTypeEnum _noiseDomainWarpFractalType =
|
||||||
|
FastNoiseLite.DomainWarpFractalTypeEnum.Progressive;
|
||||||
|
private int _noiseDomainWarpFractalOctaves = 5;
|
||||||
|
private float _noiseDomainWarpFractalLacunarity = 6.0f;
|
||||||
|
private float _noiseDomainWarpFractalGain = 0.5f;
|
||||||
|
|
||||||
private void GenerateWorldComplex()
|
private void GenerateWorldComplex()
|
||||||
{
|
{
|
||||||
@@ -350,39 +415,39 @@ public partial class World : Node2D
|
|||||||
GD.Print(noise.Seed);
|
GD.Print(noise.Seed);
|
||||||
|
|
||||||
noise.NoiseType = _noiseType;
|
noise.NoiseType = _noiseType;
|
||||||
noise.Frequency = noiseFrequency;
|
noise.Frequency = _noiseFrequency;
|
||||||
noise.Offset = noiseOffset;
|
noise.Offset = _noiseOffset;
|
||||||
noise.FractalType = noiseFractalType;
|
noise.FractalType = _noiseFractalType;
|
||||||
noise.FractalOctaves = noiseFractalOctaves;
|
noise.FractalOctaves = _noiseFractalOctaves;
|
||||||
noise.FractalLacunarity = noiseFractalLacunarity;
|
noise.FractalLacunarity = _noiseFractalLacunarity;
|
||||||
noise.FractalGain = noiseFractalGain;
|
noise.FractalGain = _noiseFractalGain;
|
||||||
noise.FractalWeightedStrength = noiseFractalWeightedStrength;
|
noise.FractalWeightedStrength = _noiseFractalWeightedStrength;
|
||||||
noise.FractalPingPongStrength = noiseFractalPingPongStrength;
|
noise.FractalPingPongStrength = _noiseFractalPingPongStrength;
|
||||||
noise.CellularJitter = noiseCellularJitter;
|
noise.CellularJitter = _noiseCellularJitter;
|
||||||
noise.CellularReturnType = noiseCellularReturnType;
|
noise.CellularReturnType = _noiseCellularReturnType;
|
||||||
noise.DomainWarpEnabled = noiseDomainWarpEnabled;
|
noise.DomainWarpEnabled = _noiseDomainWarpEnabled;
|
||||||
noise.DomainWarpType = noiseDomainWarpType;
|
noise.DomainWarpType = _noiseDomainWarpType;
|
||||||
noise.DomainWarpAmplitude = noiseDomainWarpAmplitude;
|
noise.DomainWarpAmplitude = _noiseDomainWarpAmplitude;
|
||||||
noise.DomainWarpFrequency = noiseDomainWarpFrequency;
|
noise.DomainWarpFrequency = _noiseDomainWarpFrequency;
|
||||||
noise.DomainWarpFractalType = noiseDomainWarpFractalType;
|
noise.DomainWarpFractalType = _noiseDomainWarpFractalType;
|
||||||
noise.DomainWarpFractalOctaves = noiseDomainWarpFractalOctaves;
|
noise.DomainWarpFractalOctaves = _noiseDomainWarpFractalOctaves;
|
||||||
noise.DomainWarpFractalLacunarity = noiseDomainWarpFractalLacunarity;
|
noise.DomainWarpFractalLacunarity = _noiseDomainWarpFractalLacunarity;
|
||||||
noise.DomainWarpFractalGain = noiseDomainWarpFractalGain;
|
noise.DomainWarpFractalGain = _noiseDomainWarpFractalGain;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int y = 0; y < worldHeight; y++)
|
for (int y = 0; y < _worldHeight; y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < worldWidth; x++)
|
for (int x = 0; x < _worldWidth; x++)
|
||||||
{
|
{
|
||||||
var rnd = noise.GetNoise2D(x, y);
|
var rnd = noise.GetNoise2D(x, y);
|
||||||
|
|
||||||
if (rnd < .3f)
|
if (rnd < .3f)
|
||||||
tileMapLayer.SetCell(new Vector2I(x, y), 0, darkGras);
|
_tileMapLayer.SetCell(new Vector2I(x, y), 0, _darkGras);
|
||||||
else if (rnd < .6f)
|
else if (rnd < .6f)
|
||||||
tileMapLayer.SetCell(new Vector2I(x, y), 0, brightGras);
|
_tileMapLayer.SetCell(new Vector2I(x, y), 0, _brightGras);
|
||||||
else
|
else
|
||||||
tileMapLayer.SetCell(new Vector2I(x, y), 0, flower);
|
_tileMapLayer.SetCell(new Vector2I(x, y), 0, _flower);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
[gd_scene load_steps=6 format=3 uid="uid://brbhyuelsuxyx"]
|
[gd_scene load_steps=7 format=3 uid="uid://brbhyuelsuxyx"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://d0brwy88sjvv1" path="res://art/world/grasv2.png" id="1_f3sb7"]
|
[ext_resource type="Texture2D" uid="uid://d0brwy88sjvv1" path="res://art/world/grasv2.png" id="1_f3sb7"]
|
||||||
[ext_resource type="Script" uid="uid://ctanguxj2uhw7" path="res://scenes/world/World.cs" id="1_rwgxs"]
|
[ext_resource type="Script" uid="uid://ctanguxj2uhw7" path="res://scenes/world/World.cs" id="1_rwgxs"]
|
||||||
[ext_resource type="PackedScene" uid="uid://drwdehf7caidt" path="res://scenes/spawner/spawner.tscn" id="3_1fp7r"]
|
[ext_resource type="PackedScene" uid="uid://drwdehf7caidt" path="res://scenes/spawner/spawner.tscn" id="3_1fp7r"]
|
||||||
|
[ext_resource type="Script" uid="uid://cqrt5x30j5vm6" path="res://scenes/main/grid.gd" id="4_6m72w"]
|
||||||
|
|
||||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_0xm2m"]
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_0xm2m"]
|
||||||
texture = ExtResource("1_f3sb7")
|
texture = ExtResource("1_f3sb7")
|
||||||
@@ -17,7 +18,6 @@ sources/0 = SubResource("TileSetAtlasSource_0xm2m")
|
|||||||
|
|
||||||
[node name="World" type="Node2D"]
|
[node name="World" type="Node2D"]
|
||||||
script = ExtResource("1_rwgxs")
|
script = ExtResource("1_rwgxs")
|
||||||
algorithm = 1
|
|
||||||
metadata/_edit_group_ = true
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
[node name="TileMapLayer" type="TileMapLayer" parent="."]
|
[node name="TileMapLayer" type="TileMapLayer" parent="."]
|
||||||
@@ -25,7 +25,12 @@ texture_filter = 1
|
|||||||
tile_set = SubResource("TileSet_h2yge")
|
tile_set = SubResource("TileSet_h2yge")
|
||||||
|
|
||||||
[node name="Spawner" parent="." instance=ExtResource("3_1fp7r")]
|
[node name="Spawner" parent="." instance=ExtResource("3_1fp7r")]
|
||||||
position = Vector2(50, 50)
|
|
||||||
|
|
||||||
[node name="GenerationTimeout" type="Timer" parent="."]
|
[node name="GenerationTimeout" type="Timer" parent="."]
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="Grid" type="Node2D" parent="."]
|
||||||
|
script = ExtResource("4_6m72w")
|
||||||
|
show_debug = true
|
||||||
|
|
||||||
|
[node name="Debug" type="Node2D" parent="Grid"]
|
||||||
|
|||||||
Reference in New Issue
Block a user