diff --git a/scenes/world/Player.tscn b/scenes/world/Player.tscn index b805acd..df7f0d5 100644 --- a/scenes/world/Player.tscn +++ b/scenes/world/Player.tscn @@ -76,6 +76,15 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +[node name="Dark" type="ColorRect" parent="HUD"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0, 0, 0, 1) + [node name="BlinkIconBG" type="ColorRect" parent="HUD"] layout_mode = 0 offset_right = 32.0 @@ -105,13 +114,23 @@ texture = ExtResource("3_7frn8") [node name="These meters are lazy" type="Node" parent="HUD"] -[node name="BlinkMeter" parent="HUD" instance=ExtResource("4_r7w8e")] +[node name="BlinkMeter" type="Control" parent="HUD"] +layout_mode = 3 +anchors_preset = 0 offset_left = 66.0 offset_top = 21.0 offset_right = 270.0 offset_bottom = 41.0 -[node name="Block1" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Border" parent="HUD/BlinkMeter" instance=ExtResource("4_r7w8e")] +offset_right = 204.0 + +[node name="Blocks" type="Control" parent="HUD/BlinkMeter"] +anchors_preset = 0 +offset_right = 40.0 +offset_bottom = 40.0 + +[node name="Block1" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 3.0 offset_top = 3.0 @@ -119,7 +138,7 @@ offset_right = 11.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block2" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block2" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 13.0 offset_top = 3.0 @@ -127,7 +146,7 @@ offset_right = 21.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block3" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block3" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 23.0 offset_top = 3.0 @@ -135,7 +154,7 @@ offset_right = 31.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block4" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block4" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 33.0 offset_top = 3.0 @@ -143,7 +162,7 @@ offset_right = 41.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block5" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block5" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 43.0 offset_top = 3.0 @@ -151,7 +170,7 @@ offset_right = 51.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block6" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block6" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 53.0 offset_top = 3.0 @@ -159,7 +178,7 @@ offset_right = 61.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block7" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block7" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 63.0 offset_top = 3.0 @@ -167,7 +186,7 @@ offset_right = 71.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block8" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block8" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 73.0 offset_top = 3.0 @@ -175,7 +194,7 @@ offset_right = 81.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block9" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block9" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 83.0 offset_top = 3.0 @@ -183,7 +202,7 @@ offset_right = 91.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block10" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block10" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 93.0 offset_top = 3.0 @@ -191,7 +210,7 @@ offset_right = 101.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block11" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block11" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 103.0 offset_top = 3.0 @@ -199,7 +218,7 @@ offset_right = 111.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block12" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block12" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 113.0 offset_top = 3.0 @@ -207,7 +226,7 @@ offset_right = 121.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block13" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block13" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 123.0 offset_top = 3.0 @@ -215,7 +234,7 @@ offset_right = 131.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block14" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block14" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 133.0 offset_top = 3.0 @@ -223,7 +242,7 @@ offset_right = 141.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block15" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block15" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 143.0 offset_top = 3.0 @@ -231,7 +250,7 @@ offset_right = 151.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block16" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block16" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 153.0 offset_top = 3.0 @@ -239,7 +258,7 @@ offset_right = 161.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block17" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block17" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 163.0 offset_top = 3.0 @@ -247,7 +266,7 @@ offset_right = 171.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block18" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block18" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 173.0 offset_top = 3.0 @@ -255,7 +274,7 @@ offset_right = 181.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block19" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block19" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 183.0 offset_top = 3.0 @@ -263,7 +282,7 @@ offset_right = 191.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="Block20" type="TextureRect" parent="HUD/BlinkMeter"] +[node name="Block20" type="TextureRect" parent="HUD/BlinkMeter/Blocks"] layout_mode = 0 offset_left = 193.0 offset_top = 3.0 @@ -271,11 +290,21 @@ offset_right = 201.0 offset_bottom = 17.0 texture = ExtResource("5_iwhsa") -[node name="SprintMeter" parent="HUD" instance=ExtResource("4_r7w8e")] +[node name="SprintMeter" type="Control" parent="HUD"] +anchors_preset = 0 offset_left = 66.0 offset_right = 270.0 +offset_bottom = 20.0 -[node name="Block1" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Border" parent="HUD/SprintMeter" instance=ExtResource("4_r7w8e")] +offset_right = 204.0 + +[node name="Blocks" type="Control" parent="HUD/SprintMeter"] +anchors_preset = 0 +offset_right = 40.0 +offset_bottom = 40.0 + +[node name="Block1" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 3.0 offset_top = 3.0 @@ -283,7 +312,7 @@ offset_right = 11.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block2" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block2" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 13.0 offset_top = 3.0 @@ -291,7 +320,7 @@ offset_right = 21.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block3" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block3" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 23.0 offset_top = 3.0 @@ -299,7 +328,7 @@ offset_right = 31.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block4" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block4" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 33.0 offset_top = 3.0 @@ -307,7 +336,7 @@ offset_right = 41.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block5" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block5" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 43.0 offset_top = 3.0 @@ -315,7 +344,7 @@ offset_right = 51.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block6" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block6" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 53.0 offset_top = 3.0 @@ -323,7 +352,7 @@ offset_right = 61.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block7" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block7" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 63.0 offset_top = 3.0 @@ -331,7 +360,7 @@ offset_right = 71.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block8" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block8" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 73.0 offset_top = 3.0 @@ -339,7 +368,7 @@ offset_right = 81.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block9" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block9" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 83.0 offset_top = 3.0 @@ -347,7 +376,7 @@ offset_right = 91.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block10" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block10" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 93.0 offset_top = 3.0 @@ -355,7 +384,7 @@ offset_right = 101.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block11" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block11" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 103.0 offset_top = 3.0 @@ -363,7 +392,7 @@ offset_right = 111.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block12" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block12" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 113.0 offset_top = 3.0 @@ -371,7 +400,7 @@ offset_right = 121.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block13" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block13" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 123.0 offset_top = 3.0 @@ -379,7 +408,7 @@ offset_right = 131.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block14" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block14" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 133.0 offset_top = 3.0 @@ -387,7 +416,7 @@ offset_right = 141.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block15" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block15" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 143.0 offset_top = 3.0 @@ -395,7 +424,7 @@ offset_right = 151.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block16" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block16" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 153.0 offset_top = 3.0 @@ -403,7 +432,7 @@ offset_right = 161.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block17" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block17" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 163.0 offset_top = 3.0 @@ -411,7 +440,7 @@ offset_right = 171.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block18" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block18" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 173.0 offset_top = 3.0 @@ -419,7 +448,7 @@ offset_right = 181.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block19" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block19" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 183.0 offset_top = 3.0 @@ -427,7 +456,7 @@ offset_right = 191.0 offset_bottom = 17.0 texture = ExtResource("6_g44nt") -[node name="Block20" type="TextureRect" parent="HUD/SprintMeter"] +[node name="Block20" type="TextureRect" parent="HUD/SprintMeter/Blocks"] layout_mode = 0 offset_left = 193.0 offset_top = 3.0 diff --git a/src/Player.gd b/src/Player.gd index 5852590..0221833 100644 --- a/src/Player.gd +++ b/src/Player.gd @@ -56,17 +56,87 @@ var ShouldEntitiesFall: bool = true var BlinkTimer = 0 var BLINKFREQ = 0 +var EyeIrritation = 0 +var EyeStuck = 0 +var BlinkEffect = 1.0 +var BlinkEffectTimer = 0 + +var LightBlink = 0 +var LightFlash = 0 var Injuries: float var Rotation: Vector3 = Vector3() +var MenuOpen = false + +@onready var blinkBlocks = $HUD/BlinkMeter/Blocks +@onready var staminaBlocks = $HUD/SprintMeter/Blocks + +const WHITE = Color(1, 1, 1) +const IRRITATED_RED = Color(0.78431372549, 0, 0) + func _process(delta: float) -> void: + + if Playable: + if Input.is_action_just_pressed("player_blink"): + BlinkTimer = 0 + if Input.is_action_pressed("player_blink") and BlinkTimer < -10: + BlinkTimer = -10 + + var darkA = 0.0 + if not MenuOpen: + if BlinkTimer < 0: + if BlinkTimer > -5: + darkA = max(darkA, sin(abs(BlinkTimer * 18.0))) + elif BlinkTimer > -15: + darkA = 1.0 + else: + darkA = max(darkA, abs(sin(BlinkTimer * 18.0))) + + if BlinkTimer <= -20: + # Randomizes the frequency of blinking. Scales with difficulty. + #Select SelectedDifficulty\otherFactors + # Case EASY + BLINKFREQ = randi_range(490,700) + # Case NORMAL + # BLINKFREQ = Rnd(455,665) + # Case HARD + # BLINKFREQ = Rnd(420,630) + BlinkTimer = BLINKFREQ + + BlinkTimer = BlinkTimer - Global.FPSfactor + else: + BlinkTimer = BlinkTimer - Global.FPSfactor * 0.6 * BlinkEffect + if EyeIrritation > 0: + BlinkTimer = BlinkTimer - min(EyeIrritation / 100.0 + 1.0, 4.0) * Global.FPSfactor + + darkA = max(darkA, 0.0) + + EyeIrritation = max(0, EyeIrritation - Global.FPSfactor) + + if BlinkEffectTimer > 0: + BlinkEffectTimer = BlinkEffectTimer - (Global.FPSfactor / 70) + else: + if BlinkEffect != 1.0: + BlinkEffect = 1.0 + + LightBlink = max(LightBlink - (Global.FPSfactor / 35.0), 0) + if LightBlink > 0: + darkA = min(max(darkA, LightBlink * randf_range(0.3, 0.8)), 1.0) + + # KEEP AT END OF IF + $HUD/Dark.color.a = darkA + var width = 204 var height = 20 var x = 80 var y = Hud.size.y - 95 + if EyeIrritation > 0: + blinkIconBG.color = IRRITATED_RED + else: + blinkIconBG.color = WHITE blinkIconBG.position.x = x - 51 blinkIconBG.position.y = y - 1 blinkBar.position.x = x @@ -80,10 +150,10 @@ func _process(delta: float) -> void: var barAmount = int(((width - 2) * (BlinkTimer / (BLINKFREQ))) / 10) for i in int(((width - 2) * (BlinkTimer / (BLINKFREQ))) / 10): - blinkBar.get_child(i).visible = true + blinkBlocks.get_child(i).visible = true for i in range(barAmount, 20): - blinkBar.get_child(i).visible = false + blinkBlocks.get_child(i).visible = false var Sprint = 1.0 var Speed = 0.018