add map selection

This commit is contained in:
interfisch 2024-11-09 13:47:13 +01:00
parent c1992fcfc1
commit 329d3c7fb2
7 changed files with 78 additions and 10 deletions

View file

@ -162,10 +162,10 @@ anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -483.861
offset_top = -287.132
offset_right = -425.861
offset_bottom = -210.132
offset_left = -166.0
offset_top = -252.0
offset_right = -108.0
offset_bottom = -175.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("2_80mhm")

View file

@ -227,6 +227,7 @@ collision_layer = 4
collision_mask = 4
[node name="CollisionShape2D_Fin" type="CollisionShape2D" parent="area_finish"]
visible = false
position = Vector2(89.5, -1)
shape = SubResource("RectangleShape2D_daqun")
@ -235,6 +236,7 @@ collision_layer = 4
collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="area_cp0"]
visible = false
position = Vector2(278, 575)
shape = SubResource("RectangleShape2D_dltky")
@ -243,6 +245,7 @@ collision_layer = 4
collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="area_cp1"]
visible = false
position = Vector2(194, 840)
shape = SubResource("RectangleShape2D_uys5r")
@ -251,6 +254,7 @@ collision_layer = 4
collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="area_cp2"]
visible = false
position = Vector2(-384, 0)
shape = SubResource("RectangleShape2D_82iti")

View file

@ -227,6 +227,7 @@ collision_layer = 4
collision_mask = 4
[node name="CollisionShape2D_Fin" type="CollisionShape2D" parent="area_finish"]
visible = false
position = Vector2(89.5, -1)
shape = SubResource("RectangleShape2D_daqun")
@ -235,6 +236,7 @@ collision_layer = 4
collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="area_cp0"]
visible = false
position = Vector2(1345, 583)
shape = SubResource("RectangleShape2D_dltky")
@ -243,6 +245,7 @@ collision_layer = 4
collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="area_cp1"]
visible = false
position = Vector2(191, 384)
shape = SubResource("RectangleShape2D_uys5r")
@ -251,6 +254,7 @@ collision_layer = 4
collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="area_cp2"]
visible = false
position = Vector2(-320, 193)
shape = SubResource("RectangleShape2D_82iti")

View file

@ -1,7 +1,11 @@
[gd_scene load_steps=3 format=3 uid="uid://b1uhymisifcho"]
[gd_scene load_steps=7 format=3 uid="uid://b1uhymisifcho"]
[ext_resource type="Script" path="res://scripts/menu.gd" id="1_fushn"]
[ext_resource type="Script" path="res://scripts/menudisplay.gd" id="2_jc4pv"]
[ext_resource type="Script" path="res://scripts/map_selection.gd" id="3_c0mhk"]
[ext_resource type="Texture2D" uid="uid://my0glsan1h2e" path="res://scenes/map_preview/map_00.png" id="3_p822h"]
[ext_resource type="Texture2D" uid="uid://bk32usoetq3b" path="res://scenes/map_preview/map_01.png" id="4_ac8w4"]
[ext_resource type="Texture2D" uid="uid://ole07xte1dxp" path="res://scenes/map_preview/map_02.png" id="5_pnyq7"]
[node name="Menu" type="Node"]
script = ExtResource("1_fushn")
@ -17,10 +21,10 @@ offset_bottom = 572.0
theme_override_font_sizes/font_size = 32
[node name="countdown" type="Label" parent="MenuDisplay"]
offset_left = 874.0
offset_top = 122.0
offset_right = 931.0
offset_bottom = 259.0
offset_left = 114.0
offset_top = 71.0
offset_right = 171.0
offset_bottom = 208.0
theme_override_font_sizes/font_size = 100
text = "5"
@ -93,6 +97,29 @@ offset_bottom = 571.0
scale = Vector2(2, 2)
text = "Fullscreen"
[node name="map_container" type="HFlowContainer" parent="MenuDisplay"]
offset_left = 613.0
offset_top = 31.0
offset_right = 1913.0
offset_bottom = 1263.0
scale = Vector2(0.395, 0.395)
script = ExtResource("3_c0mhk")
[node name="btn_map_00" type="Button" parent="MenuDisplay/map_container"]
layout_mode = 2
toggle_mode = true
icon = ExtResource("3_p822h")
[node name="btn_map_01" type="Button" parent="MenuDisplay/map_container"]
layout_mode = 2
toggle_mode = true
icon = ExtResource("4_ac8w4")
[node name="btn_map_02" type="Button" parent="MenuDisplay/map_container"]
layout_mode = 2
toggle_mode = true
icon = ExtResource("5_pnyq7")
[node name="Timer" type="Timer" parent="."]
wait_time = 5.0

View file

@ -39,7 +39,7 @@ func _ready() -> void:
#Load Map
var checkpoints :Array[String]=[]
var mapscene=load("res://scenes/map_goaltest.tscn")
var mapscene=load(Gamestate.getSelectedMap())
var mapsceneinstance=mapscene.instantiate()
add_child(mapsceneinstance)
for mapc in mapsceneinstance.get_children():

View file

@ -9,6 +9,17 @@ var userinput_prefix="inputP"
var time_elapsed=0
var map_scene_name=""
var map_scene_name_prefix="res://scenes/map_"
var map_scene_name_postfix=".tscn"
func getSelectedMap():
return map_scene_name
func setSelectedMap(mapname):
map_scene_name=map_scene_name_prefix+mapname+map_scene_name_postfix
func checkColoriFree(i):
var free=true
for p in players:

22
scripts/map_selection.gd Normal file
View file

@ -0,0 +1,22 @@
extends HFlowContainer
var button_prefix="btn_map_"
var disabled_mod_color=Color(0.3,0.3,0.3,1.0)
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
for btn in get_children():
btn.pressed.connect(_on_btn_map.bind(btn))
if len(Gamestate.getSelectedMap())<=0: #no map selected (ie on startup)
get_children()[0].emit_signal("pressed") #preselect first map in list
func _on_btn_map(btn):
for b in get_children():
b.self_modulate=disabled_mod_color #show all others disabled
btn.self_modulate=Color(1,1,1,1) #show selected enabled
var btn_name=btn.name
var mapname=btn_name.erase(0,len(button_prefix))
print("Selected Map="+str(mapname))
Gamestate.setSelectedMap(mapname)