This repository has been archived on 2023-12-19. You can view files and clone it, but cannot push or open issues or pull requests.
MUR/scripts/player/human_controls.gd

53 lines
1.7 KiB
GDScript

extends Spatial
var player:Player
onready var camera:InterpolatedCamera = get_node("camera")
onready var ingame_menu:Spatial = find_node("ingame_menu")
func _physics_process(delta):
if is_network_master() && player != null:
if Input.is_action_just_pressed("controls_menu"):
ingame_menu.set_visible(not ingame_menu.is_visible_in_tree())
if player.is_out:
camera.set_speed(0.1)
if player.timer.get_time_left() > 0:
get_node("hud/reset").set_text(str(int(player.timer.get_time_left()) + 1))
else:
get_node("hud/reset").set_text(tr("RESET"))
if Input.is_action_pressed("controls_reset"):
if player.reset():
camera.set_speed(10)
get_node("hud/reset").set_text("")
elif not ingame_menu.is_visible_in_tree():
if Input.is_action_pressed("controls_thrust"):
player.thrust = 1
elif Input.is_action_pressed("controls_break"):
player.thrust = -1
else:
player.thrust = 0
get_node("hud/speed_slider").set_value(player.current_speed * 1000)
if Input.is_action_pressed("debug_camera_1"):
set_debug_camera(0)
elif Input.is_action_pressed("debug_camera_2"):
set_debug_camera(1)
elif Input.is_action_pressed("debug_camera_3"):
set_debug_camera(2)
elif Input.is_action_pressed("debug_camera_4"):
set_debug_camera(3)
func set_player(path:String):
player = get_node(path)
get_node("inventory").set_player(player)
camera.set_target_path(player.find_node("CameraTarget").get_path())
camera.set_interpolation_enabled(true)
camera.set_speed(10)
func set_debug_camera(idx):
if idx < gamestate.game.get_node("players").get_child_count():
camera.set_target_path(gamestate.game.get_node("players").get_child(idx).find_node("CameraTarget").get_path())