fix S-shape road tile
This commit is contained in:
parent
11b06c5b3a
commit
768dbaf21c
8 changed files with 62 additions and 12 deletions
|
@ -39,10 +39,26 @@ horizontal_alignment = 1
|
||||||
vertical_alignment = 1
|
vertical_alignment = 1
|
||||||
|
|
||||||
[node name="times_container" type="HFlowContainer" parent="hud"]
|
[node name="times_container" type="HFlowContainer" parent="hud"]
|
||||||
offset_left = 29.0
|
anchors_preset = 8
|
||||||
offset_top = 29.0
|
anchor_left = 0.5
|
||||||
offset_right = 69.0
|
anchor_top = 0.5
|
||||||
offset_bottom = 69.0
|
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="."]
|
[node name="Camera2D" type="Camera2D" parent="."]
|
||||||
|
|
||||||
|
|
|
@ -202,7 +202,7 @@ tile_map_data = PackedByteArray("AAAAAP//AgAAAAAAAGD/////AgAAAAAAAGD+////AgAAAAA
|
||||||
tile_set = ExtResource("2_i1338")
|
tile_set = ExtResource("2_i1338")
|
||||||
|
|
||||||
[node name="road_bg2" type="TileMapLayer" parent="."]
|
[node name="road_bg2" type="TileMapLayer" parent="."]
|
||||||
tile_map_data = PackedByteArray("AAD4/wEAAgABAAIAAAD5/wAAAgABAAIAAEAAAAgAAAADAAIAAFD//wkAAAABAAMAAFAHAAIAAAAAAAIAAFAGAAMAAAABAAMAAFAHAAEAAAABAAMAAAAGAAAAAAAAAAIAAAD4/wgAAAAAAAIAADD3/wcAAAABAAMAADD6/wYAAAAAAAIAADD5/wUAAAABAAMAADAFAAEAAAABAAEAAEAEAAAAAAAAAAAAAEAEAAEAAAABAAAAAED+/wMAAAACAAMAADD+/wQAAAAEAAIAADD9/wMAAAAFAAMAADAAAAQAAgABAAEAAGD//wQAAgABAAEAAFABAAQAAgABAAEAAFACAAQAAgABAAEAAFAEAAIAAgACAAIAAED3/wQAAgAHAAIAADD3/wIAAgAHAAIAADD6////AgAHAAIAAGD5/wMAAgAHAAIAADD7/wEAAgAHAAIAAGD8/wEAAgABAAEAAGD8/wYAAgAHAAIAAFD6/wMAAgAHAAIAAAD7/wQAAAACAAMAADD7/wUAAAACAAIAADD6/wQAAAADAAMAADD9/wYAAgABAAEAAFD+/wYAAgABAAEAAFD//wUAAgABAAEAAGAAAAcAAAACAAIAAFD//wgAAAADAAMAAFAEAAMAAgAGAAAAAAABAAYAAgABAAEAAGAHAAMAAAABAAIAAFD9/wQAAAAFAAIAADD//wcAAAACAAMAAFA=")
|
tile_map_data = PackedByteArray("AAD4/wEAAgABAAIAAAD5/wAAAgABAAIAAEAAAAgAAAADAAIAAFD//wkAAAABAAMAAFAHAAIAAAAAAAIAAFAGAAMAAAABAAMAAFAHAAEAAAABAAMAAAAGAAAAAAAAAAIAAAD4/wgAAAAAAAIAADD3/wcAAAABAAMAADD6/wYAAAAAAAIAADD5/wUAAAABAAMAADAFAAEAAAABAAEAAEAEAAAAAAAAAAAAAEAEAAEAAAABAAAAAED+/wMAAAACAAMAADD+/wQAAAAEAAIAADD9/wMAAAAFAAMAADAAAAQAAgABAAEAAGD//wQAAgABAAEAAFABAAQAAgABAAEAAFACAAQAAgABAAEAAFAEAAIAAgACAAIAAED3/wQAAgAHAAIAADD3/wIAAgAHAAIAADD6////AgAHAAIAAGD5/wMAAgAHAAIAADD7/wEAAgAHAAIAAGD8/wEAAgABAAEAAGD8/wYAAgAHAAIAAFD6/wMAAgAHAAIAAAD7/wQAAAACAAMAADD7/wUAAAACAAIAADD6/wQAAAADAAMAADD9/wYAAgABAAEAAFD+/wYAAgABAAEAAFD//wUAAgABAAEAAGAAAAcAAAACAAIAAFD//wgAAAADAAMAAFAEAAMAAgAGAAAAAAABAAYAAgABAAEAAGAHAAMAAAABAAIAAFD9/wQAAAAFAAIAADD//wcAAAACAAMAAFD8/wgAAgAHAAIAAGD7/wgAAgAHAAIAAFAFAAMAAgAHAAIAAFAFAAAAAgAHAAIAAGA=")
|
||||||
tile_set = ExtResource("2_i1338")
|
tile_set = ExtResource("2_i1338")
|
||||||
|
|
||||||
[node name="road_bg_fixes" type="TileMapLayer" parent="."]
|
[node name="road_bg_fixes" type="TileMapLayer" parent="."]
|
||||||
|
|
|
@ -34,13 +34,13 @@ var traction_slow = 0.5
|
||||||
|
|
||||||
#Automatic Steering settings
|
#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_angle_slow = 50 #maximum angle slow speed
|
||||||
var steering_distance_far_slow=200
|
var steering_distance_far_slow=200
|
||||||
var steering_distance_close_slow=20
|
var steering_distance_close_slow=20
|
||||||
|
|
||||||
var steering_speed_fast = 300 #speed for fast steering
|
var steering_speed_fast = 400 #speed for fast steering
|
||||||
var steering_angle_fast = 5 #maximum angle fast speed
|
var steering_angle_fast = 2 #maximum angle fast speed
|
||||||
var steering_distance_far_fast=256
|
var steering_distance_far_fast=256
|
||||||
var steering_distance_close_fast=128
|
var steering_distance_close_fast=128
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,9 @@ extends Node2D
|
||||||
@onready var cars: Node = $cars
|
@onready var cars: Node = $cars
|
||||||
@onready var times_container: HFlowContainer = $hud/times_container
|
@onready var times_container: HFlowContainer = $hud/times_container
|
||||||
|
|
||||||
|
|
||||||
|
@onready var overlaycolor: ColorRect = $hud/overlaycolor
|
||||||
|
|
||||||
const caroffset= 32+4 #space cars on start line
|
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
|
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 viewCarMargin_zoombackup=viewCarMargin_zoomstart-Vector2(0.1,0.1) #start zooming back in
|
||||||
var zoomspeed=0.5
|
var zoomspeed=0.5
|
||||||
var zoomspeed_backup=0.1 #relative to screen size
|
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
|
const CAMERA_POSITION_SPEED=0.95 #0.0 - 1.0, higher=faster
|
||||||
|
|
||||||
var running=false
|
var running=false
|
||||||
|
|
||||||
var rounds=3
|
var rounds=3
|
||||||
|
|
||||||
|
var game_ended=false
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
@ -30,7 +33,7 @@ func _ready() -> void:
|
||||||
|
|
||||||
#Load Map
|
#Load Map
|
||||||
var checkpoints :Array[String]=[]
|
var checkpoints :Array[String]=[]
|
||||||
var mapscene=load("res://scenes/map_02.tscn")
|
var mapscene=load("res://scenes/map_00.tscn")
|
||||||
var mapsceneinstance=mapscene.instantiate()
|
var mapsceneinstance=mapscene.instantiate()
|
||||||
add_child(mapsceneinstance)
|
add_child(mapsceneinstance)
|
||||||
for mapc in mapsceneinstance.get_children():
|
for mapc in mapsceneinstance.get_children():
|
||||||
|
@ -54,7 +57,6 @@ func _ready() -> void:
|
||||||
i+=1
|
i+=1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
if running:
|
if running:
|
||||||
|
@ -137,6 +139,21 @@ func _process(delta: float) -> void:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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):
|
func _input(ev):
|
||||||
#if ev is InputEventKey and
|
#if ev is InputEventKey and
|
||||||
if Input.is_action_just_pressed("ui_cancel"):
|
if Input.is_action_just_pressed("ui_cancel"):
|
||||||
|
@ -161,6 +178,11 @@ func constrain(val,a,b):
|
||||||
var vmax=max(a,b)
|
var vmax=max(a,b)
|
||||||
return min(vmax,max(vmin,val))
|
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:
|
func _on_countdown_timeout() -> void:
|
||||||
running=true
|
running=true
|
||||||
|
@ -169,6 +191,7 @@ func _on_countdown_timeout() -> void:
|
||||||
c.setRunning(true)
|
c.setRunning(true)
|
||||||
countdown_label.visible=false
|
countdown_label.visible=false
|
||||||
|
|
||||||
|
|
||||||
func _on_car_finished(playerid,finalTime) -> void:
|
func _on_car_finished(playerid,finalTime) -> void:
|
||||||
print("Finished "+str(playerid)+" final time="+str(finalTime))
|
print("Finished "+str(playerid)+" final time="+str(finalTime))
|
||||||
var place=times_container.get_child_count()+1
|
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.text=str(place)+": "+str(round(finalTime*1000)/1000.0)+"s"
|
||||||
newlabel.set("theme_override_colors/font_color",Gamestate.getPlayers()[playerid].color)
|
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
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 582 B After Width: | Height: | Size: 582 B |
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Loading…
Reference in a new issue