fix controller support and add in game menu
This commit is contained in:
parent
9bd94304fe
commit
8c9060147f
10 changed files with 295 additions and 94 deletions
27
Scripts/InGameMenu.gd
Normal file
27
Scripts/InGameMenu.gd
Normal file
|
@ -0,0 +1,27 @@
|
|||
extends Control
|
||||
|
||||
|
||||
func _on_exit_button_pressed() -> void:
|
||||
get_tree().quit()
|
||||
|
||||
|
||||
func _on_exit_menu_button_pressed() -> void:
|
||||
get_tree().change_scene_to_file("res://Scenes/GUI/MainMenu.tscn")
|
||||
|
||||
|
||||
func _on_flow_controls_button_pressed() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_cosmetics_button_pressed() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_load_show_button_pressed() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_return_button_pressed() -> void:
|
||||
get_node("../").interact = true
|
||||
get_node("../").capture_mouse()
|
||||
visible = false
|
1
Scripts/InGameMenu.gd.uid
Normal file
1
Scripts/InGameMenu.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://pwg37gka2qr4
|
|
@ -5,6 +5,7 @@ func _ready():
|
|||
randomize()
|
||||
$VersionLabel.text = "Pneumatic Plaything v%s" % ProjectSettings.get_setting("application/config/version")
|
||||
$Backgrounds.get_child(randi() % $Backgrounds.get_child_count()).visible = true
|
||||
$Buttons/EditorButton.grab_focus()
|
||||
|
||||
var moddir = DirAccess.open("user://Mods")
|
||||
if moddir == null:
|
||||
|
|
|
@ -11,6 +11,8 @@ var acceleration: float = 100 # m/s^2
|
|||
var jump_height: float = 1 # m
|
||||
var camera_sens: float = 3
|
||||
|
||||
var interact: bool = true
|
||||
|
||||
var jumping: bool = false
|
||||
var crouched: bool = false
|
||||
var running: bool = false
|
||||
|
@ -31,36 +33,54 @@ func _ready() -> void:
|
|||
capture_mouse()
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseMotion:
|
||||
look_dir = event.relative * 0.001
|
||||
if mouse_captured: _rotate_camera()
|
||||
if (interact):
|
||||
if event is InputEventMouseMotion:
|
||||
look_dir = event.relative * 0.001
|
||||
if mouse_captured: _rotate_camera()
|
||||
if event.is_action_pressed(&"fullscreen"):
|
||||
if (!DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN):
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
||||
else:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
|
||||
elif event.is_action_pressed(&"freeroam_open_menu"):
|
||||
if (!interact):
|
||||
interact = true
|
||||
capture_mouse()
|
||||
$InGameMenu.visible = false
|
||||
else:
|
||||
interact = false
|
||||
release_mouse()
|
||||
$InGameMenu.visible = true
|
||||
$InGameMenu/Buttons/ReturnButton.grab_focus()
|
||||
pass
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if Input.is_action_just_pressed(&"freeroam_jump"): jumping = true
|
||||
elif Input.is_action_just_pressed(&"freeroam_crouch"):
|
||||
$CShape.shape.height = 1.0
|
||||
$Camera.position.y = 1.0
|
||||
if (running): speed = SPEED_CROUCH_RUN
|
||||
else: speed = SPEED_CROUCHED
|
||||
crouched = true
|
||||
elif Input.is_action_just_released(&"freeroam_crouch"):
|
||||
$CShape.shape.height = 1.8
|
||||
$Camera.position.y = 1.7
|
||||
if (running): speed = SPEED_RUNNING
|
||||
else: speed = SPEED_BASE
|
||||
crouched = false
|
||||
elif Input.is_action_just_pressed(&"freeroam_run"):
|
||||
if (crouched): speed = SPEED_CROUCH_RUN
|
||||
else: speed = SPEED_RUNNING
|
||||
running = true
|
||||
elif Input.is_action_just_released(&"freeroam_run"):
|
||||
if (crouched): speed = SPEED_CROUCHED
|
||||
else: speed = SPEED_BASE
|
||||
running = false
|
||||
|
||||
if mouse_captured: _handle_joypad_camera_rotation(delta)
|
||||
velocity = _walk(delta) + _gravity(delta) + _jump(delta)
|
||||
move_and_slide()
|
||||
if (interact):
|
||||
if Input.is_action_just_pressed(&"freeroam_jump"): jumping = true
|
||||
elif Input.is_action_just_pressed(&"freeroam_crouch"):
|
||||
$CShape.shape.height = 1.0
|
||||
$Camera.position.y = 1.0
|
||||
if (running): speed = SPEED_CROUCH_RUN
|
||||
else: speed = SPEED_CROUCHED
|
||||
crouched = true
|
||||
elif Input.is_action_just_released(&"freeroam_crouch"):
|
||||
$CShape.shape.height = 1.8
|
||||
$Camera.position.y = 1.7
|
||||
if (running): speed = SPEED_RUNNING
|
||||
else: speed = SPEED_BASE
|
||||
crouched = false
|
||||
elif Input.is_action_just_pressed(&"freeroam_run"):
|
||||
if (crouched): speed = SPEED_CROUCH_RUN
|
||||
else: speed = SPEED_RUNNING
|
||||
running = true
|
||||
elif Input.is_action_just_released(&"freeroam_run"):
|
||||
if (crouched): speed = SPEED_CROUCHED
|
||||
else: speed = SPEED_BASE
|
||||
running = false
|
||||
|
||||
if mouse_captured: _handle_joypad_camera_rotation(delta)
|
||||
velocity = _walk(delta) + _gravity(delta) + _jump(delta)
|
||||
move_and_slide()
|
||||
|
||||
func capture_mouse() -> void:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://cdk6hwb4hi2wc"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://cdk6hwb4hi2wc"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b0c02p6ckmpdq" path="res://Scripts/Player/player.gd" id="1_2f8j2"]
|
||||
[ext_resource type="PackedScene" uid="uid://cd67bfok34xhy" path="res://Scenes/GUI/InGameMenu.tscn" id="2_0s4r2"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_3rsb5"]
|
||||
radius = 0.3
|
||||
|
@ -17,3 +18,6 @@ debug_color = Color(0.141176, 0.427451, 0.92549, 0.784314)
|
|||
[node name="Camera" type="Camera3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.7, 0)
|
||||
fov = 80.0
|
||||
|
||||
[node name="InGameMenu" parent="." instance=ExtResource("2_0s4r2")]
|
||||
visible = false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue