Files
godot-4-3d-tutorial/main.gd
2024-06-12 17:51:29 +02:00

32 lines
791 B
GDScript

extends Node
@export var mob_scene: PackedScene
func _ready():
$UserInterface/Retry.hide()
Engine.max_fps = 144
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
func _on_mob_timer_timeout():
var mob = mob_scene.instantiate()
var mob_spawn_location = get_node("SpawnPath/SpawnLocation")
mob_spawn_location.progress_ratio = randf()
var player_position = $Player.position
mob.initialize(mob_spawn_location.position, player_position)
add_child(mob)
mob.squashed.connect($UserInterface/ScoreLabel._on_mob_squashed.bind())
func _on_player_hit():
$MobTimer.stop()
$UserInterface/Retry.show()
Engine.max_fps = 30
func _unhandled_input(event):
if event.is_action_pressed("ui_accept") and $UserInterface/Retry.visible:
get_tree().reload_current_scene()