diff --git a/scenes/car.tscn b/scenes/car.tscn index f9a13dc..c82a532 100644 --- a/scenes/car.tscn +++ b/scenes/car.tscn @@ -1,14 +1,52 @@ -[gd_scene load_steps=6 format=3 uid="uid://0g7qqh7naniv"] +[gd_scene load_steps=10 format=3 uid="uid://0g7qqh7naniv"] [ext_resource type="Script" path="res://scripts/car_node.gd" id="1_0tin3"] [ext_resource type="Script" path="res://scripts/car.gd" id="1_i5tet"] [ext_resource type="Texture2D" uid="uid://mqdujngircok" path="res://sprites/car_features.png" id="3_ts6mm"] [ext_resource type="Texture2D" uid="uid://e5aeyl47wi8p" path="res://sprites/car_body.png" id="4_lps13"] +[ext_resource type="Script" path="res://scripts/label_round.gd" id="5_vheit"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_bj1hp"] radius = 8.0 height = 34.0 +[sub_resource type="Animation" id="Animation_wl2vo"] +resource_name = "show_rounds" +length = 3.0 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("label_round:self_modulate") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0.133333, 0.533333, 1.5, 2.5), +"transitions": PackedFloat32Array(1, 1, 1, 1), +"update": 0, +"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1), Color(1, 1, 1, 1), Color(1, 1, 1, 0)] +} + +[sub_resource type="Animation" id="Animation_3soig"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("label_round:self_modulate") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 0, +"values": [Color(1, 1, 1, 1)] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_55lyd"] +_data = { +"RESET": SubResource("Animation_3soig"), +"show_rounds": SubResource("Animation_wl2vo") +} + [node name="Car" type="Node2D"] script = ExtResource("1_0tin3") @@ -51,5 +89,22 @@ collide_with_areas = true wait_time = 0.1 one_shot = true +[node name="label_round" type="Label" parent="CharacterBody_Car"] +z_index = 10 +offset_left = -52.0 +offset_top = -12.0 +offset_right = -12.0 +offset_bottom = 12.0 +pivot_offset = Vector2(20, 12) +text = "3/3" +horizontal_alignment = 1 +vertical_alignment = 1 +script = ExtResource("5_vheit") + +[node name="AnimationPlayer" type="AnimationPlayer" parent="CharacterBody_Car"] +libraries = { +"": SubResource("AnimationLibrary_55lyd") +} + [connection signal="timeout" from="CharacterBody_Car/resetTimer" to="CharacterBody_Car" method="_on_reset_timer_timeout"] [connection signal="timeout" from="CharacterBody_Car/collisionEnableTimer" to="CharacterBody_Car" method="_on_collision_enable_timer_timeout"] diff --git a/scenes/game.tscn b/scenes/game.tscn index cdc1824..4fc0409 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -28,7 +28,7 @@ tracks/1/keys = { "times": PackedFloat32Array(0, 0.966667), "transitions": PackedFloat32Array(1, 1), "update": 0, -"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 0.568627)] +"values": [Color(1, 1, 1, 0), Color(0.446777, 0.446777, 0.446777, 0.568627)] } tracks/2/type = "value" tracks/2/imported = false @@ -162,10 +162,10 @@ anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -offset_left = -166.0 -offset_top = -252.0 -offset_right = -108.0 -offset_bottom = -175.0 +offset_left = -483.861 +offset_top = -287.132 +offset_right = -425.861 +offset_bottom = -210.132 grow_horizontal = 2 grow_vertical = 2 script = ExtResource("2_80mhm") diff --git a/scripts/car.gd b/scripts/car.gd index 45b8335..1357342 100644 --- a/scripts/car.gd +++ b/scripts/car.gd @@ -216,6 +216,10 @@ func calculate_steering(delta:float): velocity = - new_heading * min(velocity.length(),max_speed_reverse) rotation = new_heading.angle() +func getRound(): + var i=getNextCPindex()/checkpoints.size() + print("Round="+str(i)+" cpindex="+str(getNextCPindex())+" size="+str(checkpoints.size())) + return i func check_markers(): if ray_cast_car.is_colliding(): @@ -225,8 +229,9 @@ func check_markers(): #if ray_cast_car.get_collision_mask_value(COLLISIONMASK_CHECKPOINT): var rcc_collidername=ray_cast_car.get_collider().name if rcc_collidername=="area_finish": + $label_round.showRounds(getRound()) #print("Player "+str(playerid)+" drove through Finish") - if getNextCPindex()==-1 and finalTime==-1: #all checkpoints have times and did not finish + if getNextCPindex()==-1 and finalTime==-1: #all checkpoints have times and did not finish = Finished print("Player "+str(playerid)+" Finished") print("Final Time: "+str(Gamestate.getTimeElapsed())) running=false diff --git a/scripts/gamestate.gd b/scripts/gamestate.gd index 240ef77..b4429cb 100644 --- a/scripts/gamestate.gd +++ b/scripts/gamestate.gd @@ -19,6 +19,7 @@ func getRounds(): return rounds func setRounds(r): + print("Rounds set to "+str(r)) rounds=r func getSelectedMap(): diff --git a/scripts/label_round.gd b/scripts/label_round.gd new file mode 100644 index 0000000..5be90dc --- /dev/null +++ b/scripts/label_round.gd @@ -0,0 +1,18 @@ +extends Label + +@onready var animation_player: AnimationPlayer = $"../AnimationPlayer" + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + self_modulate=Color(1,1,1,0) #start transparent + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + +func showRounds(round): + var rounds=Gamestate.getRounds() + text=str(round)+"/"+str(rounds) + animation_player.play("show_rounds") diff --git a/scripts/rounds_selection.gd b/scripts/rounds_selection.gd index 6236de1..cfe95f4 100644 --- a/scripts/rounds_selection.gd +++ b/scripts/rounds_selection.gd @@ -4,13 +4,8 @@ extends OptionButton # Called when the node enters the scene tree for the first time. func _ready() -> void: select(3-1) #preselect rounds - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass - - + Gamestate.setRounds(3) + diff --git a/sprites/car.bmp b/sprites/car.bmp deleted file mode 100644 index a9930de..0000000 Binary files a/sprites/car.bmp and /dev/null differ diff --git a/sprites/car.png b/sprites/car.png deleted file mode 100644 index ca142a1..0000000 Binary files a/sprites/car.png and /dev/null differ diff --git a/sprites/car.png.import b/sprites/car.png.import deleted file mode 100644 index e2c8a72..0000000 --- a/sprites/car.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://c2wq5xkfmca1r" -path="res://.godot/imported/car.png-b2ca7bee34d0a72d15f9ed0bc2f7996f.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://sprites/car.png" -dest_files=["res://.godot/imported/car.png-b2ca7bee34d0a72d15f9ed0bc2f7996f.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1