Added trailer and ability to disable player

This commit is contained in:
Paul Black 2023-05-05 13:05:54 -06:00
parent 537c85d017
commit 580d0a75fc
7 changed files with 161 additions and 141 deletions

BIN
.DS_Store vendored

Binary file not shown.

View file

@ -48,145 +48,147 @@ func _ready():
menuScene.visible = false
func _unhandled_input(event):
if is_multiplayer_authority():
Global.selfTeddy = selfTeddy
if event is InputEventMouseButton:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
elif event.is_action_pressed("ui_cancel"):
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
mousesense = Global.mouseSensitivity
if event is InputEventMouseMotion:
neck.rotate_y(-event.relative.x * mousesense)
camera.rotate_x(-event.relative.y * mousesense)
## FOR CONTROLLERS
if event is InputEventJoypadMotion:
var cam_dir = Input.is_action_pressed("cam_left") or Input.is_action_pressed("cam_right") or Input.is_action_pressed("cam_up") or Input.is_action_pressed("cam_down")
if cam_dir:
controllerAxisValue_x = -event.get_axis_value() * mousesense
controllerAxisValue_y = -event.get_axis_value() * mousesense
##################
# Clamps the camera
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-90), deg_to_rad(90))
if Input.is_action_just_pressed("menu"):
if menuScene.visible == false:
menuScene.visible = true
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
elif menuScene.visible == true:
menuScene.visible = false
if not Global.playerDisable:
if is_multiplayer_authority():
Global.selfTeddy = selfTeddy
if event is InputEventMouseButton:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
elif event.is_action_pressed("ui_cancel"):
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
mousesense = Global.mouseSensitivity
if event is InputEventMouseMotion:
neck.rotate_y(-event.relative.x * mousesense)
camera.rotate_x(-event.relative.y * mousesense)
## FOR CONTROLLERS
if event is InputEventJoypadMotion:
var cam_dir = Input.is_action_pressed("cam_left") or Input.is_action_pressed("cam_right") or Input.is_action_pressed("cam_up") or Input.is_action_pressed("cam_down")
if cam_dir:
controllerAxisValue_x = -event.get_axis_value() * mousesense
controllerAxisValue_y = -event.get_axis_value() * mousesense
##################
# Clamps the camera
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-90), deg_to_rad(90))
if Input.is_action_just_pressed("menu"):
if menuScene.visible == false:
menuScene.visible = true
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
elif menuScene.visible == true:
menuScene.visible = false
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _physics_process(delta):
if is_multiplayer_authority():
# This variable gets set my the death scene, so we know the player needs to be respawned
if Global.playerPleaseRespawn == true:
get_node(teddyCollider).disabled = false
var ramMax = Global.spawnCoords_x.size() - 1
var ramnum = RandomNumberGenerator.new().randi_range(0, ramMax)
print("ramnum: ", ramnum)
print("ramMax: ", ramMax)
position.x = Global.spawnCoords_x[ramnum] #Set player X
position.y = Global.spawnCoords_y[ramnum] #Set player Y
position.z = Global.spawnCoords_z[ramnum] #Set player Z
await get_tree().create_timer(0.5).timeout
Global.reset_variables()
ranRemovePlayer = false
rpc("teddy_dead_nomore")
## If player falls off the map, kill them!
if velocity.y < Global.playerYDeath:
Global.playerHealth = 0
if Global.playerHealth <= 0:
Global.player_dead()
if ranRemovePlayer == false:
if Global.playerAlive == false:
ranRemovePlayer = true
get_node(teddyCollider).disabled = true
rpc("remove_dead_teddy")
if Global.playerAlive:
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
# Handle Jump.
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMP_VELOCITY
var cam_dir = Input.is_action_pressed("cam_left") or Input.is_action_pressed("cam_right") or Input.is_action_pressed("cam_up") or Input.is_action_pressed("cam_down")
if cam_dir:
if Input.is_action_pressed("cam_left"):
controllerAxisValue_x += 1 * mousesense
if Input.is_action_pressed("cam_right"):
controllerAxisValue_x -= 1 * mousesense
if Input.is_action_pressed("cam_up"):
controllerAxisValue_y += 1 * mousesense
if Input.is_action_pressed("cam_down"):
controllerAxisValue_y -= 1 * mousesense
neck.rotate_y(controllerAxisValue_x)
camera.rotate_x(controllerAxisValue_y)
else:
controllerAxisValue_x = 0
controllerAxisValue_y = 0
var input_dir = Input.get_vector("player_left", "player_right", "player_forward", "player_backward")
var direction = (neck.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if input_dir:
if not Input.is_action_pressed("sprint"):
rpc("teddy_play_anim", "walk")
else:
rpc("teddy_play_anim", "idle")
if Input.is_action_pressed("sprint"):
if Global.fatigue > 5:
speed = SPEED * 2
if Global.fatigue < 5:
speed = SPEED
if Input.is_action_pressed("sprint"):
rpc("teddy_play_anim", "run")
elif Global.fatigue > 5:
speed = SPEED
if Input.is_action_just_released("sprint"):
speed = SPEED
if direction:
velocity.x = direction.x * speed
velocity.z = direction.z * speed
else:
velocity.x = move_toward(velocity.x, 0, speed)
velocity.z = move_toward(velocity.z, 0, speed)
if Global.playerDead:
velocity.x = 0
velocity.z = 0
if Input.is_action_just_pressed("shoot") and Global.roundInSession and menuScene.visible == false:
if menuOpen == false:
if Global.multiplayerCurrent == true:
rpc("shoot_bullet")
shoot_bullet()
else:
shoot_bullet()
if Input.is_action_just_pressed("console"):
var scene_trs = load("res://scenes/console.tscn")
var scene = scene_trs.instantiate()
if not Global.consoleOpen:
Global.consoleOpen = true
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
add_child(scene)
elif Global.consoleOpen:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
Global.consoleOpen = false # We remove the scene in console.gd
if Global.roundInSession == false:
if teddyAuthority == 1:
if Global.HUDStartLabelText == "":
Global.HUDStartLabelText = "PRESS ENTER/RETURN TO START THE ROUND"
if Input.is_action_just_pressed("start_game"):
if not Global.playerDisable:
if is_multiplayer_authority():
# This variable gets set my the death scene, so we know the player needs to be respawned
if Global.playerPleaseRespawn == true:
get_node(teddyCollider).disabled = false
var ramMax = Global.spawnCoords_x.size() - 1
var ramnum = RandomNumberGenerator.new().randi_range(0, ramMax)
print("ramnum: ", ramnum)
print("ramMax: ", ramMax)
position.x = Global.spawnCoords_x[ramnum] #Set player X
position.y = Global.spawnCoords_y[ramnum] #Set player Y
position.z = Global.spawnCoords_z[ramnum] #Set player Z
await get_tree().create_timer(0.5).timeout
Global.reset_variables()
ranRemovePlayer = false
rpc("teddy_dead_nomore")
## If player falls off the map, kill them!
if velocity.y < Global.playerYDeath:
Global.playerHealth = 0
if Global.playerHealth <= 0:
Global.player_dead()
if ranRemovePlayer == false:
if Global.playerAlive == false:
ranRemovePlayer = true
get_node(teddyCollider).disabled = true
rpc("remove_dead_teddy")
if Global.playerAlive:
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
# Handle Jump.
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMP_VELOCITY
var cam_dir = Input.is_action_pressed("cam_left") or Input.is_action_pressed("cam_right") or Input.is_action_pressed("cam_up") or Input.is_action_pressed("cam_down")
if cam_dir:
if Input.is_action_pressed("cam_left"):
controllerAxisValue_x += 1 * mousesense
if Input.is_action_pressed("cam_right"):
controllerAxisValue_x -= 1 * mousesense
if Input.is_action_pressed("cam_up"):
controllerAxisValue_y += 1 * mousesense
if Input.is_action_pressed("cam_down"):
controllerAxisValue_y -= 1 * mousesense
neck.rotate_y(controllerAxisValue_x)
camera.rotate_x(controllerAxisValue_y)
else:
controllerAxisValue_x = 0
controllerAxisValue_y = 0
var input_dir = Input.get_vector("player_left", "player_right", "player_forward", "player_backward")
var direction = (neck.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if input_dir:
if not Input.is_action_pressed("sprint"):
rpc("teddy_play_anim", "walk")
else:
rpc("teddy_play_anim", "idle")
if Input.is_action_pressed("sprint"):
if Global.fatigue > 5:
speed = SPEED * 2
if Global.fatigue < 5:
speed = SPEED
if Input.is_action_pressed("sprint"):
rpc("teddy_play_anim", "run")
elif Global.fatigue > 5:
speed = SPEED
if Input.is_action_just_released("sprint"):
speed = SPEED
if direction:
velocity.x = direction.x * speed
velocity.z = direction.z * speed
else:
velocity.x = move_toward(velocity.x, 0, speed)
velocity.z = move_toward(velocity.z, 0, speed)
if Global.playerDead:
velocity.x = 0
velocity.z = 0
if Input.is_action_just_pressed("shoot") and Global.roundInSession and menuScene.visible == false:
if menuOpen == false:
if Global.multiplayerCurrent == true:
rpc("shoot_bullet")
shoot_bullet()
else:
shoot_bullet()
if Input.is_action_just_pressed("console"):
var scene_trs = load("res://scenes/console.tscn")
var scene = scene_trs.instantiate()
if not Global.consoleOpen:
Global.consoleOpen = true
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
add_child(scene)
elif Global.consoleOpen:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
Global.consoleOpen = false # We remove the scene in console.gd
if Global.roundInSession == false:
if teddyAuthority == 1:
Global.roundInSession = true
rpc("round_start")
if Global.spawnCotton == true:
Global.spawnCotton = false
rpc("spawn_cotton")
spawn_cotton()
rpc("remote_set_position", global_position, $CollisionShape3D/Neck/Teddy.global_rotation.y, $CollisionShape3D/Neck/Camera3D/BulletGenerator.global_position, $CollisionShape3D/Neck/Camera3D/BulletGenerator.global_rotation)
rpc("set_teddy_name", teddyName, Global.playerName)
move_and_slide()
if Global.HUDStartLabelText == "":
Global.HUDStartLabelText = "PRESS ENTER/RETURN TO START THE ROUND"
if Input.is_action_just_pressed("start_game"):
if teddyAuthority == 1:
Global.roundInSession = true
rpc("round_start")
if Global.spawnCotton == true:
Global.spawnCotton = false
rpc("spawn_cotton")
spawn_cotton()
rpc("remote_set_position", global_position, $CollisionShape3D/Neck/Teddy.global_rotation.y, $CollisionShape3D/Neck/Camera3D/BulletGenerator.global_position, $CollisionShape3D/Neck/Camera3D/BulletGenerator.global_rotation)
rpc("set_teddy_name", teddyName, Global.playerName)
move_and_slide()
@rpc("any_peer", "unreliable")
func remote_set_position(authority_position, teddy_rotation, bulletgenerator_position, bulletgenerator_rotation):

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=10 format=3 uid="uid://dkokyp5lwhks4"]
[gd_scene load_steps=11 format=3 uid="uid://dkokyp5lwhks4"]
[ext_resource type="Script" path="res://scripts/maps/tutorial.gd" id="1_40ws8"]
[ext_resource type="PackedScene" uid="uid://dp1q51kvd8uow" path="res://scenes/Teddy.tscn" id="1_081si"]
@ -6,6 +6,7 @@
[ext_resource type="PackedScene" uid="uid://y3fffh5cdbks" path="res://scenes/AI.tscn" id="4_fttoe"]
[ext_resource type="PackedScene" uid="uid://c1y6p4m0sktfj" path="res://scenes/farmland-map.tscn" id="5_imhi6"]
[ext_resource type="PackedScene" uid="uid://buyvavyuwmccw" path="res://joystick/virtual_joystick.tscn" id="6_p8th3"]
[ext_resource type="VideoStream" path="res://videos/trailer.ogv" id="7_4deue"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_i5hsu"]
sky_top_color = Color(1, 1, 1, 1)
@ -42,3 +43,12 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.21775, 1.22338, -28.4151)
[node name="Farmland" parent="." instance=ExtResource("5_imhi6")]
[node name="Virtual joystick" parent="." instance=ExtResource("6_p8th3")]
[node name="VideoStreamPlayer" type="VideoStreamPlayer" parent="."]
offset_right = 1152.0
offset_bottom = 648.0
mouse_filter = 2
mouse_force_pass_scroll_events = false
stream = ExtResource("7_4deue")
autoplay = true
expand = true

View file

@ -31,11 +31,12 @@ func _process(delta):
restart_round()
rpc("restart_round")
if Global.mapName == "Tutorial":
tutorial()
if not Global.tutorialComplete:
$musicPanel.visible = false
if Global.iAmSpecial and Global.gamemode == "Runner":
rpc("sync_runner_hp", $Health.value)
if not Global.playerDisable:
tutorial()
if not Global.tutorialComplete:
$musicPanel.visible = false
if Global.iAmSpecial and Global.gamemode == "Runner":
rpc("sync_runner_hp", $Health.value)
if Global.musicUpdated == true:
Global.musicUpdated = false
$musicPanel/playingLabel.text = Global.musicName

View file

@ -48,6 +48,7 @@ var iAmDeadAndInnocent = false # Used to keep track of when an innocent dies in
var spawnCotton = false # bullet will change this to true
var addedMenuScene = false # Used for teddy.gd, fixes multiple menu bug
var tutorialCompleted = false # Used in the save file, to know if a play should go to tutorial first
var playerDisable = false # Can be used to disable the player
func _process(delta):
#if not spawnCoordsInitalized:

View file

@ -11,6 +11,12 @@ func _ready():
func _process(delta):
if Input.is_action_just_released("menu"):
$VideoStreamPlayer.stop()
if $VideoStreamPlayer.is_playing():
Global.playerDisable = true
else:
Global.playerDisable = false
if Global.tutorialComplete:
if audio_stream_player.playing == false:
var randomnum = RandomNumberGenerator.new().randi_range(0, 6)

BIN
videos/trailer.ogv Normal file

Binary file not shown.