late Sunday update: netcode changes, bot improvements, bot development

This commit is contained in:
Lurkars 2019-08-07 20:29:46 +02:00
parent c95bb8fb55
commit b928e67fb1
46 changed files with 3129 additions and 135397 deletions

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,7 @@ GAME_EXEC_ARG_PORT = '--port={0}'
GAME_EXEC_ARG_ID = '--server-id={0}'
GAME_EXEC_ARG_SECRET = '--secret={0}'
GAME_EXEC_ARG_BOTS = '--bots={0}'
GAME_EXEC_ARG_BOT_DIFFICULTY = '--bot-difficulty={0}'
GAME_EXEC_ARG_SERVER_ADDR = '--server-addr={0}'
GAME_EXEC_ARG_API_ADDR = '--api-addr={0}'
@ -23,7 +24,7 @@ try:
with sqlite3.connect("database.db") as con:
cur = con.cursor()
cur.execute(
'CREATE TABLE IF NOT EXISTS games (id INTEGER PRIMARY KEY, name TEXT, secret TEXT, ip TEXT, running INTEGER, port INTEGER, player_count INTEGER, bots INTEGER)')
'CREATE TABLE IF NOT EXISTS games (id INTEGER PRIMARY KEY, name TEXT, secret TEXT, ip TEXT, running INTEGER, port INTEGER, player_count INTEGER, bots INTEGER, bot_difficulty REAL)')
con.commit()
except:
con.rollback()
@ -42,10 +43,14 @@ def create_game():
abort(400)
bots = False
bot_difficulty = -1
name = request.json.get('name')
if 'bots' in request.json:
bots = request.json.get('bots')
if 'bot-difficulty' in request.json:
bot_difficulty = request.json.get('bot-difficulty')
game_count = 0
try:
with sqlite3.connect("database.db") as con:
@ -81,8 +86,8 @@ def create_game():
remote_addr = request.headers.getlist(
"X-Forwarded-For")[0].rpartition(' ')[-1]
cur.execute("INSERT INTO games (name,secret,ip,port,bots,player_count,running) VALUES (?,?,?,?,?,0,0)",
(name, secret, remote_addr, port, bots))
cur.execute("INSERT INTO games (name,secret,ip,port,bots,bot-difficulty,player_count,running) VALUES (?,?,?,?,?,0,0)",
(name, secret, remote_addr, port, bots, bot_difficulty))
con.commit()
cur.execute("SELECT id FROM games WHERE secret=?",
(secret,))
@ -98,6 +103,8 @@ def create_game():
secret),
GAME_EXEC_ARG_BOTS.format(
int(bots)),
GAME_EXEC_ARG_BOT_DIFFICULTY.format(
float(bot_difficulty)),
GAME_EXEC_ARG_SERVER_ADDR.format(
'127.0.0.1'), # localhost
GAME_EXEC_ARG_API_ADDR.format('http://127.0.0.1:5000/')])

View File

@ -15,6 +15,11 @@ _global_script_classes=[ {
"path": "res://scripts/player/base_inventory.gd"
}, {
"base": "Spatial",
"class": "BotPlayer",
"language": "GDScript",
"path": "res://scripts/player/bot_controls.gd"
}, {
"base": "Spatial",
"class": "Game",
"language": "GDScript",
"path": "res://scripts/game/game.gd"
@ -56,6 +61,7 @@ _global_script_classes=[ {
} ]
_global_script_class_icons={
"BaseInventory": "",
"BotPlayer": "",
"Game": "",
"GameServer": "",
"GameServerRequests": "",
@ -82,7 +88,7 @@ game_server="*res://scripts/networking/game_server.gd"
roads_factory="*res://scripts/road/roads_factory.gd"
config="*res://scripts/game/config.gd"
config_apply="*res://scripts/game/config_apply.gd"
util="*res://scripts/Util.gd"
util="*res://scripts/util.gd"
[display]
@ -174,6 +180,12 @@ controls_menu={
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null)
]
}
controls_capture={
"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":80,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":10,"pressure":0.0,"pressed":false,"script":null)
]
}
[layer_names]

View File

@ -3,7 +3,7 @@ BACK,Back,Zurück
MULTIPLAYER,Multiplayer,Multiplayer
PRACTISE,Practise,Training
SETTINGS,Settings,Einstellungen
DEBUG,Debug en,Debug DE
DEBUG,Debug EN,Debug DE
HOST,Host,Host
JOIN,Join,Beitreten
QUIT,Quit,Beenden
@ -15,6 +15,9 @@ CREATE_GAME,Create game,Spiel erstellen
PLAYER_NAME,Name,Name
PLAYER_COLOR,Color,Farbe
BOTS,Bots,Bots
BOT_DIFFICULTY,Difficulty,Schwierigkeit
DIFFICULTY_EASY,Easy,Einfach
DIFFICULTY_DIFFUCULT,Difficult,Schwierig
GAME,Game,Spiel
PORT,Port,Port
IP,Ip,IP
@ -25,7 +28,7 @@ GAME_NAME,Name,Name
READY,Ready,Bereit
ALERT,Alert!,Fehler!
CONTROLS,Controls,Steuerung
RESET,Reset,Zurücksetzen
RESET,Press reset…,Zurücksetzen drücken…
PRESS_KEY,Press any key...,Taste drücken…
KEY_ALREADY_TAKEN,Key already in use:,Taste wird bereits verwendet:
ERROR_SERVER_CREATION,Cannot create server!,Server konnte nicht erstellt werden!
@ -41,6 +44,9 @@ LOCALE,Language,Sprache
LOCALE_EN,English,Englisch (english)
LOCALE_DE,German (deutsch),Deutsch
GRAPHICS,Graphics,Grafik
FULLSCREEN,Fullscreen,Vollbild
LIGHT,Light,Licht
SHADOWS,Shadows,Schatten
SAVE,Save,Speichern
APPLY,Apply,Übernehmen
KEYBOARD,Keyboard,Tastatur
@ -91,3 +97,4 @@ controls_next_road_variant,Next variant,Nächste Variante
controls_prev_road_variant,Previous variant,Vorherige Variante
controls_reset,Reset,Zurücksetzen
controls_menu,Menu,Menu
controls_capture,Screen Capture,Aufzeichnung

1 en de
3 MULTIPLAYER Multiplayer Multiplayer
4 PRACTISE Practise Training
5 SETTINGS Settings Einstellungen
6 DEBUG Debug en Debug EN Debug DE
7 HOST Host Host
8 JOIN Join Beitreten
9 QUIT Quit Beenden
15 PLAYER_NAME Name Name
16 PLAYER_COLOR Color Farbe
17 BOTS Bots Bots
18 BOT_DIFFICULTY Difficulty Schwierigkeit
19 DIFFICULTY_EASY Easy Einfach
20 DIFFICULTY_DIFFUCULT Difficult Schwierig
21 GAME Game Spiel
22 PORT Port Port
23 IP Ip IP
28 READY Ready Bereit
29 ALERT Alert! Fehler!
30 CONTROLS Controls Steuerung
31 RESET Reset Press reset… Zurücksetzen Zurücksetzen drücken…
32 PRESS_KEY Press any key... Taste drücken…
33 KEY_ALREADY_TAKEN Key already in use: Taste wird bereits verwendet:
34 ERROR_SERVER_CREATION Cannot create server! Server konnte nicht erstellt werden!
44 GRAPHICS Graphics Grafik
45 SAVE FULLSCREEN Save Fullscreen Speichern Vollbild
46 APPLY LIGHT Apply Light Übernehmen Licht
47 SHADOWS Shadows Schatten
48 SAVE Save Speichern
49 APPLY Apply Übernehmen
50 KEYBOARD Keyboard Tastatur
51 JOYPAD Joypad Joypad
52 SERVER_ADDR Server address Server Adresse
97 controls_menu Menu Menu
98 controls_capture Screen Capture Aufzeichnung
99
100

View File

@ -6,7 +6,6 @@
[ext_resource path="res://assets/icons/exitRight.png" type="Texture" id=4]
[ext_resource path="res://assets/icons/return.png" type="Texture" id=5]
[node name="direct_host_menu" type="Control"]
anchor_left = 0.5
anchor_top = 0.5
@ -24,44 +23,67 @@ anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -217.5
margin_top = -53.5
margin_right = 217.5
margin_bottom = 53.5
margin_left = -217.0
margin_top = -53.0
margin_right = 218.0
margin_bottom = 94.0
grow_horizontal = 2
grow_vertical = 2
[node name="HBoxContainer" type="HBoxContainer" parent="menu"]
margin_left = 16.0
margin_top = 12.0
margin_right = 429.0
margin_bottom = 52.0
[node name="VBoxContainer" type="VBoxContainer" parent="menu"]
margin_left = 12.0
margin_top = 11.0
margin_right = 423.0
margin_bottom = 92.0
[node name="port_label" type="Label" parent="menu/HBoxContainer"]
margin_top = 6.0
[node name="HBoxContainer" type="HBoxContainer" parent="menu/VBoxContainer"]
margin_right = 411.0
margin_bottom = 37.0
[node name="port_label" type="Label" parent="menu/VBoxContainer/HBoxContainer"]
margin_top = 5.0
margin_right = 65.0
margin_bottom = 33.0
margin_bottom = 32.0
text = "PORT"
[node name="port" type="SpinBox" parent="menu/HBoxContainer"]
[node name="port" type="SpinBox" parent="menu/VBoxContainer/HBoxContainer"]
margin_left = 69.0
margin_right = 266.0
margin_bottom = 40.0
focus_neighbour_right = NodePath("../bots")
focus_neighbour_bottom = NodePath("../../back")
margin_right = 411.0
margin_bottom = 37.0
focus_neighbour_bottom = NodePath("../../HBoxContainer2/bots")
focus_mode = 2
size_flags_horizontal = 3
max_value = 65535.0
value = 8128.0
align = 2
[node name="bots" type="CheckButton" parent="menu/HBoxContainer"]
margin_left = 270.0
margin_right = 413.0
[node name="HBoxContainer2" type="HBoxContainer" parent="menu/VBoxContainer"]
margin_top = 41.0
margin_right = 411.0
margin_bottom = 81.0
[node name="bots" type="CheckButton" parent="menu/VBoxContainer/HBoxContainer2"]
margin_right = 143.0
margin_bottom = 40.0
focus_neighbour_left = NodePath("../port")
focus_neighbour_bottom = NodePath("../../host")
focus_neighbour_top = NodePath("../../HBoxContainer/port")
focus_neighbour_right = NodePath("../bot_difficulty")
focus_neighbour_bottom = NodePath("../../../back")
text = "BOTS"
[node name="bot_difficulty" type="HSlider" parent="menu/VBoxContainer/HBoxContainer2"]
margin_left = 147.0
margin_right = 411.0
margin_bottom = 40.0
focus_neighbour_left = NodePath("../bots")
focus_neighbour_top = NodePath("../../HBoxContainer/port")
focus_neighbour_bottom = NodePath("../../../host")
size_flags_horizontal = 3
size_flags_vertical = 1
max_value = 1.0
step = 0.1
tick_count = 11
ticks_on_borders = true
[node name="host" type="Button" parent="menu"]
anchor_left = 1.0
anchor_top = 1.0
@ -73,7 +95,7 @@ grow_horizontal = 0
grow_vertical = 0
rect_pivot_offset = Vector2( 1.89856, 0.845154 )
focus_neighbour_left = NodePath("../back")
focus_neighbour_top = NodePath("../GridContainer/bots")
focus_neighbour_top = NodePath("../VBoxContainer/HBoxContainer2/bot_difficulty")
custom_fonts/font = ExtResource( 3 )
text = "HOST"
icon = ExtResource( 4 )
@ -85,11 +107,12 @@ anchor_bottom = 1.0
margin_top = -56.0
margin_right = 132.0
rect_pivot_offset = Vector2( 0.606262, -0.447205 )
focus_neighbour_top = NodePath("../GridContainer/port")
focus_neighbour_top = NodePath("../VBoxContainer/HBoxContainer2/bots")
focus_neighbour_right = NodePath("../host")
custom_fonts/font = ExtResource( 3 )
text = "BACK"
icon = ExtResource( 5 )
flat = true
[connection signal="toggled" from="menu/VBoxContainer/HBoxContainer2/bots" to="." method="_on_bots_toggled"]
[connection signal="pressed" from="menu/host" to="." method="_on_host_pressed"]
[connection signal="pressed" from="menu/back" to="." method="_on_back_pressed"]

View File

@ -6,7 +6,6 @@
[ext_resource path="res://assets/icons/exitRight.png" type="Texture" id=4]
[ext_resource path="res://assets/icons/return.png" type="Texture" id=5]
[node name="direct_join_menu" type="Control"]
anchor_left = 0.5
anchor_top = 0.5
@ -70,6 +69,7 @@ margin_right = 407.0
margin_bottom = 78.0
focus_neighbour_top = NodePath("../ip")
focus_neighbour_bottom = NodePath("../../join")
focus_mode = 2
max_value = 65535.0
value = 8128.0
align = 2

View File

@ -23,9 +23,9 @@ anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -217.5
margin_top = -130.5
margin_top = -136.5
margin_right = 217.5
margin_bottom = 130.5
margin_bottom = 136.5
grow_horizontal = 2
grow_vertical = 2
@ -33,13 +33,13 @@ grow_vertical = 2
margin_left = 19.0
margin_top = 21.0
margin_right = 418.0
margin_bottom = 197.0
margin_bottom = 210.0
[node name="player_settings" parent="menu/VBoxContainer" instance=ExtResource( 3 )]
margin_left = 0.0
margin_top = 0.0
margin_right = 399.0
margin_bottom = 132.0
margin_bottom = 145.0
[node name="name_label" parent="menu/VBoxContainer/player_settings/VBoxContainer" index="0"]
margin_right = 399.0
@ -61,19 +61,38 @@ margin_top = 103.0
margin_right = 399.0
margin_bottom = 136.0
focus_neighbour_top = NodePath("../name")
focus_neighbour_bottom = NodePath("../../../bots")
focus_neighbour_bottom = NodePath("../../../HBoxContainer/bots")
[node name="bots" type="CheckButton" parent="menu/VBoxContainer"]
margin_top = 136.0
[node name="HBoxContainer" type="HBoxContainer" parent="menu/VBoxContainer"]
margin_top = 149.0
margin_right = 399.0
margin_bottom = 189.0
[node name="bots" type="CheckButton" parent="menu/VBoxContainer/HBoxContainer"]
margin_right = 143.0
margin_bottom = 176.0
focus_neighbour_top = NodePath("../player_settings/VBoxContainer/color")
focus_neighbour_bottom = NodePath("../../start")
margin_bottom = 40.0
focus_neighbour_top = NodePath("../../player_settings/VBoxContainer/color")
focus_neighbour_right = NodePath("../bot_difficulty")
focus_neighbour_bottom = NodePath("../../../back")
size_flags_horizontal = 0
pressed = true
text = "BOTS"
flat = true
[node name="bot_difficulty" type="HSlider" parent="menu/VBoxContainer/HBoxContainer"]
margin_left = 147.0
margin_right = 399.0
margin_bottom = 40.0
focus_neighbour_left = NodePath("../bots")
focus_neighbour_top = NodePath("../../player_settings/VBoxContainer/color")
focus_neighbour_bottom = NodePath("../../../start")
size_flags_horizontal = 3
size_flags_vertical = 1
max_value = 1.0
step = 0.1
tick_count = 11
ticks_on_borders = true
[node name="start" type="Button" parent="menu"]
anchor_left = 1.0
anchor_top = 1.0
@ -84,7 +103,7 @@ margin_top = -56.0
grow_horizontal = 0
rect_pivot_offset = Vector2( 1.89856, 0.845154 )
focus_neighbour_left = NodePath("../back")
focus_neighbour_top = NodePath("../VBoxContainer/bots")
focus_neighbour_top = NodePath("../VBoxContainer/HBoxContainer/bot_difficulty")
custom_fonts/font = ExtResource( 4 )
text = "START_GAME"
icon = ExtResource( 5 )
@ -96,12 +115,13 @@ anchor_bottom = 1.0
margin_top = -56.0
margin_right = 132.0
rect_pivot_offset = Vector2( 0.606262, -0.447205 )
focus_neighbour_top = NodePath("../VBoxContainer/bots")
focus_neighbour_top = NodePath("../VBoxContainer/HBoxContainer/bots")
focus_neighbour_right = NodePath("../start")
custom_fonts/font = ExtResource( 4 )
text = "BACK"
icon = ExtResource( 6 )
flat = true
[connection signal="toggled" from="menu/VBoxContainer/HBoxContainer/bots" to="." method="_on_bots_toggled"]
[connection signal="pressed" from="menu/start" to="." method="_on_start_pressed"]
[connection signal="pressed" from="menu/back" to="." method="_on_back_pressed"]

View File

@ -8,7 +8,6 @@
[ext_resource path="res://assets/icons/power.png" type="Texture" id=6]
[ext_resource path="res://assets/icons/question.png" type="Texture" id=7]
[node name="main_menu" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
@ -80,13 +79,14 @@ text = "QUIT"
icon = ExtResource( 6 )
flat = true
[node name="error_dialog" type="AcceptDialog" parent="."]
margin_right = 138.0
margin_bottom = 84.0
window_title = "ALERT"
dialog_text = "Server disconnected!"
[node name="version" type="Label" parent="."]
anchor_top = 1.0
anchor_bottom = 1.0
margin_top = -27.0
margin_right = 40.0
text = "v.0.0.3"
[node name="Button" type="Button" parent="."]
[node name="info" type="Button" parent="."]
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
@ -95,8 +95,21 @@ margin_left = -62.0
margin_top = -56.0
icon = ExtResource( 7 )
flat = true
[connection signal="pressed" from="menu/VBoxContainer/multiplayer" to="." method="_on_multiplayer_pressed"]
[node name="info_popup" type="WindowDialog" parent="."]
margin_left = 805.0
margin_top = 407.5
margin_right = 853.0
margin_bottom = 447.5
[node name="error_dialog" type="AcceptDialog" parent="."]
margin_right = 324.0
margin_bottom = 84.0
window_title = "ALERT"
dialog_text = "Server disconnected!"
[connection signal="pressed" from="menu/VBoxContainer/multiplayer" to="." method="_on_online_pressed"]
[connection signal="pressed" from="menu/VBoxContainer/multiplayer" to="." method="_on_multiplayer_pressed"]
[connection signal="pressed" from="menu/VBoxContainer/practice" to="." method="_on_practice_pressed"]
[connection signal="pressed" from="menu/VBoxContainer/settings" to="." method="_on_settings_pressed"]
[connection signal="pressed" from="menu/VBoxContainer/quit" to="." method="_on_quit_pressed"]
[connection signal="pressed" from="info" to="." method="_on_info_pressed"]

View File

@ -6,7 +6,6 @@
[ext_resource path="res://assets/icons/fistPlus.png" type="Texture" id=4]
[ext_resource path="res://assets/icons/return.png" type="Texture" id=5]
[node name="server_create_menu" type="Control"]
anchor_left = 0.5
anchor_top = 0.5
@ -57,13 +56,27 @@ size_flags_horizontal = 3
margin_top = 41.0
margin_right = 143.0
margin_bottom = 81.0
focus_neighbour_left = NodePath("../../back")
focus_neighbour_top = NodePath("../name")
focus_neighbour_right = NodePath("../../create")
focus_neighbour_bottom = NodePath("../../create")
focus_neighbour_right = NodePath("../bot_difficulty")
focus_neighbour_bottom = NodePath("../../back")
size_flags_horizontal = 0
text = "BOTS"
[node name="bot_difficulty" type="HSlider" parent="menu/GridContainer"]
margin_left = 166.0
margin_top = 41.0
margin_right = 572.0
margin_bottom = 81.0
focus_neighbour_left = NodePath("../bots")
focus_neighbour_top = NodePath("../name")
focus_neighbour_bottom = NodePath("../../create")
size_flags_horizontal = 3
size_flags_vertical = 1
max_value = 1.0
step = 0.1
tick_count = 11
ticks_on_borders = true
[node name="create" type="Button" parent="menu"]
anchor_left = 1.0
anchor_top = 1.0
@ -76,8 +89,7 @@ grow_horizontal = 0
grow_vertical = 0
rect_pivot_offset = Vector2( 1.89856, 0.845154 )
focus_neighbour_left = NodePath("../back")
focus_neighbour_top = NodePath("../GridContainer/bots")
focus_neighbour_right = NodePath("../GridContainer/name")
focus_neighbour_top = NodePath("../GridContainer/bot_difficulty")
custom_fonts/font = ExtResource( 3 )
text = "CREATE_GAME"
icon = ExtResource( 4 )
@ -96,5 +108,6 @@ text = "Back"
icon = ExtResource( 5 )
flat = true
[connection signal="text_changed" from="menu/GridContainer/name" to="." method="_on_name_text_changed"]
[connection signal="toggled" from="menu/GridContainer/bots" to="." method="_on_bots_toggled"]
[connection signal="pressed" from="menu/create" to="." method="_on_create_pressed"]
[connection signal="pressed" from="menu/back" to="." method="_on_back_pressed"]

View File

@ -20,7 +20,7 @@
[ext_resource path="res://assets/icons/DPAD_right.png" type="Texture" id=18]
[ext_resource path="res://assets/icons/fightJ.png" type="Texture" id=19]
[node name="settings_controls_menu" type="Control"]
[node name="settings_controls_menu" type="Tabs"]
margin_left = 12.0
margin_top = 8.0
margin_right = 858.0

View File

@ -0,0 +1,53 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://scripts/menus/settings_game_menu.gd" type="Script" id=1]
[ext_resource path="res://scenes/menus/SettingsPlayerMenu.tscn" type="PackedScene" id=2]
[node name="settings_game_menu" type="Tabs"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
margin_top = 45.0
margin_right = -4.0
margin_bottom = -4.0
focus_neighbour_right = NodePath("../controls")
focus_neighbour_bottom = NodePath("GridContainer/settings_player/VBoxContainer/name")
focus_mode = 2
script = ExtResource( 1 )
[node name="GridContainer" type="GridContainer" parent="."]
margin_left = 9.0
margin_top = 10.0
margin_right = 416.0
margin_bottom = 202.0
[node name="settings_player" parent="GridContainer" instance=ExtResource( 2 )]
margin_left = 0.0
margin_top = 0.0
margin_right = 407.0
margin_bottom = 148.0
[node name="HBoxContainer" type="HBoxContainer" parent="GridContainer"]
margin_top = 152.0
margin_right = 407.0
margin_bottom = 192.0
[node name="bots" type="CheckButton" parent="GridContainer/HBoxContainer"]
margin_right = 109.0
margin_bottom = 40.0
focus_neighbour_top = NodePath("../settings_player/VBoxContainer/color")
focus_neighbour_bottom = NodePath("../../../../HBoxContainer/apply")
size_flags_horizontal = 0
size_flags_vertical = 0
text = "Bots"
[node name="bot_difficulty" type="HSlider" parent="GridContainer/HBoxContainer"]
margin_left = 113.0
margin_right = 407.0
margin_bottom = 40.0
size_flags_horizontal = 3
size_flags_vertical = 1
max_value = 1.0
step = 0.1
tick_count = 11
ticks_on_borders = true

View File

@ -0,0 +1,44 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://scripts/menus/settings_graphics_menu.gd" type="Script" id=1]
[node name="settings_graphics_menu" type="Tabs"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
margin_top = 45.0
margin_right = -4.0
margin_bottom = -4.0
focus_neighbour_left = NodePath("../controls")
focus_neighbour_right = NodePath("../system")
focus_mode = 2
script = ExtResource( 1 )
[node name="VBoxContainer" type="VBoxContainer" parent="."]
margin_right = 40.0
margin_bottom = 40.0
[node name="resolution" type="OptionButton" parent="VBoxContainer"]
margin_right = 192.0
margin_bottom = 20.0
[node name="fullscreen" type="CheckButton" parent="VBoxContainer"]
margin_top = 24.0
margin_right = 192.0
margin_bottom = 64.0
pressed = true
text = "FULLSCREEN"
[node name="light" type="CheckButton" parent="VBoxContainer"]
margin_top = 68.0
margin_right = 192.0
margin_bottom = 108.0
text = "LIGHT"
[node name="shadows" type="CheckButton" parent="VBoxContainer"]
margin_top = 112.0
margin_right = 192.0
margin_bottom = 152.0
disabled = true
text = "SHADOWS"
[connection signal="toggled" from="VBoxContainer/light" to="." method="_on_light_toggled"]

View File

@ -1,12 +1,14 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=10 format=2]
[ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1]
[ext_resource path="res://scripts/menus/settings_menu.gd" type="Script" id=2]
[ext_resource path="res://scenes/menus/BaseMenu.tscn" type="PackedScene" id=3]
[ext_resource path="res://scenes/menus/SettingsPlayerMenu.tscn" type="PackedScene" id=4]
[ext_resource path="res://scenes/menus/SettingsGameMenu.tscn" type="PackedScene" id=4]
[ext_resource path="res://scenes/menus/SettingsControlsMenu.tscn" type="PackedScene" id=5]
[ext_resource path="res://assets/icons/checkmark.png" type="Texture" id=6]
[ext_resource path="res://assets/icons/save.png" type="Texture" id=7]
[ext_resource path="res://scenes/menus/SettingsGraphicsMenu.tscn" type="PackedScene" id=6]
[ext_resource path="res://scenes/menus/SettingsSystemMenu.tscn" type="PackedScene" id=7]
[ext_resource path="res://assets/icons/checkmark.png" type="Texture" id=8]
[ext_resource path="res://assets/icons/save.png" type="Texture" id=9]
[node name="settings_menu" type="Control"]
anchor_right = 1.0
@ -40,65 +42,9 @@ size_flags_horizontal = 3
size_flags_vertical = 3
tab_align = 0
[node name="game" type="Tabs" parent="menu/tabs"]
editor/display_folded = true
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
margin_top = 45.0
margin_right = -4.0
margin_bottom = -4.0
focus_neighbour_right = NodePath("../controls")
focus_neighbour_bottom = NodePath("GridContainer/settings_player/VBoxContainer/name")
focus_mode = 2
[node name="game" parent="menu/tabs" instance=ExtResource( 4 )]
[node name="GridContainer" type="GridContainer" parent="menu/tabs/game"]
margin_left = 9.0
margin_top = 10.0
margin_right = 416.0
margin_bottom = 200.0
[node name="settings_player" parent="menu/tabs/game/GridContainer" instance=ExtResource( 4 )]
margin_left = 0.0
margin_top = 0.0
margin_right = 407.0
margin_bottom = 146.0
[node name="name_label" parent="menu/tabs/game/GridContainer/settings_player/VBoxContainer" index="0"]
margin_right = 407.0
margin_bottom = 27.0
[node name="name" parent="menu/tabs/game/GridContainer/settings_player/VBoxContainer" index="1"]
margin_top = 31.0
margin_right = 407.0
margin_bottom = 68.0
focus_neighbour_top = NodePath("../../../..")
focus_neighbour_bottom = NodePath("../color")
[node name="color_label" parent="menu/tabs/game/GridContainer/settings_player/VBoxContainer" index="2"]
margin_top = 72.0
margin_right = 407.0
margin_bottom = 99.0
[node name="color" parent="menu/tabs/game/GridContainer/settings_player/VBoxContainer" index="3"]
margin_top = 103.0
margin_right = 407.0
margin_bottom = 136.0
focus_neighbour_top = NodePath("../name")
focus_neighbour_bottom = NodePath("../../../bots")
[node name="bots" type="CheckButton" parent="menu/tabs/game/GridContainer"]
margin_top = 150.0
margin_right = 143.0
margin_bottom = 190.0
focus_neighbour_top = NodePath("../settings_player/VBoxContainer/color")
focus_neighbour_bottom = NodePath("../../../../HBoxContainer/apply")
size_flags_horizontal = 0
size_flags_vertical = 0
text = "Bots"
[node name="controls" type="Tabs" parent="menu/tabs"]
editor/display_folded = true
[node name="controls" parent="menu/tabs" instance=ExtResource( 5 )]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
@ -106,125 +52,14 @@ margin_left = 4.0
margin_top = 45.0
margin_right = -4.0
margin_bottom = -4.0
focus_neighbour_left = NodePath("../game")
focus_neighbour_right = NodePath("../graphics")
focus_mode = 2
[node name="settings_controls" parent="menu/tabs/controls" instance=ExtResource( 5 )]
[node name="empty" parent="menu/tabs/controls/settings_controls/ScrollContainer/grid" index="0"]
margin_bottom = 27.0
[node name="keyboard_label" parent="menu/tabs/controls/settings_controls/ScrollContainer/grid" index="1"]
margin_bottom = 27.0
[node name="joypad_label" parent="menu/tabs/controls/settings_controls/ScrollContainer/grid" index="2"]
margin_bottom = 27.0
[node name="action_button" parent="menu/tabs/controls/settings_controls/key_dialog" index="3"]
margin_right = 302.0
margin_bottom = 110.0
[node name="graphics" type="Tabs" parent="menu/tabs"]
[node name="graphics" parent="menu/tabs" instance=ExtResource( 6 )]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
margin_top = 45.0
margin_right = -4.0
margin_bottom = -4.0
focus_neighbour_left = NodePath("../controls")
focus_neighbour_right = NodePath("../system")
focus_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="menu/tabs/graphics"]
margin_right = 40.0
margin_bottom = 40.0
[node name="resolution" type="OptionButton" parent="menu/tabs/graphics/VBoxContainer"]
margin_right = 248.0
margin_bottom = 33.0
[node name="fullscreen" type="CheckButton" parent="menu/tabs/graphics/VBoxContainer"]
margin_top = 37.0
margin_right = 248.0
margin_bottom = 77.0
pressed = true
text = "FULLSCREEN"
[node name="light" type="CheckButton" parent="menu/tabs/graphics/VBoxContainer"]
margin_top = 81.0
margin_right = 248.0
margin_bottom = 121.0
text = "LIGHT"
[node name="shadows" type="CheckButton" parent="menu/tabs/graphics/VBoxContainer"]
margin_top = 125.0
margin_right = 248.0
margin_bottom = 165.0
disabled = true
text = "SHADOWS"
[node name="system" type="Tabs" parent="menu/tabs"]
editor/display_folded = true
[node name="system" parent="menu/tabs" instance=ExtResource( 7 )]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
margin_top = 45.0
margin_right = -4.0
margin_bottom = -4.0
focus_neighbour_left = NodePath("../graphics")
focus_mode = 2
[node name="GridContainer" type="GridContainer" parent="menu/tabs/system"]
margin_left = 12.0
margin_top = 8.0
margin_right = 907.0
margin_bottom = 124.0
columns = 2
[node name="locale_label" type="Label" parent="menu/tabs/system/GridContainer"]
margin_right = 88.0
margin_bottom = 14.0
text = "LOCALE"
valign = 1
[node name="locales" type="ItemList" parent="menu/tabs/system/GridContainer"]
margin_left = 92.0
margin_right = 895.0
margin_bottom = 14.0
size_flags_horizontal = 3
auto_height = true
[node name="server_addr_label" type="Label" parent="menu/tabs/system/GridContainer"]
margin_top = 23.0
margin_right = 88.0
margin_bottom = 37.0
text = "SERVER_ADDR"
valign = 1
[node name="server_addr" type="LineEdit" parent="menu/tabs/system/GridContainer"]
margin_left = 92.0
margin_top = 18.0
margin_right = 895.0
margin_bottom = 42.0
[node name="api_addr_label" type="Label" parent="menu/tabs/system/GridContainer"]
margin_top = 51.0
margin_right = 88.0
margin_bottom = 65.0
text = "API_ADDR"
valign = 1
[node name="api_addr" type="LineEdit" parent="menu/tabs/system/GridContainer"]
margin_left = 92.0
margin_top = 46.0
margin_right = 895.0
margin_bottom = 70.0
[node name="HBoxContainer" type="HBoxContainer" parent="menu"]
editor/display_folded = true
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
@ -248,7 +83,7 @@ focus_neighbour_right = NodePath("../save")
size_flags_horizontal = 10
size_flags_vertical = 10
text = "APPLY"
icon = ExtResource( 6 )
icon = ExtResource( 8 )
flat = true
align = 0
@ -263,17 +98,10 @@ focus_neighbour_top = NodePath("../../tabs/game")
size_flags_horizontal = 10
size_flags_vertical = 10
text = "SAVE"
icon = ExtResource( 7 )
icon = ExtResource( 9 )
flat = true
align = 0
[connection signal="toggled" from="menu/tabs/graphics/VBoxContainer/light" to="." method="_on_light_toggled"]
[connection signal="item_selected" from="menu/tabs/system/GridContainer/locales" to="." method="_on_locales_item_selected"]
[connection signal="tree_exiting" from="menu/tabs/system/GridContainer/locales" to="." method="_on_locales_tree_exiting"]
[connection signal="pressed" from="menu/HBoxContainer/apply" to="." method="_on_apply_pressed"]
[connection signal="pressed" from="menu/HBoxContainer/save" to="." method="_on_save_pressed"]
[editable path="menu"]
[editable path="menu/tabs/game/GridContainer/settings_player"]
[editable path="menu/tabs/controls/settings_controls"]

View File

@ -2,7 +2,6 @@
[ext_resource path="res://scripts/menus/settings_player_menu.gd" type="Script" id=1]
[node name="settings_player_menu" type="Control"]
margin_left = 513.0
margin_top = 23.0

View File

@ -1,47 +1,62 @@
[gd_scene format=2]
[gd_scene load_steps=2 format=2]
[node name="GridContainer" type="GridContainer"]
[ext_resource path="res://scripts/menus/settings_system_menu.gd" type="Script" id=1]
[node name="system_settings_menu" type="Tabs"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
margin_top = 45.0
margin_right = -4.0
margin_bottom = -4.0
focus_neighbour_left = NodePath("../graphics")
focus_mode = 2
script = ExtResource( 1 )
[node name="GridContainer" type="GridContainer" parent="."]
margin_left = 12.0
margin_top = 8.0
margin_right = 907.0
margin_bottom = 124.0
columns = 2
[node name="locale_label" type="Label" parent="."]
[node name="locale_label" type="Label" parent="GridContainer"]
margin_right = 88.0
margin_bottom = 14.0
text = "LOCALE"
valign = 1
[node name="locales" type="ItemList" parent="."]
[node name="locales" type="ItemList" parent="GridContainer"]
margin_left = 92.0
margin_right = 895.0
margin_bottom = 14.0
size_flags_horizontal = 3
auto_height = true
[node name="server_addr_label" type="Label" parent="."]
[node name="server_addr_label" type="Label" parent="GridContainer"]
margin_top = 23.0
margin_right = 88.0
margin_bottom = 37.0
text = "SERVER_ADDR"
valign = 1
[node name="server_addr" type="LineEdit" parent="."]
[node name="server_addr" type="LineEdit" parent="GridContainer"]
margin_left = 92.0
margin_top = 18.0
margin_right = 895.0
margin_bottom = 42.0
[node name="api_addr_label" type="Label" parent="."]
[node name="api_addr_label" type="Label" parent="GridContainer"]
margin_top = 51.0
margin_right = 88.0
margin_bottom = 65.0
text = "API_ADDR"
valign = 1
[node name="api_addr" type="LineEdit" parent="."]
[node name="api_addr" type="LineEdit" parent="GridContainer"]
margin_left = 92.0
margin_top = 46.0
margin_right = 895.0
margin_bottom = 70.0
[connection signal="tree_exiting" from="." to="." method="_on_system_settings_menu_tree_exiting"]
[connection signal="item_selected" from="GridContainer/locales" to="." method="_on_locales_item_selected"]

View File

@ -3,10 +3,13 @@
[ext_resource path="res://scripts/player/bot_controls.gd" type="Script" id=1]
[ext_resource path="res://scripts/player/bot_inventory.gd" type="Script" id=2]
[node name="BotPlayer" type="Spatial"]
script = ExtResource( 1 )
[node name="inventory" type="Spatial" parent="."]
script = ExtResource( 2 )
[node name="rate_timer" type="Timer" parent="."]
wait_time = 0.1
autostart = true
[connection signal="timeout" from="rate_timer" to="." method="_on_rate_timer_timeout"]

View File

@ -1,33 +1,64 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=14 format=2]
[ext_resource path="res://scripts/player/human_controls.gd" type="Script" id=1]
[ext_resource path="res://resources/ui/theme.tres" type="Theme" id=2]
[ext_resource path="res://assets/fonts/Kenney Future Narrow.ttf" type="DynamicFontData" id=3]
[ext_resource path="res://scenes/menus/IngameMenu.tscn" type="PackedScene" id=4]
[ext_resource path="res://scripts/player/human_inventory.gd" type="Script" id=5]
[ext_resource path="res://scenes/road/roadStraightLong.tscn" type="PackedScene" id=6]
[ext_resource path="res://scripts/player/inventory_preview.gd" type="Script" id=7]
[ext_resource path="res://scripts/screen_capture.gd" type="Script" id=2]
[ext_resource path="res://assets/icons/save.png" type="Texture" id=3]
[ext_resource path="res://resources/ui/theme.tres" type="Theme" id=4]
[ext_resource path="res://assets/fonts/Kenney Future Narrow.ttf" type="DynamicFontData" id=5]
[ext_resource path="res://scenes/menus/IngameMenu.tscn" type="PackedScene" id=6]
[ext_resource path="res://scripts/player/human_inventory.gd" type="Script" id=7]
[ext_resource path="res://scenes/road/roadStraightLong.tscn" type="PackedScene" id=8]
[ext_resource path="res://scripts/player/inventory_preview.gd" type="Script" id=9]
[sub_resource type="StyleBoxFlat" id=4]
bg_color = Color( 1, 0, 0, 1 )
[sub_resource type="ViewportTexture" id=1]
viewport_path = NodePath("inventory/viewport")
[sub_resource type="DynamicFont" id=2]
size = 14
font_data = ExtResource( 3 )
font_data = ExtResource( 5 )
[sub_resource type="DynamicFont" id=3]
size = 85
font_data = ExtResource( 3 )
font_data = ExtResource( 5 )
[node name="HumanPlayer" type="Spatial"]
script = ExtResource( 1 )
[node name="hud" type="CanvasLayer" parent="."]
[node name="inventory" type="Control" parent="hud"]
[node name="screen_capture" type="Control" parent="hud"]
anchor_right = 1.0
anchor_bottom = 1.0
theme = ExtResource( 2 )
script = ExtResource( 2 )
[node name="recording" type="ColorRect" parent="hud/screen_capture"]
visible = false
anchor_left = 1.0
anchor_right = 1.0
margin_left = -50.0
margin_bottom = 50.0
color = Color( 1, 0, 0, 1 )
[node name="saving" type="Button" parent="hud/screen_capture"]
visible = false
anchor_left = 1.0
anchor_right = 1.0
margin_left = -50.0
margin_bottom = 50.0
custom_styles/normal = SubResource( 4 )
disabled = true
shortcut_in_tooltip = false
icon = ExtResource( 3 )
flat = true
[node name="inventory" type="Control" parent="hud"]
editor/display_folded = true
anchor_right = 1.0
anchor_bottom = 1.0
theme = ExtResource( 4 )
[node name="track_container" type="Panel" parent="hud/inventory"]
anchor_left = 0.5
@ -72,7 +103,7 @@ margin_top = -39.0
margin_right = 77.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource( 2 )
theme = ExtResource( 4 )
align = 1
valign = 1
@ -92,11 +123,12 @@ align = 1
valign = 1
uppercase = true
[node name="ingame_menu" parent="hud" instance=ExtResource( 4 )]
[node name="ingame_menu" parent="hud" instance=ExtResource( 6 )]
visible = false
[node name="inventory" type="Spatial" parent="."]
script = ExtResource( 5 )
editor/display_folded = true
script = ExtResource( 7 )
[node name="viewport" type="Viewport" parent="inventory"]
size = Vector2( 150, 150 )
@ -114,11 +146,11 @@ far = 20.0
[node name="view" type="Spatial" parent="inventory"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -50, -1000, 0 )
[node name="roadStraightLong" parent="inventory/view" instance=ExtResource( 6 )]
[node name="roadStraightLong" parent="inventory/view" instance=ExtResource( 8 )]
transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0 )
[node name="preview" type="Spatial" parent="inventory"]
script = ExtResource( 7 )
script = ExtResource( 9 )
[node name="camera" type="InterpolatedCamera" parent="."]
fov = 100.0

View File

@ -4,14 +4,13 @@ const FILE_PATH = "user://local_storage"
const RESOLUTIONS = [Vector2(1920,1080),Vector2(1600,900),Vector2(1366,758),Vector2(1280,720),Vector2(1136,640),Vector2(1024,576)]
const CONTROL_ACTIONS = ["controls_thrust", "controls_break", "controls_add_road", "controls_next_road_type", "controls_prev_road_type", "controls_next_road_variant", "controls_prev_road_variant", "controls_reset", "controls_menu"]
const CONTROL_ACTIONS = ["controls_thrust", "controls_break", "controls_add_road", "controls_next_road_type", "controls_prev_road_type", "controls_next_road_variant", "controls_prev_road_variant", "controls_reset", "controls_menu", "controls_capture"]
const INPUT_UI_MAPPING = {"ui_accept" : "controls_add_road", "ui_select" : "controls_add_road", "ui_up" : "controls_next_road_variant", "ui_down" : "controls_prev_road_variant", "ui_left" : "controls_prev_road_type", "ui_right" : "controls_next_road_type"}
var config_file:ConfigFile = ConfigFile.new()
func _ready():
config_file.load(FILE_PATH)

View File

@ -20,10 +20,10 @@ func apply_locale():
func apply_game_server():
var server_addr = config.get_value("game_server", "server_addr")
var server_addr = config.get_value("system", "server_addr")
if server_addr != null && not server_addr.empty():
game_server.set_server_addr(server_addr)
var api_addr = config.get_value("game_server","api_addr")
var api_addr = config.get_value("system","api_addr")
if api_addr != null && not api_addr.empty():
game_server.set_api_addr(api_addr)
@ -39,6 +39,7 @@ func apply_resolution():
get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_2D,SceneTree.STRETCH_ASPECT_EXPAND,base_size,scale)
else:
OS.set_window_size(resolution)
OS.set_window_position(Vector2((OS.get_screen_size().x - resolution.x) / 2, (OS.get_screen_size().y - resolution.y) / 2)) # center screen
get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_VIEWPORT,SceneTree.STRETCH_ASPECT_IGNORE,OS.get_window_size(),1)

View File

@ -16,7 +16,8 @@ func _ready():
if find_node("sun").is_visible_in_tree():
find_node("sun").set_shadow(config.get_value("graphics","shadows", false))
if is_network_master():
route.rpc("add_road",roads_factory.START, -1)
route.set_road(roads_factory.START, -1)
route.rpc("set_road",roads_factory.START, -1)
func _physics_process(delta):
@ -25,6 +26,16 @@ func _physics_process(delta):
check_autotrack()
func get_player(player_id:String):
if get_node("players") != null && get_node("players").has_node(player_id):
return get_node("players").get_node(player_id)
return null
func get_player_by_network_id(network_id:int):
return get_player(str(network_id))
func set_player_order():
players = get_node("players").get_children()
players.sort_custom(PlayerSorter,"sort")
@ -45,7 +56,8 @@ func check_autotrack():
if first != null:
if first.position.x != -1 && route.get_last_road() != null:
if first.position.x == route.get_last_road().get_index():
route.rpc("add_road", roads_factory.STRAIGHT, -1)
route.set_road(roads_factory.STRAIGHT, -1)
route.rpc("set_road", roads_factory.STRAIGHT, -1)
class PlayerSorter:

View File

@ -3,6 +3,8 @@ extends Node
const MAX_PEERS = 4
const LOBBY_READY_WAIT_TIME = 3
const DEFAULT_BOT_DIFFICULTY = 0.5
var Game = preload("res://scenes/game/Game.tscn")
var Player = preload("res://scenes/player/Player.tscn")
var HumanPlayer = preload("res://scenes/player/HumanPlayer.tscn")
@ -13,6 +15,7 @@ var players = {}
var game_name = ""
var bots:bool = false
var bot_difficulty:float = DEFAULT_BOT_DIFFICULTY
var game_running:bool = false
signal players_changed(players)
@ -74,7 +77,7 @@ remotesync func prepare_game():
var player = players[p_id]
var player_scene = Player.instance()
player_scene.set_network_master(p_id)
# player_scene.set_network_master(p_id)
player_scene.set_name(str(p_id))
game.get_node("players").add_child(player_scene)
player_scene.set_player_name(player.name)
@ -96,13 +99,14 @@ remotesync func prepare_game():
player_scene.set_name("bot_player" + str(bot_index))
game.get_node("players").add_child(player_scene)
player_scene.set_player_name("Bot " + str(bot_index))
player_scene.set_player_color(Color(randf(),randf(),randf()))
player_scene.set_player_color(Color(util.randf(),util.randf(),util.randf()))
player_scene.add_to_group("bots")
if get_tree().is_network_server():
var bot = BotPlayer.instance()
bot.set_name("bot" + str(bot_index))
game.add_child(bot)
bot.set_player(player_scene.get_path())
bot.set_difficulty(bot_difficulty)
bot.set_network_master(get_tree().get_network_unique_id())
player_scene.set_start(bot_index)
if players.has(get_tree().get_network_unique_id()):
@ -134,6 +138,11 @@ remotesync func set_bots(has_bots:bool):
bots = has_bots
remotesync func set_bot_difficulty(new_bot_difficulty:float):
if new_bot_difficulty >= 0 && new_bot_difficulty <= 1:
bot_difficulty = new_bot_difficulty
func quit_game():
if game != null:
game.queue_free()

View File

@ -14,13 +14,24 @@ func get_last_road():
func get_road(road_index):
if get_child_count() > road_index:
if road_index >= 0 && get_child_count() > road_index:
return get_child(road_index)
else:
return null
remotesync func add_road(type, creator):
master func add_road(type):
if is_network_master():
var sender_id = get_tree().get_rpc_sender_id()
if sender_id == 0:
sender_id = 1
var creator = gamestate.game.get_player_by_network_id(sender_id)
if creator != null && creator.is_in_group("first"):
set_road(type,creator.get_name())
rpc("set_road", type, creator.get_name())
puppet func set_road(type, creator):
var transform = get_global_transform()
var last_road = get_last_road()
if last_road != null:
@ -35,8 +46,7 @@ remotesync func add_road(type, creator):
new_road.set_preview(false)
new_road.set_creator(creator)
if creator > 0:
var player = gamestate.game.get_node(str(creator))
var player = gamestate.game.get_player(str(creator))
if player != null:
new_road.set_color(player.get_player_color())

View File

@ -5,6 +5,9 @@ var LobbyMenu = preload("res://scenes/menus/LobbyMenu.tscn")
func _ready():
find_node("bots").set_pressed(config.get_value("game","bots", true))
find_node("bot_difficulty").set_value(config.get_value("game","bot_difficulty", gamestate.DEFAULT_BOT_DIFFICULTY))
find_node("bot_difficulty").set_editable(find_node("bots").is_pressed())
find_node("bot_difficulty").set_tooltip(tr("BOT_DIFFICULTY"))
func _draw():
@ -14,7 +17,8 @@ func _draw():
func _on_host_pressed():
var port = find_node("port").get_value()
var bots = find_node("bots").is_pressed()
var err = server.host_game(int(port), bots)
var bot_difficulty = find_node("bot_difficulty").get_value()
var err = server.host_game(int(port), bots, bot_difficulty)
if err == OK:
var lobby_menu = LobbyMenu.instance()
@ -31,3 +35,7 @@ func _on_host_pressed():
func _on_back_pressed():
queue_free()
get_tree().get_root().get_node("multiplayer_menu").show()
func _on_bots_toggled(button_pressed):
find_node("bot_difficulty").set_editable(button_pressed)

View File

@ -1,5 +1,7 @@
extends Control
var SettingsMenu = preload("res://scenes/menus/SettingsMenu.tscn")
func _draw():
find_node("resume").grab_focus()
@ -10,7 +12,9 @@ func _on_resume_pressed():
func _on_settings_pressed():
pass
var settings_menu = SettingsMenu.instance()
get_parent().add_child(settings_menu)
hide()
func _on_end_pressed():

View File

@ -33,7 +33,7 @@ func _draw():
find_node("ready").grab_focus()
func _physics_process(delta):
func _process(delta):
if not countdown_timer.is_stopped():
get_node("countdown").text = str(int(countdown_timer.get_time_left()) + 1)

View File

@ -5,6 +5,9 @@ onready var player_settings = find_node("player_settings")
func _ready():
find_node("bots").set_pressed(config.get_value("game","bots", true))
find_node("bot_difficulty").set_value(config.get_value("game","bot_difficulty", gamestate.DEFAULT_BOT_DIFFICULTY))
find_node("bot_difficulty").set_editable(find_node("bots").is_pressed())
find_node("bot_difficulty").set_tooltip(tr("BOT_DIFFICULTY"))
func _draw():
@ -15,10 +18,15 @@ func _on_start_pressed():
var name = player_settings.get_name_node().text
var color = player_settings.get_color_node().color
var bots = find_node("bots").is_pressed()
var bot_difficulty = find_node("bot_difficulty").get_value()
queue_free()
server.local_game(name,color,bots)
server.local_game(name,color,bots,bot_difficulty)
func _on_back_pressed():
queue_free()
get_tree().get_root().get_node("main_menu").show()
func _on_bots_toggled(button_pressed):
find_node("bot_difficulty").set_editable(button_pressed)

View File

@ -43,3 +43,8 @@ func show_error_dialog(text:String):
var dialog = get_node("error_dialog")
dialog.set_text(text)
dialog.popup_centered()
func _on_info_pressed():
var dialog = get_node("info_popup")
dialog.popup_centered()

View File

@ -8,6 +8,9 @@ func _ready():
game_title += " by " + player_name
find_node("name").set_text(game_title)
find_node("bots").set_pressed(config.get_value("game","bots", true))
find_node("bot_difficulty").set_value(config.get_value("game","bot_difficulty", gamestate.DEFAULT_BOT_DIFFICULTY))
find_node("bot_difficulty").set_editable(find_node("bots").is_pressed())
find_node("bot_difficulty").set_tooltip(tr("BOT_DIFFICULTY"))
func _draw():
@ -21,7 +24,8 @@ func _on_create_pressed():
var bots = 0
if find_node("bots").is_pressed():
bots = 1
req.post_request('client/game/create', to_json({'name' : server_name, 'bots' : bots}))
var bot_difficulty = find_node("bot_difficulty").get_value()
req.post_request('client/game/create', to_json({'name' : server_name, 'bots' : bots, 'bot_difficulty' : bot_difficulty}))
func _on_game_created(result, response_code, headers, body):
@ -44,3 +48,7 @@ func _on_name_text_changed(new_text):
func _on_back_pressed():
queue_free()
get_tree().get_root().get_node("multiplayer_menu").show()
func _on_bots_toggled(button_pressed):
find_node("bot_difficulty").set_editable(button_pressed)

View File

@ -16,6 +16,10 @@ func _ready():
init_mapping()
func apply():
config.set_value("controls","mapping",new_inputs)
func init_mapping():
new_inputs = {}
for action in config.CONTROL_ACTIONS:

View File

@ -0,0 +1,17 @@
extends Tabs
onready var player_settings = find_node("settings_player")
func _ready():
# game
find_node("bots").set_pressed(config.get_value("game","bots", true))
find_node("bot_difficulty").set_value(config.get_value("game","bot_difficulty", gamestate.DEFAULT_BOT_DIFFICULTY))
find_node("bot_difficulty").set_tooltip(tr("BOT_DIFFICULTY"))
func apply():
config.set_value("game","player_name",player_settings.get_name_node().get_text())
config.set_value("game","player_color",player_settings.get_color_node().color)
config.set_value("game","bots",find_node("bots").is_pressed())
config.set_value("game","bot_difficulty",find_node("bot_difficulty").get_value())

View File

@ -0,0 +1,24 @@
extends Tabs
func _ready():
find_node("fullscreen").set_pressed(config.get_value("graphics","fullscreen", true))
find_node("light").set_pressed(config.get_value("graphics","light", false))
find_node("shadows").set_pressed(config.get_value("graphics","shadows", false))
find_node("shadows").set_disabled(not find_node("light").is_pressed())
for resolution in config.RESOLUTIONS:
find_node("resolution").add_item(str(resolution.x) + " * " + str(resolution.y))
find_node("resolution").select(config.RESOLUTIONS.find(config.get_value("graphics","resolution", config.RESOLUTIONS[0])))
func apply():
config.set_value("graphics","resolution",config.RESOLUTIONS[find_node("resolution").get_selected()])
config.set_value("graphics","fullscreen",find_node("fullscreen").is_pressed())
config.set_value("graphics","light",find_node("light").is_pressed())
config.set_value("graphics","shadows",find_node("shadows").is_pressed())
func _on_light_toggled(button_pressed):
find_node("shadows").set_disabled(not button_pressed)

View File

@ -1,35 +1,14 @@
extends Control
onready var player_settings = find_node("settings_player")
onready var game_tab = find_node("game")
onready var controls_tab = find_node("controls")
onready var graphics_tab = find_node("graphics")
onready var system_tab = find_node("system")
var locale
func _ready():
get_node("menu/back").connect("pressed",self,"_on_back_pressed")
# game
find_node("bots").set_pressed(config.get_value("game","bots", true))
# graphics
find_node("fullscreen").set_pressed(config.get_value("graphics","fullscreen", true))
find_node("light").set_pressed(config.get_value("graphics","light", false))
find_node("shadows").set_pressed(config.get_value("graphics","shadows", false))
find_node("shadows").set_disabled(not find_node("light").is_pressed())
for resolution in config.RESOLUTIONS:
find_node("resolution").add_item(str(resolution.x) + " * " + str(resolution.y))
find_node("resolution").select(config.RESOLUTIONS.find(config.get_value("graphics","resolution", config.RESOLUTIONS[0])))
# system
find_node("server_addr").set_text(game_server.get_server_addr())
find_node("api_addr").set_text(game_server.get_api_addr())
_init_locales()
system_tab.connect("locale_changed", self, "on_locale_changed")
func _draw():
@ -38,79 +17,30 @@ func _draw():
func _on_back_pressed():
queue_free()
if get_parent().has_node("ingame_menu"):
get_parent().get_node("ingame_menu").show()
get_tree().get_root().get_node("main_menu").hide()
elif get_tree().get_root().has_node("main_menu"):
get_tree().get_root().get_node("main_menu").show()
func _on_locales_item_selected(index):
match index:
0:
locale = "en"
1:
locale = "de"
_:
locale = "en"
TranslationServer.set_locale(locale)
func on_locale_changed():
game_tab.set_name(tr("GAME"))
controls_tab.set_name(tr("CONTROLS"))
graphics_tab.set_name(tr("GRAPHICS"))
system_tab.set_name(tr("SYSTEM"))
func _init_locales():
var locales = find_node("locales")
locales.clear()
locales.add_item(tr("LOCALE_EN"))
locales.add_item(tr("LOCALE_DE"))
locale = config.get_value("system","locale","en")
match locale:
"en":
locales.select(0)
_on_locales_item_selected(0)
"de":
locales.select(1)
_on_locales_item_selected(1)
func _on_locales_tree_exiting():
config_apply.apply_locale()
func _on_save_pressed():
_on_apply_pressed()
_on_back_pressed()
func _on_apply_pressed():
# game
config.set_value("game","player_name",player_settings.get_name_node().get_text())
config.set_value("game","player_color",player_settings.get_color_node().color)
config.set_value("game","bots",find_node("bots").is_pressed())
# graphics
config.set_value("graphics","resolution",config.RESOLUTIONS[find_node("resolution").get_selected()])
config.set_value("graphics","fullscreen",find_node("fullscreen").is_pressed())
config.set_value("graphics","light",find_node("light").is_pressed())
config.set_value("graphics","shadows",find_node("shadows").is_pressed())
# controls
config.set_value("controls","mapping",find_node("settings_controls").new_inputs)
# system
config.set_value("system","locale",locale)
var server_addr = find_node("server_addr").get_text()
if server_addr.empty():
server_addr = game_server.SERVER_ADDR
config.set_value("system","server_addr",server_addr)
var api_addr = find_node("api_addr").get_text()
if api_addr.empty():
api_addr = game_server.API_ADDR
config.set_value("system","api_addr",api_addr)
game_tab.apply()
graphics_tab.apply()
controls_tab.apply()
system_tab.apply()
config.save()
config_apply.apply_settings()
func _on_light_toggled(button_pressed):
find_node("shadows").set_disabled(not button_pressed)

View File

@ -0,0 +1,55 @@
extends Tabs
var locale
signal locale_changed()
func _ready():
find_node("server_addr").set_text(game_server.get_server_addr())
find_node("api_addr").set_text(game_server.get_api_addr())
_init_locales()
func apply():
config.set_value("system","locale",locale)
var server_addr = find_node("server_addr").get_text()
if server_addr.empty():
server_addr = game_server.SERVER_ADDR
config.set_value("system","server_addr",server_addr)
var api_addr = find_node("api_addr").get_text()
if api_addr.empty():
api_addr = game_server.API_ADDR
config.set_value("system","api_addr",api_addr)
func _on_locales_item_selected(index):
match index:
0:
locale = "en"
1:
locale = "de"
_:
locale = "en"
TranslationServer.set_locale(locale)
emit_signal("locale_changed")
func _init_locales():
var locales = find_node("locales")
locales.clear()
locales.add_item(tr("LOCALE_EN"))
locales.add_item(tr("LOCALE_DE"))
locale = config.get_value("system","locale","en")
match locale:
"en":
locales.select(0)
_on_locales_item_selected(0)
"de":
locales.select(1)
_on_locales_item_selected(1)
func _on_system_settings_menu_tree_exiting():
config_apply.apply_locale()

View File

@ -26,6 +26,8 @@ func _ready():
server_secret=argument.split("=")[1]
if argument.split("=")[0] == "--bots":
gamestate.set_bots(bool(int(argument.split("=")[1])))
if argument.split("=")[0] == "--bot-difficulty":
gamestate.set_bot_difficulty(float(argument.split("=")[1]))
if argument.split("=")[0] == "--server-addr":
game_server.set_server_addr(str(argument.split("=")[1]))
if argument.split("=")[0] == "--api-addr":
@ -44,7 +46,7 @@ func _ready():
quit_server()
func host_game(port:int, set_bots:bool = false):
func host_game(port:int, set_bots:bool = false, bot_difficulty:float = gamestate.DEFAULT_BOT_DIFFICULTY):
var host = NetworkedMultiplayerENet.new()
var err = host.create_server(port, MAX_PEERS)
get_tree().set_network_peer(host)
@ -59,6 +61,9 @@ func host_game(port:int, set_bots:bool = false):
if set_bots:
gamestate.bots = true
if set_bots && bot_difficulty != gamestate.DEFAULT_BOT_DIFFICULTY:
gamestate.bot_difficulty = bot_difficulty
if timer == null:
timer = Timer.new()
timer.set_name("timer")
@ -73,11 +78,12 @@ func host_game(port:int, set_bots:bool = false):
return err
func local_game(name:String, color:Color, bots:bool):
func local_game(name:String, color:Color, bots:bool, bot_difficulty:float):
var localhost = NetworkedMultiplayerENet.new()
localhost.create_server(0, 0)
get_tree().set_network_peer(localhost)
gamestate.bots = bots
gamestate.bot_difficulty = bot_difficulty
gamestate.set_player(get_tree().get_network_unique_id(), name, color)
gamestate.prepare_game()
gamestate.post_start_game()
@ -96,6 +102,7 @@ func _client_connected(id):
if dedicated_server:
print(server_id + "peer connected: " + str(id))
gamestate.rpc_id(id, "set_bots" ,gamestate.bots)
gamestate.rpc_id(id, "bot_difficulty" ,gamestate.bot_difficulty)
if not timer.is_stopped():
timer.disconnect("timeout",self,"quit_server")
timer.stop()

View File

@ -1,52 +1,62 @@
extends Spatial
class_name BotPlayer
var player:Player
const MAX_OFFSET = 8.0
const OFFSET_STEPS = 0.01
const OFFSET_STEPS = 0.1
const PRE_BREAK_DISTANCE = 3.0
var break_constrain = 0.0
var break_distance = 0.0
var thrust_distance = 0.0
export var overspeed_rate:float = 0.3
export var underspeed_rate:float = 0.1
export var difficulty:float = 0.0
var rate = 0.0
func _physics_process(delta):
func _process(delta):
if is_network_master() && player != null:
if player.is_out:
if player.is_out():
if player.is_resetable:
player.reset()
else:
if player.get_road() != null:
var road = player.get_road()
var rate = util.randf()
var speed = player.current_speed
var offset = 0
var distance = player.follow.get_offset()
var tmp_break_constrain = 0.0
var distance = player.follow.get_offset() - OFFSET_STEPS
var tmp_constrain = 0.0
break_constrain = 0.0
break_distance = 0.0
thrust_distance = 0.0
while tmp_break_constrain == 0.0 and offset < MAX_OFFSET && road != null:
while offset <= MAX_OFFSET && road != null:
var constrain_index = road.get_constrain_index(distance)
var road_length = road.get_lane_curve(player.lane).get_baked_length()
if constrain_index >= 0:
tmp_break_constrain = road.speed_constrains[constrain_index].z
if tmp_break_constrain > break_constrain:
break_constrain = tmp_break_constrain
tmp_constrain = road.speed_constrains[constrain_index].z
if tmp_constrain > 0 && (break_constrain == 0.0 || tmp_constrain < break_constrain):
break_constrain = tmp_constrain
if break_distance == 0:
break_distance = offset
if tmp_constrain < 0 && thrust_distance == 0:
thrust_distance = offset
distance += OFFSET_STEPS
offset += OFFSET_STEPS
if distance >= road_length:
if distance >= road_length && gamestate.game != null:
distance = 0
road = gamestate.game.route.get_road(road.get_index()+1)
if break_constrain > 0 && speed > break_constrain - 0.04 && rate > overspeed_rate:
if break_constrain > 0 && speed > break_constrain - 0.005 && break_distance < thrust_distance + PRE_BREAK_DISTANCE && rate < difficulty:
player.thrust = -1
elif speed - 0.08 < break_constrain && rate > underspeed_rate:
elif speed - 0.01 < break_constrain:
player.thrust = 1
elif break_constrain == 0 && rate > underspeed_rate:
elif break_constrain == 0.0 && rate < difficulty || speed < 0.02:
player.thrust = 1
else:
player.thrust = 0
@ -57,9 +67,9 @@ func set_player(path:String):
get_node("inventory").set_player(player)
func set_overspeed_rate(new_overspeed_rate:float):
overspeed_rate = new_overspeed_rate
func set_difficulty(new_difficulty:float):
difficulty = new_difficulty
func set_underspeed_rate(new_underspeed_rate:float):
underspeed_rate = new_underspeed_rate
func _on_rate_timer_timeout():
rate = util.randf()

View File

@ -14,7 +14,8 @@ func _on_raceCar_road_entered(road):
if route.get_last_road().get_index() <= (road.get_index() +2):
type = rand.randi_range(0,roads.size() -2) # TODO: remove special, loop need fixes!
index = rand.randi_range(0, roads[type].size() -1)
route.rpc("add_road", roads[type][index], player.get_index())
route.set_road(roads[type][index], -1)
route.rpc("set_road", roads[type][index], -1)
func set_player(new_player:Player):

View File

@ -5,27 +5,27 @@ onready var camera:InterpolatedCamera = get_node("camera")
onready var ingame_menu:Spatial = find_node("ingame_menu")
func _physics_process(delta):
func _process(delta):
if is_network_master() && player != null:
if Input.is_action_just_pressed("controls_menu"):
ingame_menu.set_visible(not ingame_menu.is_visible_in_tree())
if player.is_out:
if player.is_out():
camera.set_speed(0.1)
if player.timer.get_time_left() > 0:
get_node("hud/reset").set_text(str(int(player.timer.get_time_left()) + 1))
else:
get_node("hud/reset").set_text(tr("RESET"))
if Input.is_action_pressed("controls_reset"):
if player.reset():
player.rpc("reset")
elif not ingame_menu.is_visible_in_tree():
camera.set_speed(10)
get_node("hud/reset").set_text("")
elif not ingame_menu.is_visible_in_tree():
if Input.is_action_pressed("controls_thrust"):
player.thrust = 1
player.rpc_unreliable("set_thrust",1)
elif Input.is_action_pressed("controls_break"):
player.thrust = -1
player.rpc_unreliable("set_thrust",-1)
else:
player.thrust = 0
player.rpc_unreliable("set_thrust",0)
get_node("hud/speed_slider").set_value(player.current_speed * 1000)

View File

@ -13,17 +13,17 @@ func _ready():
connect("item_changed",preview,"_on_inventory_item_changed")
func _physics_process(delta):
func _process(delta):
if is_network_master():
if player != null:
if not player.is_out && player.is_in_group("first"):
if not player.is_out() && player.is_in_group("first"):
get_node("../hud/inventory").show()
if item == null:
set_item()
if preview.item:
preview.item.show()
if Input.is_action_just_pressed("controls_add_road"):
route.rpc("add_road", roads[type][index], player.get_index())
route.rpc("add_road", roads[type][index])
if Input.is_action_just_pressed("controls_prev_road_type"):
type -= 1
if type < 0:

View File

@ -11,7 +11,7 @@ func _ready():
func _on_route_road_added(road):
if is_network_master() && item:
if is_network_master() && item && road:
var transform = road.get_global_transform();
var curve = road.get_curve()
transform = transform.translated(curve.get_point_position(curve.get_point_count() -1))

View File

@ -109,9 +109,7 @@ func _physics_process(delta):
torque_penalty = road.get_torque_penalty(penalty_index)
force_penalty = road.get_force_penalty(penalty_index)
path_penalty = road.get_path_penalty(penalty_index)
is_out = true
is_resetable = false
timer.start()
rpc("set_out")
check_position()
else:
@ -173,7 +171,23 @@ func set_player_color(new_color):
race_car.get_node("body").set_surface_material(1,material)
func is_out():
return is_out
remotesync func set_out():
is_out = true
is_resetable = false
timer.start()
remotesync func set_in():
is_out = false
is_resetable = false
remotesync func set_first(is_first:bool):
if get_tree().get_rpc_sender_id() == 0 || get_tree().get_rpc_sender_id() == get_network_master():
if is_first:
add_to_group("first")
else:
@ -185,16 +199,24 @@ master func check_position():
rset("slave_position", position)
master func set_thrust(new_thrust:int):
var sender_id = get_tree().get_rpc_sender_id()
if is_network_master() || gamestate.game.get_player_by_network_id(sender_id) == self && [-1,0,1].has(new_thrust):
thrust = new_thrust
master func reset():
if is_resetable:
var sender_id = get_tree().get_rpc_sender_id()
if (is_network_master() || gamestate.game.get_player_by_network_id(sender_id) == self) && is_resetable:
has_next = false
current_speed = 0
var road = race_car.road
road.body.set_collision_layer_bit(get_index(),1)
while road.reset_index != 0:
road = route.get_road(road.get_index() - road.reset_index)
var reset_index = road.reset_index
for i in range(reset_index):
road = route.get_road(road.get_index() - 1)
road.body.set_collision_layer_bit(get_index(),1)
path.curve.clear_points()
@ -213,11 +235,7 @@ master func reset():
follow.set_transform(road.get_transform())
is_out = false
is_resetable = false
return true
else:
return false
rpc("set_in")
func set_start(new_lane:int):

53
scripts/screen_capture.gd Normal file
View File

@ -0,0 +1,53 @@
extends Node
export(float) var frames_per_second = 5.0
var is_active:bool = false
var is_saving:bool = false
var _frametick = 1.0/frames_per_second
var _thread:Thread
var images = []
func _ready():
_thread = Thread.new()
func _process(delta):
if Input.is_action_just_pressed("controls_capture") && not is_saving:
is_active = not is_active
find_node("recording").set_visible(is_active)
if not is_active:
is_saving = true
find_node("saving").set_visible(true)
_thread.start(self, "save_images")
if is_active:
_frametick += delta
if (_frametick > 1.0/frames_per_second):
get_viewport().set_clear_mode(Viewport.CLEAR_MODE_ONLY_NEXT_FRAME)
var img = get_viewport().get_texture().get_data()
img.flip_y()
images.append(img)
func save_images(userdata):
var dir = Directory.new()
var timestamp = OS.get_unix_time()
if dir.open("user://capture/") != OK:
dir.open("user://")
dir.make_dir("capture")
dir.open("user://capture/")
dir.make_dir(str(timestamp))
for img in images:
img.save_png("user://capture/" + str(timestamp) + "/" + str(img) + ".png")
images = []
is_saving = false
find_node("saving").set_visible(false)
if(_thread.is_active()):
_thread.wait_to_finish()