diff --git a/scenes/map_00.tscn b/scenes/map_00.tscn index b653816..2982e1c 100644 --- a/scenes/map_00.tscn +++ b/scenes/map_00.tscn @@ -193,6 +193,7 @@ sources/0 = SubResource("TileSetAtlasSource_hclam") [node name="Map" type="Node"] [node name="Background" type="TileMapLayer" parent="."] +visible = false tile_map_data = PackedByteArray("AAD6//z/AQAAAAAAAAD6//3/AQAAAAAAAAD6//7/AQAAAAAAAAD6////AQAAAAAAAAD6/wAAAQAAAAAAAAD6/wEAAQAAAAAAAAD6/wIAAQAAAAAAAAD6/wMAAQAAAAAAAAD6/wQAAQAAAAAAAAD6/wUAAQAAAAAAAAD6/wYAAQAAAAAAAAD6/wcAAQAAAAAAAAD7//z/AQAAAAAAAAD7//3/AQAAAAAAAAD7//7/AQAAAAAAAAD7////AQAAAAAAAAD7/wAAAQAAAAAAAAD7/wEAAQAAAAAAAAD7/wIAAQAAAAAAAAD7/wMAAQAAAAAAAAD7/wQAAQAAAAAAAAD7/wUAAQAAAAAAAAD7/wYAAQAAAAAAAAD7/wcAAQAAAAAAAAD8//z/AQAAAAAAAAD8//3/AQAAAAAAAAD8//7/AQAAAAAAAAD8////AQAAAAAAAAD8/wAAAQAAAAAAAAD8/wEAAQAAAAAAAAD8/wIAAQAAAAAAAAD8/wMAAQAAAAAAAAD8/wQAAQAAAAAAAAD8/wUAAQAAAAAAAAD8/wYAAQAAAAAAAAD8/wcAAQAAAAAAAAD9//z/AQAAAAAAAAD9//3/AQAAAAAAAAD9//7/AQAAAAAAAAD9////AQAAAAAAAAD9/wAAAQAAAAAAAAD9/wEAAQAAAAAAAAD9/wIAAQAAAAAAAAD9/wMAAQAAAAAAAAD9/wQAAQAAAAAAAAD9/wUAAQAAAAAAAAD9/wYAAQAAAAAAAAD9/wcAAQAAAAAAAAD+//z/AQAAAAAAAAD+//3/AQAAAAAAAAD+//7/AQAAAAAAAAD+////AQAAAAAAAAD+/wAAAQAAAAAAAAD+/wEAAQABAAAAAAD+/wIAAQAAAAAAAAD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AAAAD+//r/AQAAAAAAAAD+//v/AQAAAAAAAAD///r/AQAAAAAAAAD///v/AQAAAAAAAAAAAPr/AQAAAAAAAAAAAPv/AQAAAAAAAAABAPr/AQAAAAAAAAABAPv/AQAAAAAAAAACAPr/AQAAAAAAAAACAPv/AQAAAAAAAAADAPr/AQAAAAAAAAADAPv/AQAAAAAAAAAEAPr/AQAAAAAAAAAEAPv/AQAAAAAAAAAFAPr/AQAAAAAAAAAFAPv/AQAAAAAAAAAGAPr/AQAAAAAAAAAGAPv/AQAAAAAAAAAHAPr/AQAAAAAAAAAHAPv/AQAAAAAAAAAIAPr/AQAAAAAAAAAIAPv/AQAAAAAAAAAJAPr/AQAAAAAAAAAJAPv/AQAAAAAAAAAKAPr/AQAAAAAAAAAKAPv/AQAAAAAAAAA=") tile_set = SubResource("TileSet_5knbn") collision_enabled = false @@ -202,10 +203,12 @@ tile_map_data = PackedByteArray("AAD/////AgAAAAAAAGD//wAAAgAAAAAAAFAAAP//AgAAAAA tile_set = ExtResource("2_1kitx") [node name="road_bg2" type="TileMapLayer" parent="."] +visible = false tile_map_data = PackedByteArray("AAD7/wEAAgABAAEAADD//wQAAAAAAAAAAGAHAAQAAgAHAAIAADAHAP//AAAAAAIAAAAIAAAAAAABAAMAAAAHAAUAAAABAAMAAFAIAAQAAAAAAAIAAFAEAAMAAAABAAAAAHAEAAQAAAAAAAAAAHADAAMAAAABAAEAAHAAAAMAAAABAAEAAGD//wMAAAABAAAAAGACAAQAAgAHAAIAAFAHAAAAAgAGAAAAAAAHAAEAAgAHAAIAADAGAAAAAgAHAAIAAFD8/wAAAgAHAAIAAFA=") tile_set = ExtResource("2_1kitx") [node name="road_bg_fixes" type="TileMapLayer" parent="."] +visible = false tile_map_data = PackedByteArray("AAD//wQAAgABAAEAAFAEAAQAAAAAAAAAAEAFAAUAAAABAAEAAEAEAAUAAAABAAAAAEAHAAQAAgAHAAIAAGA=") tile_set = ExtResource("2_1kitx") diff --git a/scenes/menu.tscn b/scenes/menu.tscn index 252bb11..c0905f4 100644 --- a/scenes/menu.tscn +++ b/scenes/menu.tscn @@ -1,10 +1,9 @@ -[gd_scene load_steps=14 format=3 uid="uid://b1uhymisifcho"] +[gd_scene load_steps=12 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="Shader" path="res://shader/menubg.gdshader" id="3_vry7a"] [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"] [ext_resource type="Texture2D" uid="uid://mkjrrv20lhkc" path="res://scenes/map_preview/map_03.png" id="7_5f67q"] @@ -13,13 +12,6 @@ [ext_resource type="Texture2D" uid="uid://bst8p5s1sgurm" path="res://sprites/menu_bg.png" id="10_equk1"] [ext_resource type="Texture2D" uid="uid://drgqjl330tj2p" path="res://scenes/map_preview/no_preview.png" id="11_3sx36"] -[sub_resource type="ShaderMaterial" id="ShaderMaterial_kpdum"] -shader = ExtResource("3_vry7a") -shader_parameter/rotationpivot = Vector2(0.5, 0.49) -shader_parameter/speed = 0.1 -shader_parameter/strength = 8.5 -shader_parameter/iChannel0 = ExtResource("10_equk1") - [node name="Menu" type="Node"] script = ExtResource("1_fushn") @@ -27,7 +19,6 @@ script = ExtResource("1_fushn") script = ExtResource("2_jc4pv") [node name="MenuBg" type="Sprite2D" parent="MenuDisplay"] -material = SubResource("ShaderMaterial_kpdum") position = Vector2(1170, 338) scale = Vector2(2.65635, 2.65635) texture = ExtResource("10_equk1") diff --git a/scripts/car.gd b/scripts/car.gd index ea72a4b..86a7a5b 100644 --- a/scripts/car.gd +++ b/scripts/car.gd @@ -210,12 +210,14 @@ func get_input(delta:float): if distance_min float: return cbcar.velocity.length() @@ -16,9 +17,10 @@ func getPositionLookahead(t:float): func setPosition(p:Vector2): cbcar.position=p -func setPlayerinformation(playerid, playercolor): +func setPlayerinformation(playerid, playercolor,preference_gamestateplayer): cbcar.playerid=playerid carbody.modulate = playercolor + reference_gamestateplayer=preference_gamestateplayer func setCheckpoints(cps,rounds): diff --git a/scripts/game.gd b/scripts/game.gd index be11592..05d4757 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -13,6 +13,8 @@ extends Node2D const caroffset= 32+4 #space cars on start line +const caroffset_side= 32+16 +const caroffset_rear= 64 var viewCarMargin=Vector2(0.7,0.7) #1=zoom out full speed when car is at border. 0.9 zoom out full speed when car is 10% away from border var viewCarMargin_zoomstart=viewCarMargin-Vector2(0.2,0.2) #start zooming @@ -51,20 +53,34 @@ func _ready() -> void: print(str(checkpoints.size())+" Checkpoints found") var i=0 + var players_ranked :Array = Gamestate.getPlayers().duplicate() + players_ranked.sort_custom(custom_array_sort_rank) #arrange players by handicap/rank for player in Gamestate.getPlayers(): #create all players + #get player rank + var i_position=0 + while i_position void: print("Close Map") diff --git a/scripts/gamestate.gd b/scripts/gamestate.gd index 20cb5c8..3cc7be5 100644 --- a/scripts/gamestate.gd +++ b/scripts/gamestate.gd @@ -43,15 +43,20 @@ func addPlayer(key:int): #return -1 if player already exists with this key. else return id of player added if not getPlayerkeys().has(key): #key is not yet registered var prefered_colori=0 + var setrank=((randf()-0.5)/10.0)+0.5 for p in last_players: if p.inputkey==key: #key was used in last round prefered_colori=p.colori + setrank=p.rank + print("Player found in last_players. rank="+str(setrank)+" colori="+str(prefered_colori)) #check if color is free, else assign next free while not checkColoriFree(prefered_colori): prefered_colori+=1 - players.append(Player.new(key,prefered_colori)) + var newplayer: Player = Player.new(key,prefered_colori) + newplayer.rank=setrank + players.append(newplayer) return prefered_colori else: @@ -76,6 +81,7 @@ class Player: var inputkey:int var color:Color var colori + var rank:float #0-1, nonlinear, higher when player wins often func _init(key:int, pcolori:int=-1): inputkey=key @@ -86,7 +92,7 @@ class Player: if colori<0: color=Color.from_hsv(randf_range(0.0,1.0), sat,val,1.0) else: - color=Color.from_hsv(fmod(0.3*colori,1.0), sat,val,1.0) + color=Color.from_hsv(fmod(0.3*colori,1.0), sat,val,1.0) #todo: make colorwheel smaller when whitelist enabled func startGame():