add preset speed mode functions
This commit is contained in:
parent
c78fdce9cd
commit
55499832f9
5 changed files with 72 additions and 17 deletions
|
@ -271,6 +271,18 @@ tracks/0/keys = {
|
|||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("countdown_label:self_modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_wuihg"]
|
||||
_data = {
|
||||
|
@ -289,10 +301,10 @@ script = ExtResource("1_7syh4")
|
|||
visible = false
|
||||
z_index = 8
|
||||
offset_left = 14.0
|
||||
offset_top = 535.0
|
||||
offset_top = 483.0
|
||||
offset_right = 430.0
|
||||
offset_bottom = 580.0
|
||||
theme_override_font_sizes/font_size = 20
|
||||
offset_bottom = 604.0
|
||||
theme_override_font_sizes/font_size = 50
|
||||
text = "adsf"
|
||||
vertical_alignment = 1
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=35 format=3 uid="uid://bu1m43nyf4ys8"]
|
||||
[gd_scene load_steps=36 format=3 uid="uid://bu1m43nyf4ys8"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://csknopg1cbqbq" path="res://sprites/background/green_gradient.png" id="1_01a82"]
|
||||
[ext_resource type="Script" path="res://scripts/map_settings.gd" id="1_7xl02"]
|
||||
|
@ -30,9 +30,10 @@
|
|||
[ext_resource type="Texture2D" uid="uid://c6yd5j7dsnrhc" path="res://sprites/smooth_fields/fields_flower_009.png" id="23_qsqn3"]
|
||||
[ext_resource type="Texture2D" uid="uid://c02dmvpb7541n" path="res://sprites/smooth_fields/fields_flower_013.png" id="24_joq8i"]
|
||||
[ext_resource type="Texture2D" uid="uid://cx2uy8puk15v5" path="res://sprites/smooth_fields/fields_flower_015.png" id="25_ituuu"]
|
||||
[ext_resource type="Texture2D" uid="uid://do3gd2qodpq66" path="res://sprites/road/checkpoint.png" id="31_7cme3"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_dltky"]
|
||||
size = Vector2(64, 128)
|
||||
size = Vector2(12, 128)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_uys5r"]
|
||||
size = Vector2(64, 192)
|
||||
|
@ -90,6 +91,7 @@ texture = ExtResource("4_s7foq")
|
|||
texture_mode = 1
|
||||
|
||||
[node name="Road" type="Polygon2D" parent="." node_paths=PackedStringArray("line_road_left", "line_road_right")]
|
||||
position = Vector2(0, 2)
|
||||
color = Color(0.314316, 0.314316, 0.314316, 1)
|
||||
script = ExtResource("5_g15mv")
|
||||
line_road_left = NodePath("../Line2D2_left")
|
||||
|
@ -100,7 +102,7 @@ collision_layer = 4
|
|||
collision_mask = 4
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="area_cp0"]
|
||||
position = Vector2(480, 0)
|
||||
position = Vector2(455, 0)
|
||||
shape = SubResource("RectangleShape2D_dltky")
|
||||
debug_color = Color(0.958025, 0, 0.529392, 0.42)
|
||||
|
||||
|
@ -127,7 +129,7 @@ collision_layer = 4
|
|||
collision_mask = 4
|
||||
|
||||
[node name="CollisionShape2D_Fin" type="CollisionShape2D" parent="area_finish"]
|
||||
position = Vector2(144, 0)
|
||||
position = Vector2(114, 0)
|
||||
shape = SubResource("RectangleShape2D_daqun")
|
||||
debug_color = Color(1, 1, 1, 0.42)
|
||||
|
||||
|
@ -444,3 +446,21 @@ points = PackedVector2Array(128, -48, 128, 48)
|
|||
width = 16.0
|
||||
texture = ExtResource("7_03lti")
|
||||
texture_mode = 1
|
||||
|
||||
[node name="line2d_cp0" type="Line2D" parent="Node2D_Roadmarkings"]
|
||||
points = PackedVector2Array(448, -48, 448, 48)
|
||||
width = 16.0
|
||||
texture = ExtResource("31_7cme3")
|
||||
texture_mode = 1
|
||||
|
||||
[node name="line2d_cp1" type="Line2D" parent="Node2D_Roadmarkings"]
|
||||
points = PackedVector2Array(320, 336, 320, 496)
|
||||
width = 16.0
|
||||
texture = ExtResource("31_7cme3")
|
||||
texture_mode = 1
|
||||
|
||||
[node name="line2d_cp2" type="Line2D" parent="Node2D_Roadmarkings"]
|
||||
points = PackedVector2Array(-528, 160, -624, 160)
|
||||
width = 16.0
|
||||
texture = ExtResource("31_7cme3")
|
||||
texture_mode = 1
|
||||
|
|
|
@ -24,22 +24,24 @@ const MIN_CRASH_VELOCITY=10
|
|||
const STANDSTILLSPEED=0.5
|
||||
var wheel_base = 60*0.5
|
||||
|
||||
var engine_power = 350
|
||||
#var engine_power = 1000 #crazy mode
|
||||
|
||||
var applied_engine_power=0
|
||||
|
||||
|
||||
var engine_power = 350
|
||||
#var engine_power = 1000 #crazy mode
|
||||
var friction = -0.5
|
||||
var drag = -0.0005
|
||||
var braking = -200
|
||||
var braking = -250 #was 200
|
||||
#var braking = -600 #crazy mode
|
||||
var max_speed_reverse = 100
|
||||
var slip_speed = 150
|
||||
var traction_fast = 0.05 #traction when above slip_speed
|
||||
var traction_slow = 0.5
|
||||
|
||||
var max_steering_change = 2.5
|
||||
var turndirection_scale = 0.01
|
||||
|
||||
var max_steering_change = 5.0
|
||||
var turndirection_scale = 0.01
|
||||
|
||||
#Automatic Steering settings
|
||||
|
||||
|
@ -284,7 +286,7 @@ func get_input(delta:float):
|
|||
if autoreset and running:
|
||||
acceleration = transform.x * braking #drive backwards
|
||||
steer_direction_aim=resetcar_steerangle #keep steering to turn around if standing in the middle of a track
|
||||
steer_direction=steer_direction_aim #steer without smoothing
|
||||
#steer_direction=steer_direction_aim #steer without smoothing
|
||||
else:
|
||||
if steer_direction_aim<0.1:
|
||||
resetcar_steerangle=max(-resetcar_steerangle,+resetcar_steerangle) #calculate steering direction for next autoreset
|
||||
|
@ -382,3 +384,15 @@ func _on_collision_enable_timer_timeout() -> void:
|
|||
func _on_no_input_timer_timeout() -> void:
|
||||
no_input_timeout_flag=true
|
||||
running=false
|
||||
|
||||
func applyPresetNormal() -> void:
|
||||
engine_power = 350
|
||||
braking = -250
|
||||
steering_speed_fast = 400
|
||||
|
||||
|
||||
func applyPresetFast() -> void:
|
||||
engine_power = 700
|
||||
braking = -300
|
||||
steering_speed_fast = 3*400
|
||||
|
||||
|
|
|
@ -7,6 +7,12 @@ var reference_gamestateplayer
|
|||
func setMapRounds(r:int):
|
||||
$CharacterBody_Car/label_round.map_rounds=r
|
||||
|
||||
func setPreset(p:String):
|
||||
if p=="normal":
|
||||
cbcar.applyPresetNormal()
|
||||
elif p=="fast":
|
||||
cbcar.applyPresetFast()
|
||||
|
||||
func getSpeed() -> float:
|
||||
return cbcar.velocity.length()
|
||||
|
||||
|
|
|
@ -39,6 +39,9 @@ var game_ended=false
|
|||
|
||||
var map_rounds:int=1
|
||||
|
||||
#var carpreset="normal"
|
||||
var carpreset="fast"
|
||||
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
|
@ -47,8 +50,6 @@ func _ready() -> void:
|
|||
Gamestate.resetTimeElapsed()
|
||||
map_rounds=Gamestate.getRounds() #load round number from menu
|
||||
|
||||
|
||||
|
||||
#countdown.start()
|
||||
game_hud_animations.play("game_start")
|
||||
#countdown_label.visible=true
|
||||
|
@ -88,6 +89,7 @@ func _ready() -> void:
|
|||
newcarinstance.getCharacterBody().car_finished.connect(_on_car_finished)
|
||||
newcarinstance.getCharacterBody().car_on_checkpoint.connect(_on_car_on_checkpoint)
|
||||
newcarinstance.setMapRounds(map_rounds) #give information to each car (to show correct rounds number)
|
||||
newcarinstance.setPreset(carpreset)
|
||||
|
||||
var startmarker:Sprite2D=mapsceneinstance.get_node("startmarker")
|
||||
if startmarker != null:
|
||||
|
@ -101,7 +103,7 @@ func _ready() -> void:
|
|||
print("i_position="+str(i_position)+" carpos is ="+str(newcarinstance.getPosition())+" instancepos="+str(newcarinstance.position)+" colori="+str(player.colori)+" color="+str(player.color))
|
||||
i+=1
|
||||
|
||||
highscorecheckpointtimes=HighscoreHandler.loadHighcoreCheckpoints(Gamestate.getSelectedMapName(),"normal",str(map_rounds))
|
||||
highscorecheckpointtimes=HighscoreHandler.loadHighcoreCheckpoints(Gamestate.getSelectedMapName(),carpreset,str(map_rounds))
|
||||
|
||||
|
||||
func custom_array_sort_rank(a, b):
|
||||
|
@ -120,6 +122,7 @@ func _process(delta: float) -> void:
|
|||
|
||||
#$hud/debuglabel.text=""+str(calculatedViewCarMargin)+" / "+str(viewCarMargin_zoomstart)+" zoomspeed="+str(mapped_zoomspeed)
|
||||
#$hud/debuglabel.text=""+str(calculatedViewCarMargin)+" / "+str(viewsize)+" zoomspeed="+str(mapped_zoomspeed)
|
||||
$hud/debuglabel.text=""+str($cars.get_child(0).getCharacterBody().velocity.length())
|
||||
$hud/timer.text=str(round(Gamestate.getTimeElapsed()*1000)/1000.0)
|
||||
|
||||
|
||||
|
@ -297,7 +300,7 @@ func finishGame():
|
|||
|
||||
|
||||
if Gamestate.getPlayers().size()==1: #was played in singleplayer
|
||||
var timediff=HighscoreHandler.updateHighscore(Gamestate.getSelectedMapName(),"normal",str(map_rounds),getfinalTimeByPlayer(Gamestate.getPlayers()[0]),getcheckpointtimesByPlayer(Gamestate.getPlayers()[0]))
|
||||
var timediff=HighscoreHandler.updateHighscore(Gamestate.getSelectedMapName(),carpreset,str(map_rounds),getfinalTimeByPlayer(Gamestate.getPlayers()[0]),getcheckpointtimesByPlayer(Gamestate.getPlayers()[0]))
|
||||
print("Timediff="+str(timediff))
|
||||
timediff=round(timediff*1000)/1000
|
||||
highscore_label.visible=true
|
||||
|
|
Loading…
Add table
Reference in a new issue