map editor

This commit is contained in:
James 2023-12-05 20:08:23 +00:00
parent d83bd7ce17
commit cbcda09e08
5 changed files with 57 additions and 19 deletions

2
HUD.gd
View File

@ -13,7 +13,7 @@ func _process(delta):
var seconds = int(elapsed_time) % 60 var seconds = int(elapsed_time) % 60
var time_string = "%02d:%02d:%02d" % [hours, minutes, seconds] # Format time as H:M:S var time_string = "%02d:%02d:%02d" % [hours, minutes, seconds] # Format time as H:M:S
var fps = Engine.get_frames_per_second() # Get the current FPS var fps = Engine.get_frames_per_second() # Get the current FPS
$HBoxContainer/Debug.text = time_string+" "+str(fps) + " fps" # Combine FPS and runtime into one string $HBoxContainer/HBoxContainer/Debug.text = time_string+" "+str(fps) + " fps" # Combine FPS and runtime into one string
func _on_save_pressed(): func _on_save_pressed():
$"../SaveDialog".popup_centered() $"../SaveDialog".popup_centered()

20
Map.gd
View File

@ -15,6 +15,26 @@ func _unhandled_input(event):
spawn(pos,vol) spawn(pos,vol)
func spawn(pos,vol): func spawn(pos,vol):
var r=int($"../ScreenOverlay/HUD/HBoxContainer/Colors/Red".text)
var g=int($"../ScreenOverlay/HUD/HBoxContainer/Colors/Green".text)
var b=int($"../ScreenOverlay/HUD/HBoxContainer/Colors/Blue".text)
if r+g+b>0:
spawm_pool(pos,r,g,b)
else:
spawn_player(pos,vol)
func spawm_pool(pos,red,green,blue):
var new_pool: Pool = load("res://pool.tscn").instantiate()
new_pool.position = pos
new_pool.mana_r=red
new_pool.mana_g=green
new_pool.mana_b=blue
new_pool.get_node("StaticBody2D/CollisionShape2D2").disabled=true;
#new_pool.get_node("StaticBody2D/CollisionShape2D2").set_deferred("disabled", true)
get_tree().root.get_node("Sim/Map").call_deferred("add_child",new_pool)
func spawn_player(pos,vol):
var new_player = load("res://player.tscn").instantiate() var new_player = load("res://player.tscn").instantiate()
new_player.get_node("Body2D").position = pos new_player.get_node("Body2D").position = pos

View File

@ -48,18 +48,10 @@ func _process(_delta):
func drop(): func drop():
if not is_carrying(): if not is_carrying():
return return
var new_pool: Pool = load("res://pool.tscn").instantiate() #if Pool.spawn($Body2D.position,carrying_r,carrying_g,carrying_b):
new_pool.position = $Body2D.position #carrying_r=0
new_pool.mana_r=carrying_r #carrying_g=0
new_pool.mana_g=carrying_g #carrying_b=0
new_pool.mana_b=carrying_b
new_pool.get_node("StaticBody2D/CollisionShape2D2").disabled=true;
#new_pool.get_node("StaticBody2D/CollisionShape2D2").set_deferred("disabled", true)
carrying_r=0
carrying_g=0
carrying_b=0
get_tree().root.get_node("Sim/Map").call_deferred("add_child",new_pool)
update()
func doubledrop(player: Player): func doubledrop(player: Player):
if not is_carrying() or not player.is_carrying(): if not is_carrying() or not player.is_carrying():

View File

@ -1,6 +1,6 @@
[gd_scene load_steps=6 format=3 uid="uid://bu6pswk806qv6"] [gd_scene load_steps=6 format=3 uid="uid://bu6pswk806qv6"]
[ext_resource type="Script" path="res://player.gd" id="1_kr26t"] [ext_resource type="Script" path="res://Player.gd" id="1_kr26t"]
[ext_resource type="PhysicsMaterial" uid="uid://6vo1o6je0duv" path="res://physics/no_friction.tres" id="2_5k2ia"] [ext_resource type="PhysicsMaterial" uid="uid://6vo1o6je0duv" path="res://physics/no_friction.tres" id="2_5k2ia"]
[ext_resource type="Texture2D" uid="uid://clyn507dro67" path="res://images/player.png" id="2_cxs7h"] [ext_resource type="Texture2D" uid="uid://clyn507dro67" path="res://images/player.png" id="2_cxs7h"]
[ext_resource type="Script" path="res://Body2D.gd" id="3_rse87"] [ext_resource type="Script" path="res://Body2D.gd" id="3_rse87"]

View File

@ -26,15 +26,41 @@ script = ExtResource("5_pfkj4")
[node name="HBoxContainer" type="HBoxContainer" parent="ScreenOverlay/HUD"] [node name="HBoxContainer" type="HBoxContainer" parent="ScreenOverlay/HUD"]
layout_mode = 2 layout_mode = 2
[node name="Debug" type="Label" parent="ScreenOverlay/HUD/HBoxContainer"] [node name="HBoxContainer" type="HBoxContainer" parent="ScreenOverlay/HUD/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 2
[node name="Debug" type="Label" parent="ScreenOverlay/HUD/HBoxContainer/HBoxContainer"]
layout_mode = 2 layout_mode = 2
text = "debug" text = "debug"
[node name="Load" type="Button" parent="ScreenOverlay/HUD/HBoxContainer"] [node name="Colors" type="HBoxContainer" parent="ScreenOverlay/HUD/HBoxContainer"]
layout_mode = 2
[node name="Red" type="LineEdit" parent="ScreenOverlay/HUD/HBoxContainer/Colors"]
layout_mode = 2
placeholder_text = "Red"
max_length = 5
[node name="Green" type="LineEdit" parent="ScreenOverlay/HUD/HBoxContainer/Colors"]
layout_mode = 2
placeholder_text = "Green"
max_length = 5
[node name="Blue" type="LineEdit" parent="ScreenOverlay/HUD/HBoxContainer/Colors"]
layout_mode = 2
placeholder_text = "Blue"
max_length = 5
[node name="HBoxContainer3" type="HBoxContainer" parent="ScreenOverlay/HUD/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 10
[node name="Load" type="Button" parent="ScreenOverlay/HUD/HBoxContainer/HBoxContainer3"]
layout_mode = 2 layout_mode = 2
text = "Load..." text = "Load..."
[node name="Save" type="Button" parent="ScreenOverlay/HUD/HBoxContainer"] [node name="Save" type="Button" parent="ScreenOverlay/HUD/HBoxContainer/HBoxContainer3"]
layout_mode = 2 layout_mode = 2
text = "Save..." text = "Save..."
@ -69,8 +95,8 @@ wait_time = 60.0
autostart = true autostart = true
script = ExtResource("3_7b3mn") script = ExtResource("3_7b3mn")
[connection signal="pressed" from="ScreenOverlay/HUD/HBoxContainer/Load" to="ScreenOverlay/HUD" method="_on_load_pressed"] [connection signal="pressed" from="ScreenOverlay/HUD/HBoxContainer/HBoxContainer3/Load" to="ScreenOverlay/HUD" method="_on_load_pressed"]
[connection signal="pressed" from="ScreenOverlay/HUD/HBoxContainer/Save" to="ScreenOverlay/HUD" method="_on_save_pressed"] [connection signal="pressed" from="ScreenOverlay/HUD/HBoxContainer/HBoxContainer3/Save" to="ScreenOverlay/HUD" method="_on_save_pressed"]
[connection signal="about_to_popup" from="ScreenOverlay/LoadDialog" to="ScreenOverlay/LoadDialog" method="_on_about_to_popup"] [connection signal="about_to_popup" from="ScreenOverlay/LoadDialog" to="ScreenOverlay/LoadDialog" method="_on_about_to_popup"]
[connection signal="confirmed" from="ScreenOverlay/LoadDialog" to="ScreenOverlay/LoadDialog" method="_on_confirmed"] [connection signal="confirmed" from="ScreenOverlay/LoadDialog" to="ScreenOverlay/LoadDialog" method="_on_confirmed"]
[connection signal="about_to_popup" from="ScreenOverlay/SaveDialog" to="ScreenOverlay/SaveDialog" method="_on_about_to_popup"] [connection signal="about_to_popup" from="ScreenOverlay/SaveDialog" to="ScreenOverlay/SaveDialog" method="_on_about_to_popup"]