mirror of
https://github.com/HarmonyHoney/tiny_crate.git
synced 2026-01-23 02:34:53 +00:00
OptionsMenu! now to hook up the Audio Buses
This commit is contained in:
parent
81d95babf1
commit
fef71ab2d2
11 changed files with 784 additions and 89 deletions
15
default_bus_layout.tres
Normal file
15
default_bus_layout.tres
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[gd_resource type="AudioBusLayout" format=2]
|
||||
|
||||
[resource]
|
||||
bus/1/name = "SFX"
|
||||
bus/1/solo = false
|
||||
bus/1/mute = false
|
||||
bus/1/bypass_fx = false
|
||||
bus/1/volume_db = 0.0
|
||||
bus/1/send = "Master"
|
||||
bus/2/name = "Music"
|
||||
bus/2/solo = false
|
||||
bus/2/mute = false
|
||||
bus/2/bypass_fx = false
|
||||
bus/2/volume_db = 0.0
|
||||
bus/2/send = "Master"
|
||||
BIN
media/image/check.png
Normal file
BIN
media/image/check.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 100 B |
BIN
media/image/tinyArrow.png
Normal file
BIN
media/image/tinyArrow.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 111 B |
|
|
@ -1,6 +1,6 @@
|
|||
[gd_scene load_steps=11 format=2]
|
||||
|
||||
[ext_resource path="res://src/map/1-6.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://src/map/2-2.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://media/3d/DefaultMaterial.material" type="Material" id=2]
|
||||
[ext_resource path="res://media/3d/Material.material" type="Material" id=3]
|
||||
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ var is_clear = false
|
|||
var map_path := "res://src/map/"
|
||||
var current_map := 0
|
||||
var scene_path := "res://src/menu/select.tscn"
|
||||
var level_select_path := "res://src/menu/select.tscn"
|
||||
var main_menu_path := "res://src/menu/StartMenu.tscn"
|
||||
var options_menu_path := "res://src/menu/OptionsMenu.tscn"
|
||||
var level_select_path := "res://src/menu/select.tscn"
|
||||
var win_screen_path := "res://src/menu/WinScreen.tscn"
|
||||
|
||||
var _window_scale := 1.0
|
||||
#var death_count := 0
|
||||
var window_scale := 1
|
||||
|
||||
var save_data := {}
|
||||
var save_filename := "box.save"
|
||||
|
|
@ -28,6 +28,9 @@ var maps = []
|
|||
var is_level_select := false
|
||||
var is_in_game := false
|
||||
|
||||
var sfx_volume = 10
|
||||
var music_volume = 10
|
||||
|
||||
func _ready():
|
||||
dev.out("Shared._ready(): ", false)
|
||||
|
||||
|
|
@ -35,10 +38,10 @@ func _ready():
|
|||
maps = dir_list(map_path)
|
||||
print("maps: ", maps)
|
||||
|
||||
# _window_scale window
|
||||
#window_scale = floor(OS.get_screen_size().x / get_viewport().size.x)
|
||||
#_window_scale = max(1, floor(_window_scale * 0.9))
|
||||
#set_window_scale()
|
||||
# scale window
|
||||
window_scale = floor(OS.get_screen_size().x / get_viewport().size.x)
|
||||
window_scale = max(1, floor(window_scale * 0.9))
|
||||
set_window_scale()
|
||||
|
||||
# load save data
|
||||
if load_file(save_filename):
|
||||
|
|
@ -76,13 +79,13 @@ func dir_list(path : String):
|
|||
array.sort()
|
||||
return array
|
||||
|
||||
func set_window_scale(arg := _window_scale):
|
||||
_window_scale = arg if arg else _window_scale
|
||||
_window_scale = max(1, _window_scale)
|
||||
OS.window_size = Vector2(view_size.x * _window_scale, view_size.y * _window_scale)
|
||||
func set_window_scale(arg := window_scale):
|
||||
window_scale = arg if arg else window_scale
|
||||
window_scale = max(1, window_scale)
|
||||
OS.window_size = Vector2(view_size.x * window_scale, view_size.y * window_scale)
|
||||
# center window
|
||||
OS.set_window_position(OS.get_screen_size() * 0.5 - OS.get_window_size() * 0.5)
|
||||
return "_window_scale: " + str(_window_scale) + " - resolution: " + str(OS.get_window_size())
|
||||
return "window_scale: " + str(window_scale) + " - resolution: " + str(OS.get_window_size())
|
||||
|
||||
func start_reset():
|
||||
if !is_reset:
|
||||
|
|
@ -97,7 +100,7 @@ func do_reset():
|
|||
func change_map():
|
||||
get_tree().change_scene(scene_path)
|
||||
is_level_select = scene_path == level_select_path
|
||||
is_in_game = scene_path.begins_with(map_path)
|
||||
is_in_game = scene_path.begins_with(map_path) or scene_path.begins_with(win_screen_path)
|
||||
HUD.wipe.start(true)
|
||||
|
||||
func set_map(arg):
|
||||
|
|
|
|||
49
src/menu/OptionsMenu.gd
Normal file
49
src/menu/OptionsMenu.gd
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
extends Node2D
|
||||
|
||||
var menu_items := []
|
||||
var cursor := 0
|
||||
|
||||
var node_cursor : ColorRect
|
||||
var node_audio : AudioStreamPlayer2D
|
||||
|
||||
var is_input = true
|
||||
|
||||
func _ready():
|
||||
node_cursor = $Cursor
|
||||
menu_items = $MenuItems.get_children()
|
||||
|
||||
node_audio = $AudioStreamPlayer2D
|
||||
|
||||
select_item(0)
|
||||
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
func _input(event):
|
||||
if !is_input:
|
||||
return
|
||||
if event.is_action_pressed("jump"):
|
||||
if menu_items[cursor].has_method("act"):
|
||||
menu_items[cursor].act()
|
||||
elif event.is_action_pressed("left") or event.is_action_pressed("right"):
|
||||
var btnx = btn.p("right") - btn.p("left")
|
||||
if menu_items[cursor].has_method("scroll"):
|
||||
menu_items[cursor].scroll(btnx)
|
||||
elif event.is_action_pressed("down") or event.is_action_pressed("up"):
|
||||
var btny = btn.p("down") - btn.p("up")
|
||||
if btny:
|
||||
select_item(cursor + btny)
|
||||
|
||||
func select_item(arg := 0):
|
||||
if menu_items[cursor].has_method("deselect"):
|
||||
menu_items[cursor].deselect()
|
||||
|
||||
cursor = clamp(arg, 0, menu_items.size() - 1)
|
||||
node_cursor.rect_position.y = menu_items[cursor].position.y - 2
|
||||
|
||||
if menu_items[cursor].has_method("select"):
|
||||
menu_items[cursor].select()
|
||||
|
||||
|
||||
|
||||
|
||||
619
src/menu/OptionsMenu.tscn
Normal file
619
src/menu/OptionsMenu.tscn
Normal file
|
|
@ -0,0 +1,619 @@
|
|||
[gd_scene load_steps=21 format=2]
|
||||
|
||||
[ext_resource path="res://media/font/m3x6.tres" type="DynamicFont" id=1]
|
||||
[ext_resource path="res://media/image/9slice.png" type="Texture" id=2]
|
||||
[ext_resource path="res://src/menu/OptionsMenu.gd" type="Script" id=3]
|
||||
[ext_resource path="res://media/image/tinyArrow.png" type="Texture" id=4]
|
||||
[ext_resource path="res://media/font/m6x11.ttf" type="DynamicFontData" id=5]
|
||||
[ext_resource path="res://media/font/m6x11.tres" type="DynamicFont" id=6]
|
||||
[ext_resource path="res://media/audio/sfx/sfx5.wav" type="AudioStream" id=7]
|
||||
[ext_resource path="res://src/stage/DetailTileMap.tscn" type="PackedScene" id=8]
|
||||
[ext_resource path="res://media/audio/sfx/hit14.wav" type="AudioStream" id=9]
|
||||
[ext_resource path="res://src/stage/SolidTileMap.tscn" type="PackedScene" id=11]
|
||||
[ext_resource path="res://src/stage/GameCamera.tscn" type="PackedScene" id=13]
|
||||
[ext_resource path="res://media/image/btn.png" type="Texture" id=16]
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
extra_spacing_bottom = -1
|
||||
font_data = ExtResource( 5 )
|
||||
|
||||
[sub_resource type="GDScript" id=8]
|
||||
script/source = "extends Node2D
|
||||
|
||||
func act():
|
||||
Shared.scene_path = Shared.main_menu_path
|
||||
Shared.do_reset()
|
||||
owner.is_input = false
|
||||
"
|
||||
|
||||
[sub_resource type="GDScript" id=6]
|
||||
script/source = "extends Node2D
|
||||
|
||||
func _ready():
|
||||
scroll(0)
|
||||
|
||||
func select():
|
||||
$Arrows.visible = true
|
||||
|
||||
func deselect():
|
||||
$Arrows.visible = false
|
||||
|
||||
func scroll(arg = 1):
|
||||
Shared.sfx_volume = clamp(Shared.sfx_volume + arg, 0, 10)
|
||||
var meter = $Meter.get_children()
|
||||
for i in 10: # 0 - 9
|
||||
if i < Shared.sfx_volume:
|
||||
meter[i].color = Color(\"00e436\")
|
||||
else:
|
||||
meter[i].color = Color(\"ff004d\")
|
||||
print(Shared.sfx_volume)
|
||||
"
|
||||
|
||||
[sub_resource type="GDScript" id=7]
|
||||
script/source = "extends Node2D
|
||||
|
||||
func _ready():
|
||||
scroll(0)
|
||||
|
||||
func select():
|
||||
$Arrows.visible = true
|
||||
|
||||
func deselect():
|
||||
$Arrows.visible = false
|
||||
|
||||
func scroll(arg = 1):
|
||||
Shared.music_volume = clamp(Shared.music_volume + arg, 0, 10)
|
||||
var meter = $Meter.get_children()
|
||||
for i in 10: # 0 - 9
|
||||
if i < Shared.music_volume:
|
||||
meter[i].color = Color(\"00e436\")
|
||||
else:
|
||||
meter[i].color = Color(\"ff004d\")
|
||||
print(Shared.music_volume)
|
||||
"
|
||||
|
||||
[sub_resource type="GDScript" id=2]
|
||||
script/source = "extends Node2D
|
||||
|
||||
var fill
|
||||
|
||||
func _ready():
|
||||
fill = $Box/Fill
|
||||
fill.visible = OS.window_fullscreen
|
||||
|
||||
func act():
|
||||
OS.window_fullscreen = !OS.window_fullscreen
|
||||
fill.visible = OS.window_fullscreen
|
||||
"
|
||||
|
||||
[sub_resource type="GDScript" id=5]
|
||||
script/source = "extends Node2D
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
scroll(0)
|
||||
|
||||
func scroll(arg = 1):
|
||||
Shared.set_window_scale(clamp(Shared.window_scale + arg, 1, 12))
|
||||
$Scale.text = str(Shared.window_scale) + \"x\"
|
||||
$Resolution.text = str(228 * Shared.window_scale) + \" x \" + str(128 * Shared.window_scale)
|
||||
"
|
||||
|
||||
[sub_resource type="GDScript" id=3]
|
||||
script/source = "extends Node2D
|
||||
|
||||
func act():
|
||||
Shared.delete_save()
|
||||
$AudioStreamPlayer.play()
|
||||
"
|
||||
|
||||
[sub_resource type="GDScript" id=4]
|
||||
script/source = "extends Node2D
|
||||
|
||||
func act():
|
||||
Shared.unlock()
|
||||
$AudioStreamPlayer.play()
|
||||
"
|
||||
|
||||
[node name="OptionsMenu" type="Node2D"]
|
||||
pause_mode = 2
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Buttons" type="Node2D" parent="."]
|
||||
position = Vector2( 14, 0 )
|
||||
|
||||
[node name="c" type="Sprite" parent="Buttons"]
|
||||
visible = false
|
||||
position = Vector2( 103, 116 )
|
||||
texture = ExtResource( 16 )
|
||||
hframes = 6
|
||||
vframes = 4
|
||||
region_rect = Rect2( 0, 0, 18, 18 )
|
||||
|
||||
[node name="c_label" type="Label" parent="Buttons/c"]
|
||||
margin_left = 11.0
|
||||
margin_top = -6.0
|
||||
margin_right = 39.0
|
||||
margin_bottom = 7.0
|
||||
custom_fonts/font = ExtResource( 6 )
|
||||
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
|
||||
custom_constants/shadow_as_outline = 1
|
||||
text = "back"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="x" type="Sprite" parent="Buttons"]
|
||||
position = Vector2( 12, 116 )
|
||||
texture = ExtResource( 16 )
|
||||
hframes = 6
|
||||
vframes = 4
|
||||
frame = 1
|
||||
region_rect = Rect2( 0, 0, 18, 18 )
|
||||
|
||||
[node name="x_label" type="Label" parent="Buttons/x"]
|
||||
margin_left = 11.0
|
||||
margin_top = -7.0
|
||||
margin_right = 49.0
|
||||
margin_bottom = 6.0
|
||||
custom_fonts/font = ExtResource( 6 )
|
||||
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
|
||||
custom_constants/shadow_as_outline = 1
|
||||
text = "select"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="arrows" type="Sprite" parent="Buttons"]
|
||||
position = Vector2( 216, 116 )
|
||||
texture = ExtResource( 16 )
|
||||
hframes = 6
|
||||
vframes = 4
|
||||
frame = 7
|
||||
region_rect = Rect2( 0, 0, 18, 18 )
|
||||
|
||||
[node name="arrows_label" type="Label" parent="Buttons/arrows"]
|
||||
margin_left = -40.0
|
||||
margin_top = -7.0
|
||||
margin_right = -10.0
|
||||
margin_bottom = 6.0
|
||||
custom_fonts/font = ExtResource( 6 )
|
||||
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
|
||||
custom_constants/shadow_as_outline = 1
|
||||
text = "move"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Cursor" type="ColorRect" parent="."]
|
||||
margin_left = 56.0
|
||||
margin_top = 22.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 34.0
|
||||
color = Color( 0.113725, 0.168627, 0.32549, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Header" type="Label" parent="."]
|
||||
margin_left = 14.0
|
||||
margin_top = 4.0
|
||||
margin_right = 242.0
|
||||
margin_bottom = 17.0
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
|
||||
custom_constants/shadow_as_outline = 1
|
||||
text = "OPTIONS"
|
||||
align = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="NinePatchRect" type="NinePatchRect" parent="."]
|
||||
visible = false
|
||||
margin_left = -18.0
|
||||
margin_top = 8.0
|
||||
margin_right = 54.0
|
||||
margin_bottom = 80.0
|
||||
rect_min_size = Vector2( 24, 24 )
|
||||
texture = ExtResource( 2 )
|
||||
patch_margin_left = 8
|
||||
patch_margin_top = 8
|
||||
patch_margin_right = 8
|
||||
patch_margin_bottom = 8
|
||||
axis_stretch_horizontal = 1
|
||||
axis_stretch_vertical = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="MenuItems" type="Node2D" parent="."]
|
||||
position = Vector2( 14, 0 )
|
||||
z_index = 20
|
||||
z_as_relative = false
|
||||
|
||||
[node name="Back" type="Node2D" parent="MenuItems"]
|
||||
position = Vector2( 50, 24 )
|
||||
script = SubResource( 8 )
|
||||
|
||||
[node name="Label" type="Label" parent="MenuItems/Back"]
|
||||
margin_top = 1.0
|
||||
margin_right = 128.0
|
||||
margin_bottom = 9.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "Back to Menu"
|
||||
align = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="SFXVolume" type="Node2D" parent="MenuItems"]
|
||||
position = Vector2( 50, 36 )
|
||||
script = SubResource( 6 )
|
||||
|
||||
[node name="Label" type="Label" parent="MenuItems/SFXVolume"]
|
||||
margin_top = 1.0
|
||||
margin_right = 42.0
|
||||
margin_bottom = 9.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "SFX Volume"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Meter" type="Node2D" parent="MenuItems/SFXVolume"]
|
||||
position = Vector2( 89, 0 )
|
||||
|
||||
[node name="1" type="ColorRect" parent="MenuItems/SFXVolume/Meter"]
|
||||
margin_right = 3.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 0, 0.894118, 0.211765, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="2" type="ColorRect" parent="MenuItems/SFXVolume/Meter"]
|
||||
margin_left = 4.0
|
||||
margin_right = 7.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 0, 0.894118, 0.211765, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="3" type="ColorRect" parent="MenuItems/SFXVolume/Meter"]
|
||||
margin_left = 8.0
|
||||
margin_right = 11.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 0, 0.894118, 0.211765, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="4" type="ColorRect" parent="MenuItems/SFXVolume/Meter"]
|
||||
margin_left = 12.0
|
||||
margin_right = 15.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 0, 0.894118, 0.211765, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="5" type="ColorRect" parent="MenuItems/SFXVolume/Meter"]
|
||||
margin_left = 16.0
|
||||
margin_right = 19.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 0, 0.894118, 0.211765, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="6" type="ColorRect" parent="MenuItems/SFXVolume/Meter"]
|
||||
margin_left = 20.0
|
||||
margin_right = 23.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 0, 0.894118, 0.211765, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="7" type="ColorRect" parent="MenuItems/SFXVolume/Meter"]
|
||||
margin_left = 24.0
|
||||
margin_right = 27.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 1, 0, 0.301961, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="8" type="ColorRect" parent="MenuItems/SFXVolume/Meter"]
|
||||
margin_left = 28.0
|
||||
margin_right = 31.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 1, 0, 0.301961, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="9" type="ColorRect" parent="MenuItems/SFXVolume/Meter"]
|
||||
margin_left = 32.0
|
||||
margin_right = 35.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 1, 0, 0.301961, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="10" type="ColorRect" parent="MenuItems/SFXVolume/Meter"]
|
||||
margin_left = 36.0
|
||||
margin_right = 39.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 1, 0, 0.301961, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Arrows" type="Node2D" parent="MenuItems/SFXVolume"]
|
||||
visible = false
|
||||
position = Vector2( 89, 0 )
|
||||
|
||||
[node name="tinyArrow" type="Sprite" parent="MenuItems/SFXVolume/Arrows"]
|
||||
position = Vector2( -2, 4 )
|
||||
texture = ExtResource( 4 )
|
||||
|
||||
[node name="tinyArrow2" type="Sprite" parent="MenuItems/SFXVolume/Arrows"]
|
||||
position = Vector2( 41, 4 )
|
||||
texture = ExtResource( 4 )
|
||||
flip_h = true
|
||||
|
||||
[node name="MusicVolume" type="Node2D" parent="MenuItems"]
|
||||
position = Vector2( 50, 48 )
|
||||
script = SubResource( 7 )
|
||||
|
||||
[node name="Label" type="Label" parent="MenuItems/MusicVolume"]
|
||||
margin_top = 1.0
|
||||
margin_right = 50.0
|
||||
margin_bottom = 9.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "Music Volume"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Meter" type="Node2D" parent="MenuItems/MusicVolume"]
|
||||
position = Vector2( 89, 0 )
|
||||
|
||||
[node name="1" type="ColorRect" parent="MenuItems/MusicVolume/Meter"]
|
||||
margin_right = 3.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 0, 0.894118, 0.211765, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="2" type="ColorRect" parent="MenuItems/MusicVolume/Meter"]
|
||||
margin_left = 4.0
|
||||
margin_right = 7.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 0, 0.894118, 0.211765, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="3" type="ColorRect" parent="MenuItems/MusicVolume/Meter"]
|
||||
margin_left = 8.0
|
||||
margin_right = 11.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 0, 0.894118, 0.211765, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="4" type="ColorRect" parent="MenuItems/MusicVolume/Meter"]
|
||||
margin_left = 12.0
|
||||
margin_right = 15.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 0, 0.894118, 0.211765, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="5" type="ColorRect" parent="MenuItems/MusicVolume/Meter"]
|
||||
margin_left = 16.0
|
||||
margin_right = 19.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 0, 0.894118, 0.211765, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="6" type="ColorRect" parent="MenuItems/MusicVolume/Meter"]
|
||||
margin_left = 20.0
|
||||
margin_right = 23.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 0, 0.894118, 0.211765, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="7" type="ColorRect" parent="MenuItems/MusicVolume/Meter"]
|
||||
margin_left = 24.0
|
||||
margin_right = 27.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 0, 0.894118, 0.211765, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="8" type="ColorRect" parent="MenuItems/MusicVolume/Meter"]
|
||||
margin_left = 28.0
|
||||
margin_right = 31.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 0, 0.894118, 0.211765, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="9" type="ColorRect" parent="MenuItems/MusicVolume/Meter"]
|
||||
margin_left = 32.0
|
||||
margin_right = 35.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 1, 0, 0.301961, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="10" type="ColorRect" parent="MenuItems/MusicVolume/Meter"]
|
||||
margin_left = 36.0
|
||||
margin_right = 39.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 1, 0, 0.301961, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Arrows" type="Node2D" parent="MenuItems/MusicVolume"]
|
||||
visible = false
|
||||
position = Vector2( 89, 0 )
|
||||
|
||||
[node name="tinyArrow" type="Sprite" parent="MenuItems/MusicVolume/Arrows"]
|
||||
position = Vector2( -2, 4 )
|
||||
texture = ExtResource( 4 )
|
||||
|
||||
[node name="tinyArrow2" type="Sprite" parent="MenuItems/MusicVolume/Arrows"]
|
||||
position = Vector2( 41, 4 )
|
||||
texture = ExtResource( 4 )
|
||||
flip_h = true
|
||||
|
||||
[node name="Fullscreen" type="Node2D" parent="MenuItems"]
|
||||
position = Vector2( 50, 60 )
|
||||
script = SubResource( 2 )
|
||||
|
||||
[node name="Label" type="Label" parent="MenuItems/Fullscreen"]
|
||||
margin_top = 1.0
|
||||
margin_right = 50.0
|
||||
margin_bottom = 9.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "Fullscreen"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Box" type="ColorRect" parent="MenuItems/Fullscreen"]
|
||||
margin_left = 99.0
|
||||
margin_top = -1.0
|
||||
margin_right = 109.0
|
||||
margin_bottom = 9.0
|
||||
color = Color( 1, 0.945098, 0.909804, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Back" type="ColorRect" parent="MenuItems/Fullscreen/Box"]
|
||||
margin_left = 1.0
|
||||
margin_top = 1.0
|
||||
margin_right = 9.0
|
||||
margin_bottom = 9.0
|
||||
color = Color( 0, 0, 0, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Fill" type="ColorRect" parent="MenuItems/Fullscreen/Box"]
|
||||
margin_left = 2.0
|
||||
margin_top = 2.0
|
||||
margin_right = 8.0
|
||||
margin_bottom = 8.0
|
||||
color = Color( 1, 0.945098, 0.909804, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="WindowSize" type="Node2D" parent="MenuItems"]
|
||||
position = Vector2( 50, 72 )
|
||||
script = SubResource( 5 )
|
||||
|
||||
[node name="Label" type="Label" parent="MenuItems/WindowSize"]
|
||||
margin_top = 1.0
|
||||
margin_right = 50.0
|
||||
margin_bottom = 9.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "Window Size"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Scale" type="Label" parent="MenuItems/WindowSize"]
|
||||
margin_left = 48.0
|
||||
margin_top = 1.0
|
||||
margin_right = 80.0
|
||||
margin_bottom = 9.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "1x"
|
||||
align = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Resolution" type="Label" parent="MenuItems/WindowSize"]
|
||||
margin_left = 72.0
|
||||
margin_top = 1.0
|
||||
margin_right = 136.0
|
||||
margin_bottom = 9.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "228 x 128"
|
||||
align = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="DeleteSaveData" type="Node2D" parent="MenuItems"]
|
||||
position = Vector2( 50, 84 )
|
||||
script = SubResource( 3 )
|
||||
|
||||
[node name="Label" type="Label" parent="MenuItems/DeleteSaveData"]
|
||||
margin_top = 1.0
|
||||
margin_right = 128.0
|
||||
margin_bottom = 9.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "Delete Save Data"
|
||||
align = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="MenuItems/DeleteSaveData"]
|
||||
stream = ExtResource( 7 )
|
||||
bus = "SFX"
|
||||
|
||||
[node name="UnlockAll" type="Node2D" parent="MenuItems"]
|
||||
position = Vector2( 50, 96 )
|
||||
script = SubResource( 4 )
|
||||
|
||||
[node name="Label" type="Label" parent="MenuItems/UnlockAll"]
|
||||
margin_top = 1.0
|
||||
margin_right = 128.0
|
||||
margin_bottom = 9.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "Unlock All"
|
||||
align = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="MenuItems/UnlockAll"]
|
||||
stream = ExtResource( 9 )
|
||||
bus = "SFX"
|
||||
|
||||
[node name="Stage" type="Node2D" parent="."]
|
||||
|
||||
[node name="SolidTileMap" parent="Stage" instance=ExtResource( 11 )]
|
||||
|
||||
[node name="DetailTileMap" parent="Stage" instance=ExtResource( 8 )]
|
||||
z_index = -11
|
||||
|
||||
[node name="GameCamera" parent="Stage" instance=ExtResource( 13 )]
|
||||
position = Vector2( 128, 64 )
|
||||
|
||||
[editable path="Stage/GameCamera"]
|
||||
|
|
@ -1,22 +1,22 @@
|
|||
extends Node2D
|
||||
|
||||
var menu_list : Label
|
||||
var menu_items := []
|
||||
|
||||
var main_menu : Control
|
||||
var main_list : Label
|
||||
var main_items := ["play", "options", "quit"]
|
||||
|
||||
var options_menu : Control
|
||||
var options_list : Label
|
||||
var options_items := ["back", "SFX volume", "Music volume", "fullscreen", "window size", "delete save data", "unlock all"]
|
||||
var quit_menu : Control
|
||||
var quit_list : Label
|
||||
var quit_items := ["yes", "no"]
|
||||
|
||||
var cursor := 0
|
||||
var menu_items := []
|
||||
|
||||
var timer := 0.1
|
||||
var clock := 0.0
|
||||
|
||||
var node_cursor : Node2D
|
||||
var node_cursor : ColorRect
|
||||
var node_audio : AudioStreamPlayer2D
|
||||
|
||||
var is_input = true
|
||||
|
|
@ -24,18 +24,16 @@ var is_input = true
|
|||
func _ready():
|
||||
main_menu = $Menu/Main
|
||||
main_list = $Menu/Main/List
|
||||
print(main_menu)
|
||||
|
||||
options_menu = $Menu/Options
|
||||
options_list = $Menu/Options/List
|
||||
quit_menu = $Menu/Quit
|
||||
quit_list = $Menu/Quit/List
|
||||
|
||||
menu_list = main_list
|
||||
|
||||
node_cursor = $Menu/Cursor
|
||||
node_audio = $AudioStreamPlayer2D
|
||||
|
||||
switch_menu("paused")
|
||||
write_menu()
|
||||
switch_menu("main")
|
||||
|
||||
func _process(delta):
|
||||
pass
|
||||
|
|
@ -43,7 +41,10 @@ func _process(delta):
|
|||
func _input(event):
|
||||
if !is_input:
|
||||
return
|
||||
if event.is_action_pressed("jump"):
|
||||
if event.is_action_pressed("action"):
|
||||
if menu_list == quit_list:
|
||||
switch_menu("paused")
|
||||
elif event.is_action_pressed("jump"):
|
||||
menu_select()
|
||||
elif event.is_action_pressed("down") or event.is_action_pressed("up"):
|
||||
var btny = btn.p("down") - btn.p("up")
|
||||
|
|
@ -56,44 +57,49 @@ func write_menu():
|
|||
for i in menu_items.size():
|
||||
if cursor == i:
|
||||
menu_list.text += "-" + menu_items[i] + "-" + "\n"
|
||||
node_cursor.position.y = menu_list.rect_position.y + 4 + i * 11
|
||||
node_cursor.scale.x = menu_items[i].length() * 0.6
|
||||
node_cursor.rect_position.y = -1 + i * 11
|
||||
node_cursor.rect_position.x = 0
|
||||
node_cursor.rect_size.x = menu_list.rect_size.x - 1
|
||||
else:
|
||||
menu_list.text += menu_items[i] + "\n"
|
||||
|
||||
func menu_select():
|
||||
match menu_items[cursor]:
|
||||
match menu_items[cursor].to_lower():
|
||||
"play":
|
||||
Shared.scene_path = Shared.level_select_path
|
||||
Shared.do_reset()
|
||||
is_input = false
|
||||
"options":
|
||||
switch_menu("options")
|
||||
Shared.scene_path = Shared.options_menu_path
|
||||
Shared.do_reset()
|
||||
is_input = false
|
||||
"quit":
|
||||
switch_menu("quit")
|
||||
"yes":
|
||||
get_tree().quit()
|
||||
"back":
|
||||
switch_menu("paused")
|
||||
"fullscreen":
|
||||
OS.window_fullscreen = !OS.window_fullscreen
|
||||
"volume":
|
||||
pass
|
||||
"delete save data":
|
||||
Shared.delete_save()
|
||||
node_audio.play()
|
||||
"unlock all":
|
||||
Shared.unlock()
|
||||
"no":
|
||||
switch_menu("main")
|
||||
cursor = 2
|
||||
write_menu()
|
||||
|
||||
|
||||
func switch_menu(arg):
|
||||
cursor = 0
|
||||
match arg:
|
||||
"paused":
|
||||
"main":
|
||||
main_menu.visible = true
|
||||
options_menu.visible = false
|
||||
quit_menu.visible = false
|
||||
menu_list = main_list
|
||||
menu_items = main_items
|
||||
"options":
|
||||
main_menu.visible = false
|
||||
options_menu.visible = true
|
||||
menu_list = options_list
|
||||
menu_items = options_items
|
||||
|
||||
node_cursor.get_parent().remove_child(node_cursor)
|
||||
main_list.add_child(node_cursor)
|
||||
"quit":
|
||||
quit_menu.visible = true
|
||||
menu_list = quit_list
|
||||
menu_items = quit_items
|
||||
cursor = 1
|
||||
|
||||
node_cursor.get_parent().remove_child(node_cursor)
|
||||
quit_list.add_child(node_cursor)
|
||||
write_menu()
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
[gd_scene load_steps=19 format=2]
|
||||
[gd_scene load_steps=18 format=2]
|
||||
|
||||
[ext_resource path="res://media/font/m3x6.tres" type="DynamicFont" id=1]
|
||||
[ext_resource path="res://media/image/9slice.png" type="Texture" id=2]
|
||||
[ext_resource path="res://src/menu/StartMenu.gd" type="Script" id=3]
|
||||
[ext_resource path="res://media/image/8pixel.png" type="Texture" id=4]
|
||||
[ext_resource path="res://media/font/m6x11.ttf" type="DynamicFontData" id=5]
|
||||
[ext_resource path="res://media/font/m6x11.tres" type="DynamicFont" id=6]
|
||||
[ext_resource path="res://media/audio/sfx/sfx5.wav" type="AudioStream" id=7]
|
||||
|
|
@ -16,10 +15,7 @@
|
|||
[ext_resource path="res://src/actor/SwitchBlockBlue.tscn" type="PackedScene" id=14]
|
||||
[ext_resource path="res://src/actor/SwitchBlue.tscn" type="PackedScene" id=15]
|
||||
[ext_resource path="res://media/image/btn.png" type="Texture" id=16]
|
||||
|
||||
[sub_resource type="DynamicFont" id=2]
|
||||
extra_spacing_bottom = -1
|
||||
font_data = ExtResource( 5 )
|
||||
[ext_resource path="res://media/font/m5x7.tres" type="DynamicFont" id=17]
|
||||
|
||||
[sub_resource type="DynamicFont" id=1]
|
||||
extra_spacing_bottom = -1
|
||||
|
|
@ -138,17 +134,22 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Cursor" type="Sprite" parent="Menu"]
|
||||
modulate = Color( 0.113725, 0.168627, 0.32549, 1 )
|
||||
position = Vector2( 30, 52 )
|
||||
scale = Vector2( 5, 1 )
|
||||
texture = ExtResource( 4 )
|
||||
[node name="Cursor" type="ColorRect" parent="Menu"]
|
||||
show_behind_parent = true
|
||||
margin_left = 15.0
|
||||
margin_top = 47.0
|
||||
margin_right = 44.0
|
||||
margin_bottom = 57.0
|
||||
color = Color( 0.113725, 0.168627, 0.32549, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Header" type="Label" parent="Menu"]
|
||||
margin_top = 9.0
|
||||
margin_right = 114.0
|
||||
margin_bottom = 22.0
|
||||
custom_fonts/font = SubResource( 2 )
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
|
||||
custom_constants/shadow_as_outline = 1
|
||||
text = "TINY CRATE"
|
||||
|
|
@ -181,10 +182,10 @@ __meta__ = {
|
|||
}
|
||||
|
||||
[node name="List" type="Label" parent="Menu/Main"]
|
||||
margin_left = 10.0
|
||||
margin_left = 12.0
|
||||
margin_top = 48.0
|
||||
margin_right = 50.0
|
||||
margin_bottom = 67.0
|
||||
margin_right = 48.0
|
||||
margin_bottom = 78.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "play
|
||||
options
|
||||
|
|
@ -194,21 +195,23 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Options" type="Control" parent="Menu"]
|
||||
[node name="Quit" type="Control" parent="Menu"]
|
||||
visible = false
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
margin_left = 80.0
|
||||
margin_top = 44.0
|
||||
margin_right = 120.0
|
||||
margin_bottom = 84.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="NinePatchRect" type="NinePatchRect" parent="Menu/Options"]
|
||||
visible = false
|
||||
margin_right = 72.0
|
||||
margin_bottom = 88.0
|
||||
[node name="NinePatchRect" type="NinePatchRect" parent="Menu/Quit"]
|
||||
margin_left = -1.0
|
||||
margin_top = -1.0
|
||||
margin_right = 69.0
|
||||
margin_bottom = 41.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
rect_min_size = Vector2( 72, 72 )
|
||||
texture = ExtResource( 2 )
|
||||
patch_margin_left = 8
|
||||
patch_margin_top = 8
|
||||
|
|
@ -220,29 +223,29 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="List" type="Label" parent="Menu/Options"]
|
||||
margin_left = 10.0
|
||||
margin_top = 47.0
|
||||
margin_right = 58.0
|
||||
margin_bottom = 88.0
|
||||
[node name="List" type="Label" parent="Menu/Quit"]
|
||||
margin_left = 18.0
|
||||
margin_top = 17.0
|
||||
margin_right = 50.0
|
||||
margin_bottom = 36.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
custom_colors/font_color = Color( 1, 0.945098, 0.909804, 1 )
|
||||
text = "back
|
||||
fullscreen
|
||||
volume
|
||||
"
|
||||
text = "yes
|
||||
no"
|
||||
align = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Header" type="Label" parent="Menu/Options"]
|
||||
margin_top = 32.0
|
||||
margin_right = 66.0
|
||||
margin_bottom = 45.0
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
[node name="Header" type="Label" parent="Menu/Quit"]
|
||||
margin_left = -53.0
|
||||
margin_top = 4.0
|
||||
margin_right = 121.0
|
||||
margin_bottom = 17.0
|
||||
custom_fonts/font = ExtResource( 17 )
|
||||
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
|
||||
custom_constants/shadow_as_outline = 1
|
||||
text = "OPTIONS"
|
||||
text = "Quit Game?"
|
||||
align = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ z_as_relative = false
|
|||
[node name="ColorRect" type="ColorRect" parent="BG/Background"]
|
||||
margin_right = 320.0
|
||||
margin_bottom = 180.0
|
||||
color = Color( 0.258824, 0.129412, 0.211765, 1 )
|
||||
color = Color( 0.113725, 0.168627, 0.32549, 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ func _ready():
|
|||
|
||||
# set vars
|
||||
lerp_pos = position
|
||||
pos_target = position
|
||||
|
||||
func _process(delta):
|
||||
if !is_moving or Engine.editor_hint:
|
||||
|
|
@ -42,9 +43,8 @@ func _process(delta):
|
|||
|
||||
if is_instance_valid(node_target):
|
||||
pos_target = node_target.position + pos_target_offset
|
||||
pos_target.x = clamp(pos_target.x, bounds_upper.x, bounds_lower.x)
|
||||
pos_target.y = clamp(pos_target.y, bounds_upper.y, bounds_lower.y)
|
||||
#HUD.test_label.text = str(pos_target)
|
||||
pos_target.x = clamp(pos_target.x, bounds_upper.x, bounds_lower.x)
|
||||
pos_target.y = clamp(pos_target.y, bounds_upper.y, bounds_lower.y)
|
||||
|
||||
# smoothing
|
||||
lerp_pos = lerp_pos.linear_interpolate(pos_target, lerp_step)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue