summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2022-06-03 21:13:19 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2022-06-03 21:13:19 -0600
commitf922fe4669080d1633e0a345a3f8981867c9e841 (patch)
tree7c2c98bfca20fda37fe34ba99e2d3caa9a39ca02 /src/ui
parent898877f09808691a5e5d45850d27ae85f270db16 (diff)
add working world gen, fixed food placing, minor refactoring
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/UI.tscn32
-rw-r--r--src/ui/ui.gd9
2 files changed, 34 insertions, 7 deletions
diff --git a/src/ui/UI.tscn b/src/ui/UI.tscn
index f5b0ac3..207a5fa 100644
--- a/src/ui/UI.tscn
+++ b/src/ui/UI.tscn
@@ -1,6 +1,7 @@
-[gd_scene load_steps=2 format=2]
+[gd_scene load_steps=3 format=2]
[ext_resource path="res://ui/ui.gd" type="Script" id=1]
+[ext_resource path="res://fonts/MonogramExtended.tres" type="DynamicFont" id=2]
[node name="UI" type="CanvasLayer"]
script = ExtResource( 1 )
@@ -12,13 +13,30 @@ anchor_bottom = 1.0
[node name="StatsHUD" type="MarginContainer" parent="Root"]
margin_left = 10.0
margin_top = 10.0
-margin_right = 310.0
-margin_bottom = 110.0
+margin_right = 130.0
+margin_bottom = 50.0
[node name="VBox" type="VBoxContainer" parent="Root/StatsHUD"]
-margin_right = 300.0
-margin_bottom = 100.0
+margin_right = 120.0
+margin_bottom = 40.0
[node name="SnakeSize" type="Label" parent="Root/StatsHUD/VBox"]
-margin_right = 300.0
-margin_bottom = 14.0
+margin_right = 120.0
+margin_bottom = 13.0
+custom_fonts/font = ExtResource( 2 )
+
+[node name="MarginContainer" type="MarginContainer" parent="Root"]
+anchor_top = 1.0
+anchor_right = 1.0
+anchor_bottom = 1.0
+margin_top = -20.0
+
+[node name="CenterContainer" type="CenterContainer" parent="Root/MarginContainer"]
+margin_right = 320.0
+margin_bottom = 20.0
+
+[node name="Start" type="Button" parent="Root/MarginContainer/CenterContainer"]
+margin_left = 139.0
+margin_right = 180.0
+margin_bottom = 20.0
+text = "Start"
diff --git a/src/ui/ui.gd b/src/ui/ui.gd
index cb7353e..8132d52 100644
--- a/src/ui/ui.gd
+++ b/src/ui/ui.gd
@@ -2,6 +2,7 @@ class_name UI
extends CanvasLayer
onready var _snake_size_label: Label = $Root/StatsHUD/VBox/SnakeSize
+onready var _start_button: Button = $Root/MarginContainer/CenterContainer/Start
var snake_size: int = 0
var _snake_size_fmt: String = "Snake size: %s"
@@ -11,7 +12,15 @@ func _ready():
Event.connect("snake_added_new_segment", self, "_on_Snake_added_new_segment")
_snake_size_label.text =_snake_size_fmt % snake_size
+ _start_button.connect("pressed", self, "_on_start_button_pressed")
+
func _on_Snake_added_new_segment(type: String) -> void:
snake_size += 1
_snake_size_label.text =_snake_size_fmt % snake_size
+
+
+func _on_start_button_pressed() -> void:
+ _start_button.disabled = true
+ _start_button.visible = false
+ Event.emit_signal("game_start") \ No newline at end of file