Browse Source

improvements, server update

Lurkars 6 years ago
parent
commit
21797ec0b5
  1. 6
      ext/server.py
  2. 12
      scenes/menus/BaseMenu.tscn
  3. 24
      scenes/player/HumanPlayer.tscn
  4. 2
      scenes/road/roadRampFlipped.tscn
  5. 2
      scenes/road/roadRampLongFlipped.tscn
  6. 18
      scripts/player/base_inventory.gd
  7. 6
      scripts/player/human_controls.gd
  8. 4
      scripts/player/human_inventory.gd
  9. 2
      scripts/player/player.gd

6
ext/server.py

@ -5,6 +5,7 @@ import secrets
from flask import Flask, abort, request, jsonify from flask import Flask, abort, request, jsonify
START_PORT = 8128 START_PORT = 8128
MAX_GAMES = 10
GAME_EXEC = 'godot_server' GAME_EXEC = 'godot_server'
GAME_EXEC_ARG_PACK = '--main-pack' GAME_EXEC_ARG_PACK = '--main-pack'
GAME_EXEC_ARG_PACK_PATH = '/opt/godot/MUR.pck' GAME_EXEC_ARG_PACK_PATH = '/opt/godot/MUR.pck'
@ -49,14 +50,19 @@ def create_game():
with sqlite3.connect("database.db") as con: with sqlite3.connect("database.db") as con:
# check free port # check free port
port = START_PORT port = START_PORT
game_count = 0
cur = con.cursor() cur = con.cursor()
cur.execute("SELECT * FROM games WHERE port=?", (port,)) cur.execute("SELECT * FROM games WHERE port=?", (port,))
rows = cur.fetchall() rows = cur.fetchall()
while rows: while rows:
port += 1 port += 1
game_count += 1
cur.execute("SELECT * FROM games WHERE port=?", (port,)) cur.execute("SELECT * FROM games WHERE port=?", (port,))
rows = cur.fetchall() rows = cur.fetchall()
if game_count == MAX_GAMES:
abort(401)
# check duplicate name # check duplicate name
base_name = name base_name = name
base_name_count = 1 base_name_count = 1

12
scenes/menus/BaseMenu.tscn

@ -1,7 +1,8 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=4 format=2]
[ext_resource path="res://resources/ui/font.tres" type="DynamicFont" id=1]
[ext_resource path="res://assets/icons/return.png" type="Texture" id=2]
[ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1]
[ext_resource path="res://resources/ui/font.tres" type="DynamicFont" id=2]
[ext_resource path="res://assets/icons/return.png" type="Texture" id=3]
[node name="menu" type="Panel"] [node name="menu" type="Panel"]
anchor_left = 0.5 anchor_left = 0.5
@ -17,6 +18,7 @@ grow_vertical = 2
rect_clip_content = true rect_clip_content = true
size_flags_horizontal = 6 size_flags_horizontal = 6
size_flags_vertical = 6 size_flags_vertical = 6
theme = ExtResource( 1 )
[node name="back" type="Button" parent="."] [node name="back" type="Button" parent="."]
anchor_top = 1.0 anchor_top = 1.0
@ -25,8 +27,8 @@ margin_top = -56.0
margin_right = 132.0 margin_right = 132.0
size_flags_horizontal = 6 size_flags_horizontal = 6
size_flags_vertical = 6 size_flags_vertical = 6
custom_fonts/font = ExtResource( 1 )
custom_fonts/font = ExtResource( 2 )
text = "BACK" text = "BACK"
icon = ExtResource( 2 )
icon = ExtResource( 3 )
flat = true flat = true
align = 0 align = 0

24
scenes/player/HumanPlayer.tscn

@ -1,8 +1,8 @@
[gd_scene load_steps=11 format=2] [gd_scene load_steps=11 format=2]
[ext_resource path="res://scripts/player/human_controls.gd" type="Script" id=1] [ext_resource path="res://scripts/player/human_controls.gd" type="Script" id=1]
[ext_resource path="res://assets/fonts/Kenney Future Narrow.ttf" type="DynamicFontData" id=2]
[ext_resource path="res://resources/ui/theme.tres" type="Theme" id=3]
[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://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://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://scenes/road/roadStraightLong.tscn" type="PackedScene" id=6]
@ -13,11 +13,11 @@ viewport_path = NodePath("inventory/viewport")
[sub_resource type="DynamicFont" id=2] [sub_resource type="DynamicFont" id=2]
size = 14 size = 14
font_data = ExtResource( 2 )
font_data = ExtResource( 3 )
[sub_resource type="DynamicFont" id=3] [sub_resource type="DynamicFont" id=3]
size = 85 size = 85
font_data = ExtResource( 2 )
font_data = ExtResource( 3 )
[node name="HumanPlayer" type="Spatial"] [node name="HumanPlayer" type="Spatial"]
script = ExtResource( 1 ) script = ExtResource( 1 )
@ -27,15 +27,16 @@ script = ExtResource( 1 )
[node name="inventory" type="Control" parent="hud"] [node name="inventory" type="Control" parent="hud"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
theme = ExtResource( 2 )
[node name="background" type="ColorRect" parent="hud/inventory"]
[node name="track_container" type="Panel" parent="hud/inventory"]
anchor_left = 0.5 anchor_left = 0.5
anchor_right = 0.5 anchor_right = 0.5
margin_left = -75.0 margin_left = -75.0
margin_right = 75.0 margin_right = 75.0
margin_bottom = 150.0 margin_bottom = 150.0
[node name="track" type="TextureRect" parent="hud/inventory"]
[node name="track" type="TextureRect" parent="hud/inventory/track_container"]
anchor_left = 0.5 anchor_left = 0.5
anchor_right = 0.5 anchor_right = 0.5
margin_left = -75.0 margin_left = -75.0
@ -43,7 +44,7 @@ margin_right = 75.0
margin_bottom = 150.0 margin_bottom = 150.0
texture = SubResource( 1 ) texture = SubResource( 1 )
[node name="type" type="Label" parent="hud/inventory"]
[node name="type" type="Label" parent="hud/inventory/track_container"]
anchor_left = 0.5 anchor_left = 0.5
anchor_right = 0.5 anchor_right = 0.5
margin_left = -74.0 margin_left = -74.0
@ -52,10 +53,15 @@ margin_bottom = 58.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
custom_fonts/font = SubResource( 2 ) custom_fonts/font = SubResource( 2 )
custom_colors/font_color = Color( 0, 0, 0, 1 )
align = 1 align = 1
valign = 1 valign = 1
[node name="speed_slider" type="VSlider" parent="hud"]
anchor_bottom = 1.0
margin_right = 16.0
max_value = 250.0
step = 0.5
[node name="speed" type="Label" parent="hud"] [node name="speed" type="Label" parent="hud"]
anchor_left = 0.5 anchor_left = 0.5
anchor_top = 1.0 anchor_top = 1.0
@ -66,7 +72,7 @@ margin_top = -39.0
margin_right = 77.0 margin_right = 77.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
theme = ExtResource( 3 )
theme = ExtResource( 2 )
align = 1 align = 1
valign = 1 valign = 1

2
scenes/road/roadRampFlipped.tscn

@ -10,7 +10,7 @@ material/0 = null
material/1 = null material/1 = null
material/2 = null material/2 = null
script = ExtResource( 2 ) script = ExtResource( 2 )
speed_constrains = PoolVector3Array( 0, 0.3, 0.12 )
speed_constrains = PoolVector3Array( 0, 0.1, 0.12 )
force_penalties = PoolVector3Array( 0, 0, 4 ) force_penalties = PoolVector3Array( 0, 0, 4 )
[node name="Path" type="Path" parent="."] [node name="Path" type="Path" parent="."]

2
scenes/road/roadRampLongFlipped.tscn

@ -10,7 +10,7 @@ material/0 = null
material/1 = null material/1 = null
material/2 = null material/2 = null
script = ExtResource( 2 ) script = ExtResource( 2 )
speed_constrains = PoolVector3Array( 0, 0.1, 0.12 )
speed_constrains = PoolVector3Array( 0, 0.3, 0.12 )
force_penalties = PoolVector3Array( 0, 0, 4 ) force_penalties = PoolVector3Array( 0, 0, 4 )
[node name="Path" type="Path" parent="."] [node name="Path" type="Path" parent="."]

18
scripts/player/base_inventory.gd

@ -9,14 +9,6 @@ var road_straights = [
roads_factory.STRAIGHT_SMALL, roads_factory.STRAIGHT_SMALL,
] ]
var roads_left = [
roads_factory.CURVE_LEFT,
roads_factory.CURVE_LARGE_LEFT,
roads_factory.CURVE_SMALL_LEFT,
roads_factory.SKEW_LEFT,
roads_factory.CURVED_LEFT,
]
var roads_right = [ var roads_right = [
roads_factory.CURVE_RIGHT, roads_factory.CURVE_RIGHT,
roads_factory.CURVE_LARGE_RIGHT, roads_factory.CURVE_LARGE_RIGHT,
@ -25,6 +17,14 @@ var roads_right = [
roads_factory.CURVED_RIGHT, roads_factory.CURVED_RIGHT,
] ]
var roads_left = [
roads_factory.CURVE_LEFT,
roads_factory.CURVE_LARGE_LEFT,
roads_factory.CURVE_SMALL_LEFT,
roads_factory.SKEW_LEFT,
roads_factory.CURVED_LEFT,
]
var roads_up = [ var roads_up = [
roads_factory.RAMP_UP, roads_factory.RAMP_UP,
roads_factory.RAMP_CURVED_UP, roads_factory.RAMP_CURVED_UP,
@ -41,7 +41,7 @@ var roads_special = [
roads_factory.LOOP, roads_factory.LOOP,
] ]
var roads = [ road_straights, roads_left, roads_right, roads_up, roads_down, roads_special ]
var roads = [ road_straights, roads_right, roads_left, roads_up, roads_down, roads_special ]
var player:Player var player:Player
var route:Route var route:Route

6
scripts/player/human_controls.gd

@ -24,7 +24,7 @@ func _physics_process(delta):
else: else:
player.thrust = 0 player.thrust = 0
get_node("hud/speed").set_text(str(player.current_speed))
get_node("hud/speed_slider").set_value(player.current_speed * 1000)
if Input.is_action_pressed("debug_camera_1"): if Input.is_action_pressed("debug_camera_1"):
set_debug_camera(0) set_debug_camera(0)
@ -45,5 +45,5 @@ func set_player(path:String):
func set_debug_camera(idx): func set_debug_camera(idx):
if idx < gamestate.game.players.get_child_count():
camera.set_target_path(gamestate.game.players.get_child(idx).find_node("CameraTarget").get_path())
if idx < gamestate.game.get_node("players").get_child_count():
camera.set_target_path(gamestate.game.get_node("players").get_child(idx).find_node("CameraTarget").get_path())

4
scripts/player/human_inventory.gd

@ -7,7 +7,7 @@ var preview:Spatial
func _ready(): func _ready():
view = get_node("view") view = get_node("view")
preview = get_node("preview") preview = get_node("preview")
var hud_track = get_node("../hud/inventory/track")
var hud_track = get_node("../hud/inventory/track_container/track")
hud_track.get_texture().set_viewport_path_in_scene(str(get_path()) + "/viewport") hud_track.get_texture().set_viewport_path_in_scene(str(get_path()) + "/viewport")
connect("item_changed",self,"_on_item_changed") connect("item_changed",self,"_on_item_changed")
connect("item_changed",preview,"_on_inventory_item_changed") connect("item_changed",preview,"_on_inventory_item_changed")
@ -59,4 +59,4 @@ func _on_item_changed(road_identifier, player):
view.add_child(item) view.add_child(item)
get_node("../hud/inventory/type").set_text(tr(road_identifier))
get_node("../hud/inventory/track_container/type").set_text(tr(road_identifier))

2
scripts/player/player.gd

@ -58,7 +58,7 @@ func _physics_process(delta):
var road = get_road() var road = get_road()
if is_in_group("first"): if is_in_group("first"):
max_speed *= road.get_first_speed_factor() max_speed *= road.get_first_speed_factor()
if road.get_creator() == get_index():
elif road.get_creator() == get_index():
max_speed *= road.get_creator_speed_factor() max_speed *= road.get_creator_speed_factor()
else: else:
max_speed *= road.get_chasers_speed_factor() max_speed *= road.get_chasers_speed_factor()

Loading…
Cancel
Save