Skip to content

Commit

Permalink
bot vs bot: add power/speed selection screen, before starting game #26
Browse files Browse the repository at this point in the history
  • Loading branch information
dulvui committed Jan 16, 2025
1 parent c9e4a47 commit 275473b
Show file tree
Hide file tree
Showing 3 changed files with 291 additions and 1 deletion.
74 changes: 74 additions & 0 deletions game/src/ui/bots-difficulty/BotsDifficultySelection.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# SPDX-FileCopyrightText: 2023 Simon Dalvai <info@simondalvai.org>

# SPDX-License-Identifier: AGPL-3.0-or-later

extends Control


onready var speed_bar_away: TextureProgress = $VBoxContainer/Speed1/SpeedBar1
onready var power_bar_away: TextureProgress = $VBoxContainer/Power1/PowerBar1
onready var speed_bar_home: TextureProgress = $VBoxContainer/Speed2/SpeedBar2
onready var power_bar_home: TextureProgress = $VBoxContainer/Power2/PowerBar2


func _ready() -> void:
Global.set_home_team({})
Global.set_away_team({})
Global.current_league_game = {}
Global.home_team_power = 5
Global.home_team_speed = 5
Global.away_team_power = 5
Global.away_team_speed = 5


func _on_Start_pressed() -> void:
Global.click()
get_tree().change_scene("res://src/ui/game/bots/Bots.tscn")


func _on_GoBack_pressed() -> void:
Global.click()
get_tree().change_scene("res://src/ui/menu/play/Play.tscn")


func _on_PowerPlus1_pressed() -> void:
Global.away_team_power = min(10 , Global.away_team_power + 1)
power_bar_away.value = Global.away_team_power


func _on_PowerMinus1_pressed() -> void:
Global.away_team_power = max(1 , Global.away_team_power - 1)
power_bar_away.value = Global.away_team_power


func _on_SpeedPlus1_pressed() -> void:
Global.away_team_speed = min(10 , Global.away_team_speed + 1)
speed_bar_away.value = Global.away_team_speed


func _on_SpeedMinus1_pressed() -> void:
Global.away_team_speed = max(1 , Global.away_team_speed - 1)
speed_bar_away.value = Global.away_team_speed


func _on_PowerPlus2_pressed() -> void:
Global.home_team_power = min(10 , Global.home_team_power + 1)
power_bar_home.value = Global.home_team_power


func _on_PowerMinus2_pressed() -> void:
Global.home_team_power = max(1 , Global.home_team_power - 1)
power_bar_home.value = Global.home_team_power


func _on_SpeedPlus2_pressed() -> void:
Global.home_team_speed = min(10 , Global.home_team_speed + 1)
speed_bar_home.value = Global.home_team_speed


func _on_SpeedMinus2_pressed() -> void:
Global.home_team_speed = max(1 , Global.home_team_speed - 1)
speed_bar_home.value = Global.home_team_speed



214 changes: 214 additions & 0 deletions game/src/ui/bots-difficulty/BotsDifficultySelection.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
[gd_scene load_steps=6 format=2]

[ext_resource path="res://src/ui/background/Background.tscn" type="PackedScene" id=1]
[ext_resource path="res://src/ui/Icon.tscn" type="PackedScene" id=2]
[ext_resource path="res://src/ui/bots-difficulty/BotsDifficultySelection.gd" type="Script" id=3]
[ext_resource path="res://src/FadeEffect.tscn" type="PackedScene" id=4]
[ext_resource path="res://src/ui/TextureProgress.tscn" type="PackedScene" id=5]

[node name="BotsDifficultySelection" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
rect_pivot_offset = Vector2( -3085, 470 )
script = ExtResource( 3 )

[node name="Background" parent="." instance=ExtResource( 1 )]

[node name="Icon" parent="." instance=ExtResource( 2 )]
position = Vector2( 360, 200 )

[node name="FadeEffect" parent="." instance=ExtResource( 4 )]
node_path = NodePath("../VBoxContainer")

[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -270.0
margin_top = -336.0
margin_right = 278.0
margin_bottom = 512.0
rect_pivot_offset = Vector2( -1608, -111 )
size_flags_horizontal = 0
custom_constants/separation = 8
alignment = 1

[node name="Bot1" type="Label" parent="VBoxContainer"]
margin_right = 548.0
margin_bottom = 64.0
text = "Bot 1"
align = 1

[node name="Power1" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 72.0
margin_right = 548.0
margin_bottom = 156.0
custom_constants/separation = 10

[node name="PowerMinus1" type="Button" parent="VBoxContainer/Power1"]
margin_right = 60.0
margin_bottom = 84.0
rect_min_size = Vector2( 60, 0 )
text = "-"

[node name="PowerBar1" parent="VBoxContainer/Power1" instance=ExtResource( 5 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 70.0
margin_right = 478.0
margin_bottom = 84.0
size_flags_vertical = 1

[node name="PowerPlus1" type="Button" parent="VBoxContainer/Power1"]
margin_left = 488.0
margin_right = 548.0
margin_bottom = 84.0
rect_min_size = Vector2( 60, 0 )
text = "+"

[node name="Speed1" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 164.0
margin_right = 548.0
margin_bottom = 248.0
custom_constants/separation = 10

[node name="SpeedMinus1" type="Button" parent="VBoxContainer/Speed1"]
margin_right = 60.0
margin_bottom = 84.0
rect_min_size = Vector2( 60, 0 )
text = "-"

[node name="SpeedBar1" parent="VBoxContainer/Speed1" instance=ExtResource( 5 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 70.0
margin_right = 478.0
margin_bottom = 84.0
size_flags_vertical = 1
text = "SPEED"

[node name="SpeedPlus1" type="Button" parent="VBoxContainer/Speed1"]
margin_left = 488.0
margin_right = 548.0
margin_bottom = 84.0
rect_min_size = Vector2( 60, 0 )
text = "+"

[node name="HSeparator2" type="HSeparator" parent="VBoxContainer"]
modulate = Color( 1, 1, 1, 0 )
margin_top = 256.0
margin_right = 548.0
margin_bottom = 296.0
rect_min_size = Vector2( 0, 40 )
size_flags_horizontal = 3
custom_constants/separation = 20

[node name="Start" type="Button" parent="VBoxContainer"]
margin_top = 304.0
margin_right = 548.0
margin_bottom = 376.0
text = "PLAY"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="HSeparator3" type="HSeparator" parent="VBoxContainer"]
modulate = Color( 1, 1, 1, 0 )
margin_top = 384.0
margin_right = 548.0
margin_bottom = 424.0
rect_min_size = Vector2( 0, 40 )
size_flags_horizontal = 3
custom_constants/separation = 20

[node name="Bot2" type="Label" parent="VBoxContainer"]
margin_top = 432.0
margin_right = 548.0
margin_bottom = 496.0
text = "Bot 2"
align = 1

[node name="Power2" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 504.0
margin_right = 548.0
margin_bottom = 588.0
custom_constants/separation = 10

[node name="PowerMinus2" type="Button" parent="VBoxContainer/Power2"]
margin_right = 60.0
margin_bottom = 84.0
rect_min_size = Vector2( 60, 0 )
text = "-"

[node name="PowerBar2" parent="VBoxContainer/Power2" instance=ExtResource( 5 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 70.0
margin_right = 478.0
margin_bottom = 84.0
size_flags_vertical = 1

[node name="PowerPlus2" type="Button" parent="VBoxContainer/Power2"]
margin_left = 488.0
margin_right = 548.0
margin_bottom = 84.0
rect_min_size = Vector2( 60, 0 )
text = "+"

[node name="Speed2" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 596.0
margin_right = 548.0
margin_bottom = 680.0
custom_constants/separation = 10

[node name="SpeedMinus2" type="Button" parent="VBoxContainer/Speed2"]
margin_right = 60.0
margin_bottom = 84.0
rect_min_size = Vector2( 60, 0 )
text = "-"

[node name="SpeedBar2" parent="VBoxContainer/Speed2" instance=ExtResource( 5 )]
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 70.0
margin_right = 478.0
margin_bottom = 84.0
size_flags_vertical = 1
text = "SPEED"

[node name="SpeedPlus2" type="Button" parent="VBoxContainer/Speed2"]
margin_left = 488.0
margin_right = 548.0
margin_bottom = 84.0
rect_min_size = Vector2( 60, 0 )
text = "+"

[node name="HSeparator" type="HSeparator" parent="VBoxContainer"]
modulate = Color( 1, 1, 1, 0 )
margin_top = 688.0
margin_right = 548.0
margin_bottom = 768.0
rect_min_size = Vector2( 0, 80 )
size_flags_horizontal = 3
custom_constants/separation = 20

[node name="GoBack" type="Button" parent="VBoxContainer"]
margin_top = 776.0
margin_right = 548.0
margin_bottom = 848.0
text = "GO_BACK"
__meta__ = {
"_edit_use_anchors_": false
}

[connection signal="pressed" from="VBoxContainer/Power1/PowerMinus1" to="." method="_on_PowerMinus1_pressed"]
[connection signal="pressed" from="VBoxContainer/Power1/PowerPlus1" to="." method="_on_PowerPlus1_pressed"]
[connection signal="pressed" from="VBoxContainer/Speed1/SpeedMinus1" to="." method="_on_SpeedMinus1_pressed"]
[connection signal="pressed" from="VBoxContainer/Speed1/SpeedPlus1" to="." method="_on_SpeedPlus1_pressed"]
[connection signal="pressed" from="VBoxContainer/Start" to="." method="_on_Start_pressed"]
[connection signal="pressed" from="VBoxContainer/Power2/PowerMinus2" to="." method="_on_PowerMinus2_pressed"]
[connection signal="pressed" from="VBoxContainer/Power2/PowerPlus2" to="." method="_on_PowerPlus2_pressed"]
[connection signal="pressed" from="VBoxContainer/Speed2/SpeedMinus2" to="." method="_on_SpeedMinus2_pressed"]
[connection signal="pressed" from="VBoxContainer/Speed2/SpeedPlus2" to="." method="_on_SpeedPlus2_pressed"]
[connection signal="pressed" from="VBoxContainer/GoBack" to="." method="_on_GoBack_pressed"]
4 changes: 3 additions & 1 deletion game/src/ui/menu/play/Play.gd
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ func _on_OneVsOne_pressed() -> void:
Global.set_away_team({})
Global.home_team_power = 10
Global.home_team_speed = 10
Global.away_team_power = 10
Global.away_team_speed = 10
get_tree().change_scene("res://src/ui/game/multiplayer/Multiplayer.tscn")


Expand All @@ -39,7 +41,7 @@ func _on_BotVsBot_pressed() -> void:
Global.away_team_speed = 10
Global.home_team_power = 2
Global.home_team_speed = 2
get_tree().change_scene("res://src/ui/game/bots/Bots.tscn")
get_tree().change_scene("res://src/ui/bots-difficulty/BotsDifficultySelection.tscn")


func _on_Back_pressed() -> void:
Expand Down

0 comments on commit 275473b

Please sign in to comment.