Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
psychowolf960 committed May 3, 2024
1 parent 8d6cbdc commit c84c229
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 60 deletions.
5 changes: 2 additions & 3 deletions .godot/editor/create_recent.Node
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Panel
HBoxContainer
VBoxContainer
TextureRect
TextureButton
Label
Expand All @@ -9,7 +11,4 @@ Button
SpinBox
RayCast2D
Timer
VBoxContainer
Node2D
Panel
MarginContainer
10 changes: 5 additions & 5 deletions .godot/editor/editor_layout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dock_1_selected_tab_idx=0
dock_2_selected_tab_idx=0
dock_3_selected_tab_idx=0
dock_4_selected_tab_idx=0
dock_5_selected_tab_idx=1
dock_5_selected_tab_idx=0
dock_6_selected_tab_idx=0
dock_7_selected_tab_idx=0
dock_8_selected_tab_idx=0
Expand All @@ -13,7 +13,7 @@ dock_split_2=196
dock_split_3=0
dock_hsplit_1=0
dock_hsplit_2=270
dock_hsplit_3=-270
dock_hsplit_3=-284
dock_hsplit_4=0
dock_filesystem_split=0
dock_filesystem_display_mode=0
Expand All @@ -32,13 +32,13 @@ current_scene="res://scenes/mainmenu.tscn"
center_split_offset=-288
selected_default_debugger_tab_idx=0
selected_main_editor_idx=2
selected_bottom_panel_item=1
selected_bottom_panel_item=0

[ScriptEditor]

open_scripts=["res://scripts/mainmenu.gd", "res://scenes/MarginContainer2.gd", "res://scripts/player.gd"]
open_scripts=["res://scripts/gamemanager.gd", "res://scripts/mainmenu.gd", "res://scenes/MarginContainer2.gd", "res://scripts/player.gd"]
selected_script="res://scripts/mainmenu.gd"
open_help=[]
open_help=["Vector2"]
script_split_offset=70
list_split_offset=0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Anim={
"grid_snap_active": false,
"grid_step": Vector2(8, 8),
"grid_visibility": 1,
"ofs": Vector2(-260.112, -361.511),
"ofs": Vector2(-189.871, -207.983),
"primary_grid_step": Vector2i(8, 8),
"show_edit_locks": true,
"show_guides": true,
Expand All @@ -32,7 +32,7 @@ Anim={
"snap_rotation_step": 0.261799,
"snap_scale": false,
"snap_scale_step": 0.1,
"zoom": 0.793701
"zoom": 0.66742
}
3D={
"fov": 70.01,
Expand Down Expand Up @@ -172,4 +172,4 @@ Anim={
"zfar": 4000.01,
"znear": 0.05
}
selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17095/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@61/@VBoxContainer@62/@PanelContainer@109/MainScreen/@CanvasItemEditor@9461/@VSplitContainer@9280/@HSplitContainer@9282/@HSplitContainer@9284/@Control@9285/@SubViewportContainer@9286/@SubViewport@9287/mainmenu/MarginContainer2")])
selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17095/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@61/@VBoxContainer@62/@PanelContainer@109/MainScreen/@CanvasItemEditor@9461/@VSplitContainer@9280/@HSplitContainer@9282/@HSplitContainer@9284/@Control@9285/@SubViewportContainer@9286/@SubViewport@9287/mainmenu/MarginContainer2/HBoxContainer")])
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[folding]

node_unfolds=[NodePath("MarginContainer"), PackedStringArray("Layout", "Layout/Transform"), NodePath("MarginContainer/Panel"), PackedStringArray("Layout", "Layout/Container Sizing", "Layout/Transform", "Theme"), NodePath("MarginContainer/Panel/VBoxContainer"), PackedStringArray("Layout"), NodePath("MarginContainer2"), PackedStringArray("Layout", "Layout/Transform", "Localization"), NodePath("MarginContainer2/World1"), PackedStringArray("Layout", "Layout/Transform", "Layout/Container Sizing"), NodePath("MarginContainer2/World1/Label"), PackedStringArray("Layout", "Layout/Transform", "Theme Overrides", "Theme Overrides/fonts", "Theme Overrides/font_sizes", "Theme Overrides/styles", "theme_override_styles/normal"), NodePath("MarginContainer2/World1/TextureRect"), PackedStringArray("Theme", "Layout"), NodePath("MarginContainer2/World4"), PackedStringArray("Theme", "Visibility"), NodePath("MarginContainer2/World2"), PackedStringArray("Layout")]
resource_unfolds=["res://scenes/mainmenu.tscn::Theme_45hd1", PackedStringArray(), "res://scenes/mainmenu.tscn::StyleBoxFlat_2rwsq", PackedStringArray(), "res://scenes/mainmenu.tscn::StyleBoxFlat_8c08p", PackedStringArray("Border Width", "Expand Margins")]
node_unfolds=[NodePath("MarginContainer"), PackedStringArray("Layout", "Layout/Transform"), NodePath("MarginContainer/Panel"), PackedStringArray("Layout", "Layout/Container Sizing", "Layout/Transform", "Theme"), NodePath("MarginContainer/Panel/VBoxContainer"), PackedStringArray("Layout"), NodePath("MarginContainer2"), PackedStringArray("Layout", "Layout/Transform", "Localization"), NodePath("MarginContainer2/HBoxContainer"), PackedStringArray("Layout", "Localization", "Layout/Transform", "Layout/Container Sizing"), NodePath("MarginContainer2/HBoxContainer/World1"), PackedStringArray("Layout", "Layout/Transform", "Layout/Container Sizing", "Localization", "Focus"), NodePath("MarginContainer2/HBoxContainer/World1/Label2"), PackedStringArray("Layout", "Layout/Transform", "Theme Overrides", "Theme Overrides/fonts", "Theme Overrides/font_sizes", "Theme Overrides/styles", "theme_override_styles/normal"), NodePath("MarginContainer2/HBoxContainer/World1/Label1"), PackedStringArray("Theme", "Layout"), NodePath("MarginContainer2/HBoxContainer/World4"), PackedStringArray("Theme", "Visibility"), NodePath("MarginContainer2/HBoxContainer/World2"), PackedStringArray("Layout"), NodePath("MarginContainer2/Panel"), PackedStringArray("Layout", "Layout/Container Sizing", "Layout/Transform", "Theme", "Theme Overrides", "Theme Overrides/styles", "theme_override_styles/panel", "Localization")]
resource_unfolds=["res://scenes/mainmenu.tscn::Theme_45hd1", PackedStringArray(), "res://scenes/mainmenu.tscn::StyleBoxFlat_2rwsq", PackedStringArray(), "res://scenes/mainmenu.tscn::StyleBoxFlat_8c08p", PackedStringArray("Border Width", "Expand Margins"), "res://scenes/mainmenu.tscn::StyleBoxFlat_llkcd", PackedStringArray("Border Width", "Expand Margins")]
nodes_folded=[]
4 changes: 2 additions & 2 deletions .godot/editor/project_metadata.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ run_reload_scripts=true
[recent_files]

scenes=["res://scenes/mainmenu.tscn", "res://scenes/level1.tscn", "res://scenes/player.tscn", "res://scenes/game.tscn", "res://scenes/optionsmenu.tscn", "res://scenes/slime.tscn", "res://scenes/coin.tscn", "res://mainmenu.tscn", "res://slime.tscn"]
scripts=["res://scenes/MarginContainer2.gd", "res://scripts/player.gd", "res://mainmenu.gd", "Node", "res://scripts/killzone.gd", "res://scenes/optionsmenu.gd", "res://scripts/gamemanager.gd", "res://slime.gd", "res://scripts/coin.gd", "res://scripts/game_manager.gd"]
scripts=["res://scripts/gamemanager.gd", "Vector2", "res://scenes/MarginContainer2.gd", "res://scripts/player.gd", "res://mainmenu.gd", "Node", "res://scripts/killzone.gd", "res://scenes/optionsmenu.gd", "res://slime.gd", "res://scripts/coin.gd"]

[linked_properties]

Expand Down Expand Up @@ -55,7 +55,7 @@ last_selected_language="GDScript"

[color_picker]

recent_presets=PackedColorArray(0.409567, 0.586235, 0.964558, 1, 0.181615, 0.374112, 0.837668, 1, 0.398291, 0.628022, 0.796577, 1, 0.840567, 0.833517, 0, 1, 0.835294, 0.835294, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0.6, 0.151276, 0.151276, 0.151276, 1)
recent_presets=PackedColorArray(0.181615, 0.374112, 0.837668, 1, 0.398291, 0.628022, 0.796577, 1, 0.840567, 0.833517, 0, 1, 0.835294, 0.835294, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0.6, 0.151276, 0.151276, 0.151276, 1, 0.6, 0.6, 0.6, 0.305882, 0.122252, 0.122252, 0.122252, 0.305882)

[scripts_panel]

Expand Down
6 changes: 3 additions & 3 deletions .godot/editor/script_editor_cache.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ state={
state={
"bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(),
"column": 0,
"column": 42,
"folded_lines": Array[int]([]),
"h_scroll_position": 0,
"row": 25,
"scroll_position": 5.0,
"row": 66,
"scroll_position": 60.8,
"selection": false,
"syntax_highlighter": "GDScript"
}
46 changes: 30 additions & 16 deletions scenes/mainmenu.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=8 format=3 uid="uid://cedft3vy5hg68"]
[gd_scene load_steps=9 format=3 uid="uid://cedft3vy5hg68"]

[ext_resource type="Script" path="res://scripts/mainmenu.gd" id="1_qj2ne"]
[ext_resource type="FontFile" uid="uid://dbjl1e6kdxpl6" path="res://assets/fonts/PixelOperator8.ttf" id="2_h05dh"]
Expand Down Expand Up @@ -30,6 +30,10 @@ expand_margin_top = 5.0
expand_margin_right = 5.0
expand_margin_bottom = 5.0

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_llkcd"]
bg_color = Color(0.121569, 0.121569, 0.121569, 0.305882)
expand_margin_top = 10.0

[node name="mainmenu" type="Control"]
layout_mode = 3
anchors_preset = 15
Expand Down Expand Up @@ -92,18 +96,23 @@ layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -243.345
offset_left = -539.0
offset_top = 30.0
offset_right = -29.345
offset_bottom = 184.0
offset_right = -6.0
offset_bottom = 203.0
grow_horizontal = 2
scale = Vector2(2, 2)
script = ExtResource("3_rb1ce")

[node name="World1" type="Control" parent="MarginContainer2"]
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer2"]
layout_mode = 2
size_flags_horizontal = 4

[node name="World1" type="Control" parent="MarginContainer2/HBoxContainer"]
y_sort_enabled = true
layout_mode = 2

[node name="Label" type="Label" parent="MarginContainer2/World1"]
[node name="Label2" type="Label" parent="MarginContainer2/HBoxContainer/World1"]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
Expand All @@ -117,7 +126,7 @@ theme_override_font_sizes/font_size = 24
theme_override_styles/normal = SubResource("StyleBoxFlat_8c08p")
text = "World 1"

[node name="TextureRect" type="TextureRect" parent="MarginContainer2/World1"]
[node name="Label1" type="TextureRect" parent="MarginContainer2/HBoxContainer/World1"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
Expand All @@ -134,10 +143,10 @@ texture = ExtResource("3_tlb1w")
expand_mode = 1
stretch_mode = 5

[node name="World4" type="Control" parent="MarginContainer2"]
[node name="World4" type="Control" parent="MarginContainer2/HBoxContainer"]
layout_mode = 2

[node name="Label" type="Label" parent="MarginContainer2/World4"]
[node name="Level4" type="Label" parent="MarginContainer2/HBoxContainer/World4"]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
Expand All @@ -150,7 +159,7 @@ theme_override_fonts/font = ExtResource("2_h05dh")
theme_override_font_sizes/font_size = 24
text = "World 4"

[node name="TextureRect" type="TextureRect" parent="MarginContainer2/World4"]
[node name="Level5" type="TextureRect" parent="MarginContainer2/HBoxContainer/World4"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
Expand All @@ -167,10 +176,10 @@ texture = ExtResource("3_tlb1w")
expand_mode = 1
stretch_mode = 5

[node name="World2" type="Control" parent="MarginContainer2"]
[node name="World2" type="Control" parent="MarginContainer2/HBoxContainer"]
layout_mode = 2

[node name="Label" type="Label" parent="MarginContainer2/World2"]
[node name="Label" type="Label" parent="MarginContainer2/HBoxContainer/World2"]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
Expand All @@ -183,7 +192,7 @@ theme_override_fonts/font = ExtResource("2_h05dh")
theme_override_font_sizes/font_size = 24
text = "World 2"

[node name="TextureRect" type="TextureRect" parent="MarginContainer2/World2"]
[node name="TextureRect" type="TextureRect" parent="MarginContainer2/HBoxContainer/World2"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
Expand All @@ -200,10 +209,10 @@ texture = ExtResource("3_tlb1w")
expand_mode = 1
stretch_mode = 5

[node name="World3" type="Control" parent="MarginContainer2"]
[node name="World3" type="Control" parent="MarginContainer2/HBoxContainer"]
layout_mode = 2

[node name="Label" type="Label" parent="MarginContainer2/World3"]
[node name="Label" type="Label" parent="MarginContainer2/HBoxContainer/World3"]
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
Expand All @@ -216,7 +225,7 @@ theme_override_fonts/font = ExtResource("2_h05dh")
theme_override_font_sizes/font_size = 24
text = "World 3"

[node name="TextureRect" type="TextureRect" parent="MarginContainer2/World3"]
[node name="TextureRect" type="TextureRect" parent="MarginContainer2/HBoxContainer/World3"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
Expand All @@ -233,6 +242,11 @@ texture = ExtResource("3_tlb1w")
expand_mode = 1
stretch_mode = 5

[node name="Panel" type="Panel" parent="MarginContainer2"]
layout_mode = 2
size_flags_vertical = 0
theme_override_styles/panel = SubResource("StyleBoxFlat_llkcd")

[connection signal="pressed" from="MarginContainer/Panel/VBoxContainer/Play" to="." method="_on_play_pressed"]
[connection signal="pressed" from="MarginContainer/Panel/VBoxContainer/Options" to="." method="_on_options_pressed"]
[connection signal="pressed" from="MarginContainer/Panel/VBoxContainer/Exit" to="." method="_on_exit_pressed"]
74 changes: 48 additions & 26 deletions scripts/mainmenu.gd
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
extends Control

class World:
class World extends Control:
var label: String
var x: int

func _init(initial_label: String):
self.label = initial_label
self.x = 0
@onready var world_1 = $MarginContainer2/World1
@onready var world_4 = $MarginContainer2/World4
@onready var world_2 = $MarginContainer2/World2
@onready var world_3 = $MarginContainer2/World3

@onready var world_1 = $MarginContainer2/HBoxContainer/World1
@onready var world_4 = $MarginContainer2/HBoxContainer/World4
@onready var world_2 = $MarginContainer2/HBoxContainer/World2
@onready var world_3 = $MarginContainer2/HBoxContainer/World3

var middle_index: int
var animation_duration: float
Expand All @@ -20,30 +21,50 @@ func animate_sliding(direction: String):
if direction == "right":
_start_animation_right()

@onready var worlds = [world_1, world_2, world_3, world_4]
var world_indices = {world_1: 1, world_2: 2, world_3: 3, world_4: 4}
@onready var worlds = []
var world_indices = {}

var animation_in_progress = false

func _ready():
var world_1_obj = World.new("World 1")
var world_2_obj = World.new("World 2")
var world_3_obj = World.new("World 3")
var world_4_obj = World.new("World 4")

world_1.add_child(world_1_obj)
world_2.add_child(world_2_obj)
world_3.add_child(world_3_obj)
world_4.add_child(world_4_obj)

worlds.append(world_1_obj)
worlds.append(world_2_obj)
worlds.append(world_3_obj)
worlds.append(world_4_obj)

world_indices[world_1_obj] = 1
world_indices[world_2_obj] = 2
world_indices[world_3_obj] = 3
world_indices[world_4_obj] = 4

func _start_animation_right():
animation_in_progress = true
for world in worlds:
if world_indices[world] == 4:
world_indices[world] = 1
else:
world_indices[world] += 1
for world in worlds:
if world_indices[world] == 1:
world.rect_position = Vector2(-185, 0)
world.show()
elif world_indices[world] == 2:
world.rect_position = Vector2(0, 0)
world.show()
elif world_indices[world] == 3:
world.rect_position = Vector2(185, 0)
world.show()
elif world_indices[world] == 4:
world.rect_position = Vector2(185, 0)
world.hide()
var hbox = $MarginContainer2/HBoxContainer
var temp_worlds = worlds.duplicate()
for i in range(temp_worlds.size()):
if world_indices[temp_worlds[i]] == 4:
world_indices[temp_worlds[i]] = 1
else:
world_indices[temp_worlds[i]] += 1
for i in range(temp_worlds.size()):
if world_indices[temp_worlds[i]] == 1:
hbox.move_child(temp_worlds[i].get_parent(), 0)
elif world_indices[temp_worlds[i]] == 2:
hbox.move_child(temp_worlds[i].get_parent(), 1)
elif world_indices[temp_worlds[i]] == 3:
hbox.move_child(temp_worlds[i].get_parent(), 2)
elif world_indices[temp_worlds[i]] == 4:
hbox.move_child(temp_worlds[i].get_parent(), 3)
animation_in_progress = false

func _on_play_pressed():
Expand All @@ -61,5 +82,6 @@ func _input(event: InputEvent):
print("gay")
animate_sliding("right")
elif Input.is_action_just_pressed("ui_left") and not animation_in_progress:
print(world_indices)
print("work")
animate_sliding("left")
print(worlds)

0 comments on commit c84c229

Please sign in to comment.