Added 'pausing' and input capturing

This commit is contained in:
Jan 2020-06-17 22:38:26 +02:00
parent a43524999b
commit bf510a7c9e
4 changed files with 20 additions and 2 deletions

11
Game.gd
View file

@ -5,16 +5,25 @@ export var is_server = true
export var SERVER_PORT = 9999
export(String, "172.28.162.191", "172.28.166.24", "127.0.0.1") var SERVER_IP = "172.28.162.191"
export var MAX_PLAYERS = 10
export (String, "MENU", "PLAYING") var GAME_MODE = "MENU"
var player_scene = preload("res://Player.tscn")
# Called when the node enters the scene tree for the first time.
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
initialize()
debug_connection_status()
func _input(event):
if event.is_action_pressed("ToggleMenu"):
if GAME_MODE == "PLAYING":
GAME_MODE = "MENU"
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
else:
GAME_MODE = "PLAYING"
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func debug_connection_status():
if (get_tree().network_peer.get_connection_status() == NetworkedMultiplayerPeer.CONNECTION_CONNECTING):
print("We are trying to connect")

View file

@ -5,7 +5,6 @@
[node name="Game" type="Spatial"]
script = ExtResource( 2 )
SERVER_IP = "127.0.0.1"
[node name="Level" parent="." instance=ExtResource( 3 )]

View file

@ -17,6 +17,8 @@ onready var health = max_health
onready var camera = $Camera
onready var debug = $Debug
onready var game = get_parent().get_parent()
onready var crosshair_pos = $CrosshairContainer.rect_size / 2
var velocity = Vector3.ZERO
@ -112,6 +114,9 @@ func _input(event):
if str(get_tree().get_network_unique_id()) != name:
return
if game.GAME_MODE != "PLAYING":
return
# Moouselook
if event is InputEventMouseMotion:
var rel = event.relative

View file

@ -56,6 +56,11 @@ WeaponSecondary={
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":2,"pressed":false,"doubleclick":false,"script":null)
]
}
ToggleMenu={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"unicode":0,"echo":false,"script":null)
]
}
[rendering]