Files
A Thousand Ships 0343cedd48 General proofreading (#1262)
* General proofreading for grammar and spelling
* General formatting
* Addition of appropriate literals where appropriate, i.e. `&"foo"` for `StringName` cases and `^"foo/bar"` for `NodePath` cases
2025-10-11 01:39:59 -07:00

48 lines
1.5 KiB
GDScript

extends Node
@export var mob_scene: PackedScene
func _ready():
if RenderingServer.get_current_rendering_method() == "gl_compatibility":
# Use PCF13 shadow filtering to improve quality (Medium maps to PCF5 instead).
RenderingServer.directional_soft_shadow_filter_set_quality(RenderingServer.SHADOW_QUALITY_SOFT_HIGH)
# Darken the light's energy to compensate for sRGB blending (without affecting sky rendering).
$DirectionalLight3D.sky_mode = DirectionalLight3D.SKY_MODE_SKY_ONLY
var new_light: DirectionalLight3D = $DirectionalLight3D.duplicate()
new_light.light_energy = 0.35
new_light.sky_mode = DirectionalLight3D.SKY_MODE_LIGHT_ONLY
add_child(new_light)
$UserInterface/Retry.hide()
func _unhandled_input(event):
if event.is_action_pressed(&"ui_accept") and $UserInterface/Retry.visible:
get_tree().reload_current_scene()
func _on_mob_timer_timeout():
# Create a new instance of the Mob scene.
var mob = mob_scene.instantiate()
# Choose a random location on the SpawnPath.
var mob_spawn_location = get_node(^"SpawnPath/SpawnLocation")
mob_spawn_location.progress_ratio = randf()
# Communicate the spawn location and the player's location to the mob.
var player_position = $Player.position
mob.initialize(mob_spawn_location.position, player_position)
# Spawn the mob by adding it to the Main scene.
add_child(mob)
# We connect the mob to the score label to update the score upon squashing a mob.
mob.squashed.connect($UserInterface/ScoreLabel._on_Mob_squashed)
func _on_player_hit():
$MobTimer.stop()
$UserInterface/Retry.show()