summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Game.tscn24
-rw-r--r--src/Main.tscn25
-rw-r--r--src/entities/actors/snake/scripts/head.gd1
-rw-r--r--src/event.gd1
-rw-r--r--src/game.gd (renamed from src/main.gd)24
-rw-r--r--src/global.gd1
-rw-r--r--src/project.godot48
-rw-r--r--src/tools/world_generator/scripts/walker_head.gd12
-rw-r--r--src/ui/UI.tscn58
-rw-r--r--src/ui/hud/HUD.tscn42
-rw-r--r--src/ui/main_menu/scenes/MainMenu.tscn66
-rw-r--r--src/ui/main_menu/scenes/MenuOption.tscn27
-rw-r--r--src/ui/main_menu/scripts/main_menu.gd81
-rw-r--r--src/ui/main_menu/scripts/menu_option.gd35
-rw-r--r--src/ui/main_menu/sprites/selector.pngbin0 -> 231 bytes
-rw-r--r--src/ui/main_menu/sprites/selector.png.import35
-rw-r--r--src/ui/main_menu/sprites/selector1.pngbin0 -> 155 bytes
-rw-r--r--src/ui/main_menu/sprites/selector1.png.import35
-rw-r--r--src/ui/main_menu/sprites/selector2.pngbin0 -> 160 bytes
-rw-r--r--src/ui/main_menu/sprites/selector2.png.import35
-rw-r--r--src/ui/main_menu/sprites/selector3.pngbin0 -> 164 bytes
-rw-r--r--src/ui/main_menu/sprites/selector3.png.import35
-rw-r--r--src/ui/main_menu/sprites/selector4.pngbin0 -> 159 bytes
-rw-r--r--src/ui/main_menu/sprites/selector4.png.import35
-rw-r--r--src/ui/main_menu/sprites/selector5.pngbin0 -> 88 bytes
-rw-r--r--src/ui/main_menu/sprites/selector5.png.import35
-rw-r--r--src/ui/ui.gd14
27 files changed, 538 insertions, 131 deletions
diff --git a/src/Game.tscn b/src/Game.tscn
new file mode 100644
index 0000000..1709a85
--- /dev/null
+++ b/src/Game.tscn
@@ -0,0 +1,24 @@
+[gd_scene load_steps=7 format=2]
+
+[ext_resource path="res://entities/actors/snake/scenes/Snake.tscn" type="PackedScene" id=1]
+[ext_resource path="res://ui/hud/HUD.tscn" type="PackedScene" id=2]
+[ext_resource path="res://tools/score_manager/ScoreManager.tscn" type="PackedScene" id=3]
+[ext_resource path="res://entities/food/scenes/FoodManager.tscn" type="PackedScene" id=4]
+[ext_resource path="res://tools/world_generator/scenes/WorldGenerator.tscn" type="PackedScene" id=5]
+[ext_resource path="res://game.gd" type="Script" id=6]
+
+[node name="Game" type="Node2D"]
+script = ExtResource( 6 )
+
+[node name="WorldGenerator" parent="." instance=ExtResource( 5 )]
+
+[node name="ScoreManager" parent="." instance=ExtResource( 3 )]
+
+[node name="Snake" parent="." instance=ExtResource( 1 )]
+
+[node name="FoodManager" parent="." instance=ExtResource( 4 )]
+WORLD_GENERATOR_NP = NodePath("../WorldGenerator")
+
+[node name="HUDScreen" type="CanvasLayer" parent="."]
+
+[node name="HUD" parent="HUDScreen" instance=ExtResource( 2 )]
diff --git a/src/Main.tscn b/src/Main.tscn
deleted file mode 100644
index e874cc8..0000000
--- a/src/Main.tscn
+++ /dev/null
@@ -1,25 +0,0 @@
-[gd_scene load_steps=7 format=2]
-
-[ext_resource path="res://entities/actors/snake/scenes/Snake.tscn" type="PackedScene" id=1]
-[ext_resource path="res://tools/score_manager/ScoreManager.tscn" type="PackedScene" id=2]
-[ext_resource path="res://ui/UI.tscn" type="PackedScene" id=3]
-[ext_resource path="res://main.gd" type="Script" id=4]
-[ext_resource path="res://entities/food/scenes/FoodManager.tscn" type="PackedScene" id=5]
-[ext_resource path="res://tools/world_generator/scenes/WorldGenerator.tscn" type="PackedScene" id=6]
-
-[node name="Main" type="Node2D"]
-script = ExtResource( 4 )
-
-[node name="WorldGenerator" parent="." instance=ExtResource( 6 )]
-
-[node name="FoodManager" parent="." instance=ExtResource( 5 )]
-WORLD_GENERATOR_NP = NodePath("../WorldGenerator")
-
-[node name="Snake" parent="." instance=ExtResource( 1 )]
-
-[node name="ScoreManager" parent="." instance=ExtResource( 2 )]
-
-[node name="UI" parent="." instance=ExtResource( 3 )]
-__meta__ = {
-"_edit_horizontal_guides_": [ 8.0 ]
-}
diff --git a/src/entities/actors/snake/scripts/head.gd b/src/entities/actors/snake/scripts/head.gd
index 1e17b18..32847f7 100644
--- a/src/entities/actors/snake/scripts/head.gd
+++ b/src/entities/actors/snake/scripts/head.gd
@@ -46,7 +46,6 @@ func _handle_time_elapsed(delta: float) -> void:
func _on_food_eaten(properties: Dictionary) -> void:
- print("tongue food eaten")
if not tongue_sprite.visible:
tongue_sprite.visible = true
tongue_sprite.play()
diff --git a/src/event.gd b/src/event.gd
index 991b0e2..fb79a30 100644
--- a/src/event.gd
+++ b/src/event.gd
@@ -1,6 +1,7 @@
extends Node
signal game_start
+signal game_restart
signal game_over
signal snake_path_new_point(coordinates)
diff --git a/src/main.gd b/src/game.gd
index 38a0341..218d975 100644
--- a/src/main.gd
+++ b/src/game.gd
@@ -1,21 +1,17 @@
-class_name Main
-extends Node
+extends Node2D
onready var _snake: Node2D = $Snake
func _ready() -> void:
- Event.connect("game_start", self, "_on_game_start")
Event.connect("game_over", self, "_on_game_over")
+ Event.connect("game_restart", self, "_on_game_restart")
Event.connect("snake_segment_body_entered", self, "_on_snake_segment_body_entered")
- _snake_disabled(false)
- # OS.window_size = Global.GAME_SCALE * OS.window_size
-
func _input(event: InputEvent) -> void:
if event.is_action_pressed("restart"):
- get_tree().reload_current_scene()
+ Event.emit_signal("game_restart")
func _on_snake_segment_body_entered(body: Node) -> void:
@@ -23,7 +19,7 @@ func _on_snake_segment_body_entered(body: Node) -> void:
Event.emit_signal("game_over")
-func _snake_disabled(on_off: bool) -> void:
+func _snake_set_process(on_off: bool) -> void:
_snake.propagate_call("set_process", [on_off])
_snake.propagate_call("set_process_internal", [on_off])
_snake.propagate_call("set_physics_process", [on_off])
@@ -31,11 +27,11 @@ func _snake_disabled(on_off: bool) -> void:
_snake.propagate_call("set_process_input", [on_off])
-func _on_game_start() -> void:
- print("game start")
- _snake_disabled(true)
+func _on_game_over() -> void:
+ print("game_over")
+ _snake_set_process(false)
-func _on_game_over() -> void:
- print("game over")
- _snake_disabled(false)
+func _on_game_restart() -> void:
+ print("game_restart")
+ get_tree().change_scene_to(Global.GAME_NODE) \ No newline at end of file
diff --git a/src/global.gd b/src/global.gd
index 1ed4d29..59fd4bd 100644
--- a/src/global.gd
+++ b/src/global.gd
@@ -1,5 +1,6 @@
extends Node
+var GAME_NODE: PackedScene = preload("res://Game.tscn")
var GAME_SCALE: float = 2.0
var TILE_SIZE: int = 16
var WORLD_TILE_PATH: int = 0
diff --git a/src/project.godot b/src/project.godot
index 159bfd5..5ea911a 100644
--- a/src/project.godot
+++ b/src/project.godot
@@ -39,20 +39,15 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://addons/GifMaker/GifRectangle.gd"
}, {
-"base": "Node",
-"class": "Main",
+"base": "CenterContainer",
+"class": "MenuOption",
"language": "GDScript",
-"path": "res://main.gd"
+"path": "res://ui/main_menu/scripts/menu_option.gd"
}, {
"base": "Node2D",
"class": "Snake",
"language": "GDScript",
"path": "res://entities/actors/snake/scripts/snake.gd"
-}, {
-"base": "CanvasLayer",
-"class": "UI",
-"language": "GDScript",
-"path": "res://ui/ui.gd"
} ]
_global_script_class_icons={
"Food": "",
@@ -61,15 +56,14 @@ _global_script_class_icons={
"GifDecoder": "",
"GifRecorder": "res://addons/GifMaker/gif.svg",
"GifRectangle": "res://addons/GifMaker/GifRectangle.svg",
-"Main": "",
-"Snake": "",
-"UI": ""
+"MenuOption": "",
+"Snake": ""
}
[application]
config/name="GoGodotJam3"
-run/main_scene="res://Main.tscn"
+run/main_scene="res://ui/main_menu/scenes/MainMenu.tscn"
config/icon="res://icons/game.png"
[autoload]
@@ -108,6 +102,34 @@ texture={
[input]
+ui_left={
+"deadzone": 0.5,
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
+, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
+, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
+ ]
+}
+ui_right={
+"deadzone": 0.5,
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
+, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null)
+, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
+ ]
+}
+ui_up={
+"deadzone": 0.5,
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
+, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
+, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
+ ]
+}
+ui_down={
+"deadzone": 0.5,
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
+, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
+, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
+ ]
+}
move_left={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":65,"unicode":0,"echo":false,"script":null)
@@ -125,7 +147,7 @@ add_body_part={
}
restart={
"deadzone": 0.5,
-"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":0,"physical_scancode":82,"unicode":0,"echo":false,"script":null)
+"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":82,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
]
}
diff --git a/src/tools/world_generator/scripts/walker_head.gd b/src/tools/world_generator/scripts/walker_head.gd
index 3bf7e3a..dc71db1 100644
--- a/src/tools/world_generator/scripts/walker_head.gd
+++ b/src/tools/world_generator/scripts/walker_head.gd
@@ -2,8 +2,8 @@ extends Node2D
export(NodePath) var TILEMAP_NP: NodePath
export(PackedScene) var WALKER_UNIT_NP: PackedScene
-export(int, 5, 100, 1) var starting_unit_count: int = 5
-export(int, 5, 10, 1) var initial_safe_zone_size: int = 5
+export(int, 5, 100, 1) var STARTING_UNIT_COUNT: int = 5
+export(int, 3, 10, 1) var INITIAL_SAFE_ZONE_SIZE: int = 3
onready var tilemap: TileMap = get_node(TILEMAP_NP)
@@ -24,14 +24,14 @@ func _ready() -> void:
func _place_safe_zone() -> void:
- for i in initial_safe_zone_size:
- for j in initial_safe_zone_size:
+ var size: int = INITIAL_SAFE_ZONE_SIZE
+ for i in range(-size, size):
+ for j in range(-size, size):
tilemap.set_cell(i, j, Global.WORLD_TILE_PATH)
- tilemap.set_cell(-i, -j, Global.WORLD_TILE_PATH)
func _spawn_walker_units() -> void:
- for i in starting_unit_count:
+ for i in STARTING_UNIT_COUNT:
_spawn_walker_unit(Vector2.ZERO)
diff --git a/src/ui/UI.tscn b/src/ui/UI.tscn
deleted file mode 100644
index 79d8f93..0000000
--- a/src/ui/UI.tscn
+++ /dev/null
@@ -1,58 +0,0 @@
-[gd_scene load_steps=5 format=2]
-
-[ext_resource path="res://ui/ui.gd" type="Script" id=1]
-[ext_resource path="res://ui/hud/progress_bars/sprites/grow_progress_icon.png" type="Texture" id=2]
-[ext_resource path="res://ui/hud/snake/scenes/SnakeHUD.tscn" type="PackedScene" id=3]
-[ext_resource path="res://ui/hud/progress_bars/scenes/GrowthProgress.tscn" type="PackedScene" id=4]
-
-[node name="UI" type="CanvasLayer"]
-script = ExtResource( 1 )
-
-[node name="Root" type="Control" parent="."]
-anchor_right = 1.0
-anchor_bottom = 1.0
-
-[node name="StatsHUD" type="MarginContainer" parent="Root"]
-margin_left = 4.0
-margin_top = 4.0
-margin_right = 124.0
-margin_bottom = 44.0
-
-[node name="VBox" type="VBoxContainer" parent="Root/StatsHUD"]
-custom_constants/separation = 2
-
-[node name="SnakeHUD" parent="Root/StatsHUD/VBox" instance=ExtResource( 3 )]
-margin_right = 30.0
-margin_bottom = 8.0
-
-[node name="HBoxProgressBars" type="HBoxContainer" parent="Root/StatsHUD/VBox"]
-margin_top = 10.0
-margin_right = 30.0
-margin_bottom = 18.0
-custom_constants/separation = 2
-
-[node name="GrowthProgressIcon" type="TextureRect" parent="Root/StatsHUD/VBox/HBoxProgressBars"]
-margin_right = 8.0
-margin_bottom = 8.0
-texture = ExtResource( 2 )
-
-[node name="GrowthProgress" parent="Root/StatsHUD/VBox/HBoxProgressBars" instance=ExtResource( 4 )]
-margin_left = 10.0
-margin_right = 30.0
-margin_bottom = 8.0
-
-[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/hud/HUD.tscn b/src/ui/hud/HUD.tscn
new file mode 100644
index 0000000..d30f7f5
--- /dev/null
+++ b/src/ui/hud/HUD.tscn
@@ -0,0 +1,42 @@
+[gd_scene load_steps=4 format=2]
+
+[ext_resource path="res://ui/hud/progress_bars/sprites/grow_progress_icon.png" type="Texture" id=2]
+[ext_resource path="res://ui/hud/snake/scenes/SnakeHUD.tscn" type="PackedScene" id=3]
+[ext_resource path="res://ui/hud/progress_bars/scenes/GrowthProgress.tscn" type="PackedScene" id=4]
+
+[node name="HUD" type="MarginContainer"]
+anchor_right = 1.0
+anchor_bottom = 1.0
+margin_left = 4.0
+margin_top = 4.0
+margin_right = -4.0
+margin_bottom = -4.0
+
+[node name="StatsHUD" type="MarginContainer" parent="."]
+margin_right = 312.0
+margin_bottom = 172.0
+
+[node name="VBox" type="VBoxContainer" parent="StatsHUD"]
+margin_right = 312.0
+margin_bottom = 172.0
+custom_constants/separation = 2
+
+[node name="SnakeHUD" parent="StatsHUD/VBox" instance=ExtResource( 3 )]
+margin_right = 312.0
+margin_bottom = 8.0
+
+[node name="HBoxProgressBars" type="HBoxContainer" parent="StatsHUD/VBox"]
+margin_top = 10.0
+margin_right = 312.0
+margin_bottom = 18.0
+custom_constants/separation = 2
+
+[node name="GrowthProgressIcon" type="TextureRect" parent="StatsHUD/VBox/HBoxProgressBars"]
+margin_right = 8.0
+margin_bottom = 8.0
+texture = ExtResource( 2 )
+
+[node name="GrowthProgress" parent="StatsHUD/VBox/HBoxProgressBars" instance=ExtResource( 4 )]
+margin_left = 10.0
+margin_right = 30.0
+margin_bottom = 8.0
diff --git a/src/ui/main_menu/scenes/MainMenu.tscn b/src/ui/main_menu/scenes/MainMenu.tscn
new file mode 100644
index 0000000..249885e
--- /dev/null
+++ b/src/ui/main_menu/scenes/MainMenu.tscn
@@ -0,0 +1,66 @@
+[gd_scene load_steps=5 format=2]
+
+[ext_resource path="res://ui/main_menu/scenes/MenuOption.tscn" type="PackedScene" id=1]
+[ext_resource path="res://fonts/monogram_extended.ttf" type="DynamicFontData" id=2]
+[ext_resource path="res://ui/main_menu/scripts/main_menu.gd" type="Script" id=3]
+
+[sub_resource type="DynamicFont" id=1]
+size = 64
+font_data = ExtResource( 2 )
+
+[node name="MainMenu" type="MarginContainer"]
+anchor_right = 1.0
+anchor_bottom = 1.0
+script = ExtResource( 3 )
+START_OPTION_NP = NodePath("Center/VBox/Options/VBox/Start")
+SETTINGS_OPTION_NP = NodePath("Center/VBox/Options/VBox/Settings")
+EXIT_OPTION_NP = NodePath("Center/VBox/Options/VBox/Exit")
+
+[node name="Center" type="CenterContainer" parent="."]
+margin_right = 320.0
+margin_bottom = 180.0
+
+[node name="VBox" type="VBoxContainer" parent="Center"]
+margin_left = 64.0
+margin_top = 28.0
+margin_right = 256.0
+margin_bottom = 152.0
+custom_constants/separation = 16
+
+[node name="Title" type="CenterContainer" parent="Center/VBox"]
+margin_right = 192.0
+margin_bottom = 52.0
+
+[node name="Label" type="Label" parent="Center/VBox/Title"]
+margin_right = 192.0
+margin_bottom = 52.0
+custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
+custom_fonts/font = SubResource( 1 )
+text = "El Snake"
+
+[node name="Options" type="CenterContainer" parent="Center/VBox"]
+margin_top = 68.0
+margin_right = 192.0
+margin_bottom = 124.0
+
+[node name="VBox" type="VBoxContainer" parent="Center/VBox/Options"]
+margin_left = 56.0
+margin_right = 136.0
+margin_bottom = 56.0
+
+[node name="Start" parent="Center/VBox/Options/VBox" instance=ExtResource( 1 )]
+margin_right = 80.0
+label_text = "Start"
+selected = true
+
+[node name="Settings" parent="Center/VBox/Options/VBox" instance=ExtResource( 1 )]
+margin_top = 20.0
+margin_right = 80.0
+margin_bottom = 36.0
+label_text = "Settings"
+
+[node name="Exit" parent="Center/VBox/Options/VBox" instance=ExtResource( 1 )]
+margin_top = 40.0
+margin_right = 80.0
+margin_bottom = 56.0
+label_text = "Exit"
diff --git a/src/ui/main_menu/scenes/MenuOption.tscn b/src/ui/main_menu/scenes/MenuOption.tscn
new file mode 100644
index 0000000..d6bb05f
--- /dev/null
+++ b/src/ui/main_menu/scenes/MenuOption.tscn
@@ -0,0 +1,27 @@
+[gd_scene load_steps=3 format=2]
+
+[ext_resource path="res://fonts/MonogramExtended.tres" type="DynamicFont" id=2]
+[ext_resource path="res://ui/main_menu/scripts/menu_option.gd" type="Script" id=3]
+
+[node name="MenuOption" type="CenterContainer"]
+margin_right = 49.0
+margin_bottom = 16.0
+script = ExtResource( 3 )
+
+[node name="HBox" type="HBoxContainer" parent="."]
+margin_right = 80.0
+margin_bottom = 16.0
+
+[node name="Selector" type="TextureRect" parent="HBox"]
+margin_right = 16.0
+margin_bottom = 16.0
+rect_min_size = Vector2( 16, 16 )
+
+[node name="Label" type="Label" parent="HBox"]
+margin_left = 20.0
+margin_top = 1.0
+margin_right = 80.0
+margin_bottom = 14.0
+rect_min_size = Vector2( 60, 0 )
+custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
+custom_fonts/font = ExtResource( 2 )
diff --git a/src/ui/main_menu/scripts/main_menu.gd b/src/ui/main_menu/scripts/main_menu.gd
new file mode 100644
index 0000000..7077b68
--- /dev/null
+++ b/src/ui/main_menu/scripts/main_menu.gd
@@ -0,0 +1,81 @@
+extends MarginContainer
+
+export(NodePath) var START_OPTION_NP: NodePath
+export(NodePath) var SETTINGS_OPTION_NP: NodePath
+export(NodePath) var EXIT_OPTION_NP: NodePath
+
+onready var start_option: MenuOption = get_node(START_OPTION_NP)
+onready var settings_option: MenuOption = get_node(SETTINGS_OPTION_NP)
+onready var exit_option: MenuOption = get_node(EXIT_OPTION_NP)
+
+onready var main: Node2D = get_parent().get_parent()
+
+
+enum Option {
+ START,
+ SETTINGS,
+ EXIT
+}
+
+enum {
+ NEXT,
+ PREV
+}
+
+onready var options: Dictionary = {
+ Option.START: start_option,
+ Option.SETTINGS: settings_option,
+ Option.EXIT: exit_option
+}
+
+var current_selection: int = Option.START
+
+
+func _ready():
+ Event.connect("game_start", self, "_on_game_start")
+ start_option.type = Option.START
+ settings_option.type = Option.SETTINGS
+ exit_option.type = Option.EXIT
+
+
+func _input(event: InputEvent) -> void:
+ if event.is_action_pressed("ui_down"):
+ _menu_selection(NEXT)
+ elif event.is_action_pressed("ui_up"):
+ _menu_selection(PREV)
+
+
+ if event.is_action_pressed("ui_accept"):
+ match current_selection:
+ Option.START:
+ Event.emit_signal("game_start")
+ Option.SETTINGS:
+ print("Option TEST.")
+ Option.EXIT:
+ get_tree().quit()
+
+
+func _menu_selection(selection: int) -> void:
+ match selection:
+ NEXT:
+ current_selection += 1
+ if current_selection == Option.size():
+ current_selection = 0
+ PREV:
+ current_selection -= 1
+ if current_selection == -1:
+ current_selection = Option.size() - 1
+ _update_options()
+
+
+func _update_options() -> void:
+ for i in options:
+ if i == current_selection:
+ options[i].selected = true
+ else:
+ options[i].selected = false
+
+
+func _on_game_start() -> void:
+ print("game_start")
+ get_tree().change_scene_to(Global.GAME_NODE)
diff --git a/src/ui/main_menu/scripts/menu_option.gd b/src/ui/main_menu/scripts/menu_option.gd
new file mode 100644
index 0000000..58b4a50
--- /dev/null
+++ b/src/ui/main_menu/scripts/menu_option.gd
@@ -0,0 +1,35 @@
+class_name MenuOption
+extends CenterContainer
+
+export(String) var label_text: String
+export(bool) var selected: bool = false
+
+onready var label: Label = $HBox/Label
+onready var selector: TextureRect = $HBox/Selector
+var type: int
+
+var time_elapsed: float = 0.0
+var timer: float = 0.2
+var last_frame: int = 0
+var frames: Array = [preload("res://ui/main_menu/sprites/selector1.png"),
+ preload("res://ui/main_menu/sprites/selector2.png"),
+ preload("res://ui/main_menu/sprites/selector3.png"),
+ preload("res://ui/main_menu/sprites/selector4.png"),
+ preload("res://ui/main_menu/sprites/selector5.png")]
+
+
+func _ready():
+ label.text = label_text
+
+
+func _process(delta: float) -> void:
+ if selected:
+ if time_elapsed >= timer:
+ selector.texture = frames[last_frame]
+ last_frame += 1
+ if last_frame == frames.size() - 1:
+ last_frame = 0
+ time_elapsed = 0.0
+ time_elapsed += delta
+ else:
+ selector.texture = frames[4]
diff --git a/src/ui/main_menu/sprites/selector.png b/src/ui/main_menu/sprites/selector.png
new file mode 100644
index 0000000..48a5678
--- /dev/null
+++ b/src/ui/main_menu/sprites/selector.png
Binary files differ
diff --git a/src/ui/main_menu/sprites/selector.png.import b/src/ui/main_menu/sprites/selector.png.import
new file mode 100644
index 0000000..c327b8f
--- /dev/null
+++ b/src/ui/main_menu/sprites/selector.png.import
@@ -0,0 +1,35 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/selector.png-bd5373564ca790ce40721086d248728a.stex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://ui/main_menu/sprites/selector.png"
+dest_files=[ "res://.import/selector.png-bd5373564ca790ce40721086d248728a.stex" ]
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_mode=0
+compress/bptc_ldr=0
+compress/normal_map=0
+flags/repeat=0
+flags/filter=false
+flags/mipmaps=false
+flags/anisotropic=false
+flags/srgb=2
+process/fix_alpha_border=false
+process/premult_alpha=false
+process/HDR_as_SRGB=false
+process/invert_color=false
+process/normal_map_invert_y=false
+stream=false
+size_limit=0
+detect_3d=false
+svg/scale=1.0
diff --git a/src/ui/main_menu/sprites/selector1.png b/src/ui/main_menu/sprites/selector1.png
new file mode 100644
index 0000000..b516e93
--- /dev/null
+++ b/src/ui/main_menu/sprites/selector1.png
Binary files differ
diff --git a/src/ui/main_menu/sprites/selector1.png.import b/src/ui/main_menu/sprites/selector1.png.import
new file mode 100644
index 0000000..322198e
--- /dev/null
+++ b/src/ui/main_menu/sprites/selector1.png.import
@@ -0,0 +1,35 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/selector1.png-b6d09b162403970de2678bdb1de12abb.stex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://ui/main_menu/sprites/selector1.png"
+dest_files=[ "res://.import/selector1.png-b6d09b162403970de2678bdb1de12abb.stex" ]
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_mode=0
+compress/bptc_ldr=0
+compress/normal_map=0
+flags/repeat=0
+flags/filter=false
+flags/mipmaps=false
+flags/anisotropic=false
+flags/srgb=2
+process/fix_alpha_border=false
+process/premult_alpha=false
+process/HDR_as_SRGB=false
+process/invert_color=false
+process/normal_map_invert_y=false
+stream=false
+size_limit=0
+detect_3d=false
+svg/scale=1.0
diff --git a/src/ui/main_menu/sprites/selector2.png b/src/ui/main_menu/sprites/selector2.png
new file mode 100644
index 0000000..93547db
--- /dev/null
+++ b/src/ui/main_menu/sprites/selector2.png
Binary files differ
diff --git a/src/ui/main_menu/sprites/selector2.png.import b/src/ui/main_menu/sprites/selector2.png.import
new file mode 100644
index 0000000..6bb6018
--- /dev/null
+++ b/src/ui/main_menu/sprites/selector2.png.import
@@ -0,0 +1,35 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/selector2.png-0419bb1259e0efa492a2ce8346b72d74.stex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://ui/main_menu/sprites/selector2.png"
+dest_files=[ "res://.import/selector2.png-0419bb1259e0efa492a2ce8346b72d74.stex" ]
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_mode=0
+compress/bptc_ldr=0
+compress/normal_map=0
+flags/repeat=0
+flags/filter=false
+flags/mipmaps=false
+flags/anisotropic=false
+flags/srgb=2
+process/fix_alpha_border=false
+process/premult_alpha=false
+process/HDR_as_SRGB=false
+process/invert_color=false
+process/normal_map_invert_y=false
+stream=false
+size_limit=0
+detect_3d=false
+svg/scale=1.0
diff --git a/src/ui/main_menu/sprites/selector3.png b/src/ui/main_menu/sprites/selector3.png
new file mode 100644
index 0000000..0e468c2
--- /dev/null
+++ b/src/ui/main_menu/sprites/selector3.png
Binary files differ
diff --git a/src/ui/main_menu/sprites/selector3.png.import b/src/ui/main_menu/sprites/selector3.png.import
new file mode 100644
index 0000000..17be43b
--- /dev/null
+++ b/src/ui/main_menu/sprites/selector3.png.import
@@ -0,0 +1,35 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/selector3.png-e7eb1264fbb84184dcddc29017bcfac0.stex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://ui/main_menu/sprites/selector3.png"
+dest_files=[ "res://.import/selector3.png-e7eb1264fbb84184dcddc29017bcfac0.stex" ]
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_mode=0
+compress/bptc_ldr=0
+compress/normal_map=0
+flags/repeat=0
+flags/filter=false
+flags/mipmaps=false
+flags/anisotropic=false
+flags/srgb=2
+process/fix_alpha_border=false
+process/premult_alpha=false
+process/HDR_as_SRGB=false
+process/invert_color=false
+process/normal_map_invert_y=false
+stream=false
+size_limit=0
+detect_3d=false
+svg/scale=1.0
diff --git a/src/ui/main_menu/sprites/selector4.png b/src/ui/main_menu/sprites/selector4.png
new file mode 100644
index 0000000..7d2ee70
--- /dev/null
+++ b/src/ui/main_menu/sprites/selector4.png
Binary files differ
diff --git a/src/ui/main_menu/sprites/selector4.png.import b/src/ui/main_menu/sprites/selector4.png.import
new file mode 100644
index 0000000..5cb135e
--- /dev/null
+++ b/src/ui/main_menu/sprites/selector4.png.import
@@ -0,0 +1,35 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/selector4.png-c3312c451267db277e5279e15c3e9dc2.stex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://ui/main_menu/sprites/selector4.png"
+dest_files=[ "res://.import/selector4.png-c3312c451267db277e5279e15c3e9dc2.stex" ]
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_mode=0
+compress/bptc_ldr=0
+compress/normal_map=0
+flags/repeat=0
+flags/filter=false
+flags/mipmaps=false
+flags/anisotropic=false
+flags/srgb=2
+process/fix_alpha_border=false
+process/premult_alpha=false
+process/HDR_as_SRGB=false
+process/invert_color=false
+process/normal_map_invert_y=false
+stream=false
+size_limit=0
+detect_3d=false
+svg/scale=1.0
diff --git a/src/ui/main_menu/sprites/selector5.png b/src/ui/main_menu/sprites/selector5.png
new file mode 100644
index 0000000..5e4988e
--- /dev/null
+++ b/src/ui/main_menu/sprites/selector5.png
Binary files differ
diff --git a/src/ui/main_menu/sprites/selector5.png.import b/src/ui/main_menu/sprites/selector5.png.import
new file mode 100644
index 0000000..9282f51
--- /dev/null
+++ b/src/ui/main_menu/sprites/selector5.png.import
@@ -0,0 +1,35 @@
+[remap]
+
+importer="texture"
+type="StreamTexture"
+path="res://.import/selector5.png-57a6bf00d882484ef5ce3c35f8ecea76.stex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://ui/main_menu/sprites/selector5.png"
+dest_files=[ "res://.import/selector5.png-57a6bf00d882484ef5ce3c35f8ecea76.stex" ]
+
+[params]
+
+compress/mode=0
+compress/lossy_quality=0.7
+compress/hdr_mode=0
+compress/bptc_ldr=0
+compress/normal_map=0
+flags/repeat=0
+flags/filter=false
+flags/mipmaps=false
+flags/anisotropic=false
+flags/srgb=2
+process/fix_alpha_border=false
+process/premult_alpha=false
+process/HDR_as_SRGB=false
+process/invert_color=false
+process/normal_map_invert_y=false
+stream=false
+size_limit=0
+detect_3d=false
+svg/scale=1.0
diff --git a/src/ui/ui.gd b/src/ui/ui.gd
deleted file mode 100644
index 1ceff2f..0000000
--- a/src/ui/ui.gd
+++ /dev/null
@@ -1,14 +0,0 @@
-class_name UI
-extends CanvasLayer
-
-onready var _start_button: Button = $Root/MarginContainer/CenterContainer/Start
-
-
-func _ready():
- _start_button.connect("pressed", self, "_on_start_button_pressed")
-
-
-func _on_start_button_pressed() -> void:
- _start_button.disabled = true
- _start_button.visible = false
- Event.emit_signal("game_start")