21 lines
651 B
GDScript
21 lines
651 B
GDScript
# scripts/game.gd — autoloaded as "Game"
|
|
extends Node
|
|
|
|
const BOAT_SCENE := preload("res://boat.tscn")
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
if event.is_action_pressed("restart"):
|
|
get_tree().reload_current_scene()
|
|
if event.is_action_pressed(&"debug_spawn_boat"):
|
|
_debug_spawn_boat()
|
|
|
|
func _debug_spawn_boat() -> void:
|
|
var focus := get_tree().get_first_node_in_group(&"boats") as Node3D
|
|
var boat: Boat = BOAT_SCENE.instantiate()
|
|
|
|
if focus != null:
|
|
boat.position = focus.global_position + focus.global_basis.x * 10.0 + Vector3.UP * 2.0
|
|
else:
|
|
boat.position = Vector3(0, 3, 0)
|
|
get_tree().current_scene.add_child(boat, true)
|