add random fast mode with animation
This commit is contained in:
parent
55499832f9
commit
9c8631390f
4 changed files with 109 additions and 4 deletions
|
@ -1,10 +1,75 @@
|
|||
[gd_scene load_steps=14 format=3 uid="uid://cotth8e5rtioe"]
|
||||
[gd_scene load_steps=18 format=3 uid="uid://cotth8e5rtioe"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/game.gd" id="1_7syh4"]
|
||||
[ext_resource type="Script" path="res://scripts/times.gd" id="2_80mhm"]
|
||||
[ext_resource type="AudioStream" uid="uid://cdricwi06nttp" path="res://sounds/beep/countdown_beep_high.mp3" id="3_fdp2i"]
|
||||
[ext_resource type="AudioStream" uid="uid://v3eqa857k2xo" path="res://sounds/beep/countdown_beep.mp3" id="3_fv4j3"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_52fxl"]
|
||||
resource_name = "normal"
|
||||
|
||||
[sub_resource type="Animation" id="Animation_2q66f"]
|
||||
resource_name = "fast"
|
||||
length = 2.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("hud/carpreset_animations/label_fast:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.3, 1.66667, 2),
|
||||
"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)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("hud/carpreset_animations/label_fast:position")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0.0333333, 0.366667, 1.36667, 1.96667),
|
||||
"transitions": PackedFloat32Array(1, 0.353554, 4, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(-500, 100), Vector2(375, 100), Vector2(375, 100), Vector2(900, 100)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_fgk0n"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("hud/carpreset_animations/label_fast: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, 0)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("hud/carpreset_animations/label_fast:position")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(353, 269)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_dbd4v"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_fgk0n"),
|
||||
"fast": SubResource("Animation_2q66f"),
|
||||
"normal": SubResource("Animation_52fxl")
|
||||
}
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_e0d0g"]
|
||||
bg_color = Color(0.6, 0.6, 0.6, 0.294118)
|
||||
|
||||
|
@ -297,6 +362,28 @@ script = ExtResource("1_7syh4")
|
|||
|
||||
[node name="hud" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="carpreset_animations" type="AnimationPlayer" parent="hud"]
|
||||
root_node = NodePath("../..")
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_dbd4v")
|
||||
}
|
||||
|
||||
[node name="label_fast" type="Label" parent="hud/carpreset_animations"]
|
||||
modulate = Color(1, 1, 1, 0)
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -223.0
|
||||
offset_top = -55.0
|
||||
offset_right = 223.0
|
||||
offset_bottom = 55.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_font_sizes/font_size = 80
|
||||
text = "FAST MODE"
|
||||
|
||||
[node name="debuglabel" type="Label" parent="hud"]
|
||||
visible = false
|
||||
z_index = 8
|
||||
|
|
|
@ -8,12 +8,16 @@ extends Node2D
|
|||
|
||||
@onready var game_hud_animations: AnimationPlayer = $hud/game_hud_animations
|
||||
|
||||
@onready var carpreset_animations: AnimationPlayer = $hud/carpreset_animations
|
||||
|
||||
@onready var times_container: HFlowContainer = $hud/times_container
|
||||
@onready var timer_close: Timer = $timer_close
|
||||
|
||||
@onready var highscore_label: Label = $hud/highscore_label
|
||||
@onready var splittime_label: Label = $hud/splittime_label
|
||||
|
||||
|
||||
|
||||
const caroffset= 32+4 #space cars on start line
|
||||
const caroffset_side= 16
|
||||
const caroffset_rear= 32+16
|
||||
|
@ -39,9 +43,7 @@ var game_ended=false
|
|||
|
||||
var map_rounds:int=1
|
||||
|
||||
#var carpreset="normal"
|
||||
var carpreset="fast"
|
||||
|
||||
var carpreset="normal" # normal, fast
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
|
@ -49,6 +51,10 @@ func _ready() -> void:
|
|||
|
||||
Gamestate.resetTimeElapsed()
|
||||
map_rounds=Gamestate.getRounds() #load round number from menu
|
||||
carpreset=Gamestate.getCarPreset()
|
||||
|
||||
carpreset_animations.play(carpreset)
|
||||
|
||||
|
||||
#countdown.start()
|
||||
game_hud_animations.play("game_start")
|
||||
|
|
|
@ -16,6 +16,8 @@ var map_scene_name_postfix=".tscn"
|
|||
|
||||
var rounds=3
|
||||
|
||||
var carpreset="normal"
|
||||
|
||||
var remove_cars_timeout=true
|
||||
|
||||
var automatic_map_change_after=5
|
||||
|
@ -37,6 +39,12 @@ func setRemoveCarsTimeout(s):
|
|||
print("remove_cars_timeout set to "+str(s))
|
||||
remove_cars_timeout=s
|
||||
|
||||
func getCarPreset():
|
||||
return carpreset
|
||||
|
||||
func setCarPreset(p:String):
|
||||
carpreset=p
|
||||
|
||||
func setAutomaticMapChangeAfter(v):
|
||||
automatic_map_change_after=max(v,0)
|
||||
|
||||
|
|
|
@ -72,6 +72,10 @@ func _unhandled_key_input(event: InputEvent) -> void:
|
|||
|
||||
func _on_timer_timeout() -> void: #Start Game
|
||||
print("Game starting")
|
||||
if (randi() % 5 == 0):
|
||||
Gamestate.setCarPreset("fast")
|
||||
else:
|
||||
Gamestate.setCarPreset("normal")
|
||||
get_tree().change_scene_to_file("res://scenes/game.tscn")
|
||||
$Timer.stop()
|
||||
assignKeys()
|
||||
|
|
Loading…
Add table
Reference in a new issue