diff --git a/scenes/game.tscn b/scenes/game.tscn index 9fb6f00..602464b 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -39,10 +39,26 @@ horizontal_alignment = 1 vertical_alignment = 1 [node name="times_container" type="HFlowContainer" parent="hud"] -offset_left = 29.0 -offset_top = 29.0 -offset_right = 69.0 -offset_bottom = 69.0 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -546.0 +offset_top = -294.0 +offset_right = -506.0 +offset_bottom = -254.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="overlaycolor" type="ColorRect" parent="hud"] +visible = false +modulate = Color(1, 1, 1, 0) +offset_left = -25.0 +offset_top = -20.0 +offset_right = 1190.0 +offset_bottom = 682.0 +color = Color(0.482353, 0.482353, 0.482353, 0.52549) [node name="Camera2D" type="Camera2D" parent="."] diff --git a/scenes/map_01.tscn b/scenes/map_01.tscn index b15ba1a..6499610 100644 --- a/scenes/map_01.tscn +++ b/scenes/map_01.tscn @@ -202,7 +202,7 @@ tile_map_data = PackedByteArray("AAAAAP//AgAAAAAAAGD/////AgAAAAAAAGD+////AgAAAAA tile_set = ExtResource("2_i1338") [node name="road_bg2" type="TileMapLayer" parent="."] -tile_map_data = PackedByteArray("AAD4/wEAAgABAAIAAAD5/wAAAgABAAIAAEAAAAgAAAADAAIAAFD//wkAAAABAAMAAFAHAAIAAAAAAAIAAFAGAAMAAAABAAMAAFAHAAEAAAABAAMAAAAGAAAAAAAAAAIAAAD4/wgAAAAAAAIAADD3/wcAAAABAAMAADD6/wYAAAAAAAIAADD5/wUAAAABAAMAADAFAAEAAAABAAEAAEAEAAAAAAAAAAAAAEAEAAEAAAABAAAAAED+/wMAAAACAAMAADD+/wQAAAAEAAIAADD9/wMAAAAFAAMAADAAAAQAAgABAAEAAGD//wQAAgABAAEAAFABAAQAAgABAAEAAFACAAQAAgABAAEAAFAEAAIAAgACAAIAAED3/wQAAgAHAAIAADD3/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AGA=") tile_set = ExtResource("2_i1338") [node name="road_bg_fixes" type="TileMapLayer" parent="."] diff --git a/scripts/car.gd b/scripts/car.gd index c0b1981..45b8335 100644 --- a/scripts/car.gd +++ b/scripts/car.gd @@ -34,13 +34,13 @@ var traction_slow = 0.5 #Automatic Steering settings -var steering_speed_slow = 100 #speed for slow steering +var steering_speed_slow = 150 #speed for slow steering var steering_angle_slow = 50 #maximum angle slow speed var steering_distance_far_slow=200 var steering_distance_close_slow=20 -var steering_speed_fast = 300 #speed for fast steering -var steering_angle_fast = 5 #maximum angle fast speed +var steering_speed_fast = 400 #speed for fast steering +var steering_angle_fast = 2 #maximum angle fast speed var steering_distance_far_fast=256 var steering_distance_close_fast=128 diff --git a/scripts/game.gd b/scripts/game.gd index 4f59476..2e2a894 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -7,6 +7,9 @@ extends Node2D @onready var cars: Node = $cars @onready var times_container: HFlowContainer = $hud/times_container + +@onready var overlaycolor: ColorRect = $hud/overlaycolor + const caroffset= 32+4 #space cars on start line 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 @@ -14,14 +17,14 @@ var viewCarMargin_zoomstart=viewCarMargin-Vector2(0.2,0.2) #start zooming var viewCarMargin_zoombackup=viewCarMargin_zoomstart-Vector2(0.1,0.1) #start zooming back in var zoomspeed=0.5 var zoomspeed_backup=0.1 #relative to screen size -var zoom_normal=2.0 +var zoom_normal=1.5 const CAMERA_POSITION_SPEED=0.95 #0.0 - 1.0, higher=faster var running=false var rounds=3 - +var game_ended=false # Called when the node enters the scene tree for the first time. func _ready() -> void: @@ -30,7 +33,7 @@ func _ready() -> void: #Load Map var checkpoints :Array[String]=[] - var mapscene=load("res://scenes/map_02.tscn") + var mapscene=load("res://scenes/map_00.tscn") var mapsceneinstance=mapscene.instantiate() add_child(mapsceneinstance) for mapc in mapsceneinstance.get_children(): @@ -54,7 +57,6 @@ func _ready() -> void: i+=1 - # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: if running: @@ -135,6 +137,21 @@ func _process(delta: float) -> void: #$hud/debuglabel.text=""+str(calculatedViewCarMargin)+" / "+str(viewsize)+" zoomspeed="+str(mapped_zoomspeed) $hud/timer.text=str(round(Gamestate.getTimeElapsed()*1000)/1000.0) + + + if game_ended: + var ovlcolor=overlaycolor.get_modulate() + ovlcolor.a+=0.5*delta + ovlcolor.a=constrain(ovlcolor.a,0.0,1.0) + overlaycolor.set_modulate(ovlcolor) + + var tconpos_goal=Vector2(556,304) + var tconpos=times_container.get_position() + var tconsize=times_container.get_size() + tconpos+=constrain2((tconpos_goal-tconpos),Vector2(100,100)*delta,Vector2(100,100)*delta) #TODO Fix movement + times_container.set_position(tconpos) + #TODO change size container + func _input(ev): @@ -160,6 +177,11 @@ func constrain(val,a,b): var vmin=min(a,b) var vmax=max(a,b) return min(vmax,max(vmin,val)) + +func constrain2(val:Vector2,a:Vector2,b:Vector2): + var vmin=a.min(b) + var vmax=a.max(b) + return vmax.min(vmin.max(val)) func _on_countdown_timeout() -> void: @@ -169,6 +191,7 @@ func _on_countdown_timeout() -> void: c.setRunning(true) countdown_label.visible=false + func _on_car_finished(playerid,finalTime) -> void: print("Finished "+str(playerid)+" final time="+str(finalTime)) var place=times_container.get_child_count()+1 @@ -179,3 +202,14 @@ func _on_car_finished(playerid,finalTime) -> void: newlabel.text=str(place)+": "+str(round(finalTime*1000)/1000.0)+"s" newlabel.set("theme_override_colors/font_color",Gamestate.getPlayers()[playerid].color) + if times_container.get_child_count() == Gamestate.getPlayers().size(): #all players have finish times + finishGame()# Game finished + + + +func finishGame(): + print("Game Finished") + running=false + game_ended=true + overlaycolor.visible=true + diff --git a/sprites/spritesheet_road/road_2x2.xcf b/sprites/spritesheet_road/road_2x2.xcf index 30ed920..a319ce5 100644 Binary files a/sprites/spritesheet_road/road_2x2.xcf and b/sprites/spritesheet_road/road_2x2.xcf differ diff --git a/sprites/spritesheet_road/spritesheet_markings1x1.png b/sprites/spritesheet_road/spritesheet_markings1x1.png index ab6cdc4..135e2e5 100644 Binary files a/sprites/spritesheet_road/spritesheet_markings1x1.png and b/sprites/spritesheet_road/spritesheet_markings1x1.png differ diff --git a/sprites/spritesheet_road/spritesheet_road1x1.png b/sprites/spritesheet_road/spritesheet_road1x1.png index 7309378..081be2e 100644 Binary files a/sprites/spritesheet_road/spritesheet_road1x1.png and b/sprites/spritesheet_road/spritesheet_road1x1.png differ diff --git a/sprites/spritesheet_road/spritesheet_road2x2.png b/sprites/spritesheet_road/spritesheet_road2x2.png index 82c8609..9b87155 100644 Binary files a/sprites/spritesheet_road/spritesheet_road2x2.png and b/sprites/spritesheet_road/spritesheet_road2x2.png differ