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 menuScene.visible = false
func _unhandled_input(event): func _unhandled_input(event):
if is_multiplayer_authority(): if not Global.playerDisable:
Global.selfTeddy = selfTeddy if is_multiplayer_authority():
if event is InputEventMouseButton: Global.selfTeddy = selfTeddy
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) if event is InputEventMouseButton:
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) 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): func _physics_process(delta):
if is_multiplayer_authority(): if not Global.playerDisable:
# This variable gets set my the death scene, so we know the player needs to be respawned if is_multiplayer_authority():
if Global.playerPleaseRespawn == true: # This variable gets set my the death scene, so we know the player needs to be respawned
get_node(teddyCollider).disabled = false if Global.playerPleaseRespawn == true:
var ramMax = Global.spawnCoords_x.size() - 1 get_node(teddyCollider).disabled = false
var ramnum = RandomNumberGenerator.new().randi_range(0, ramMax) var ramMax = Global.spawnCoords_x.size() - 1
print("ramnum: ", ramnum) var ramnum = RandomNumberGenerator.new().randi_range(0, ramMax)
print("ramMax: ", ramMax) print("ramnum: ", ramnum)
position.x = Global.spawnCoords_x[ramnum] #Set player X print("ramMax: ", ramMax)
position.y = Global.spawnCoords_y[ramnum] #Set player Y position.x = Global.spawnCoords_x[ramnum] #Set player X
position.z = Global.spawnCoords_z[ramnum] #Set player Z position.y = Global.spawnCoords_y[ramnum] #Set player Y
await get_tree().create_timer(0.5).timeout position.z = Global.spawnCoords_z[ramnum] #Set player Z
Global.reset_variables() await get_tree().create_timer(0.5).timeout
ranRemovePlayer = false Global.reset_variables()
rpc("teddy_dead_nomore") ranRemovePlayer = false
rpc("teddy_dead_nomore")
## If player falls off the map, kill them!
if velocity.y < Global.playerYDeath: ## If player falls off the map, kill them!
Global.playerHealth = 0 if velocity.y < Global.playerYDeath:
if Global.playerHealth <= 0: Global.playerHealth = 0
Global.player_dead() if Global.playerHealth <= 0:
Global.player_dead()
if ranRemovePlayer == false:
if Global.playerAlive == false: if ranRemovePlayer == false:
ranRemovePlayer = true if Global.playerAlive == false:
get_node(teddyCollider).disabled = true ranRemovePlayer = true
rpc("remove_dead_teddy") get_node(teddyCollider).disabled = true
rpc("remove_dead_teddy")
if Global.playerAlive:
# Add the gravity. if Global.playerAlive:
if not is_on_floor(): # Add the gravity.
velocity.y -= gravity * delta if not is_on_floor():
# Handle Jump. velocity.y -= gravity * delta
if Input.is_action_just_pressed("jump") and is_on_floor(): # Handle Jump.
velocity.y = JUMP_VELOCITY if Input.is_action_just_pressed("jump") and is_on_floor():
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") velocity.y = JUMP_VELOCITY
if cam_dir: 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 Input.is_action_pressed("cam_left"): if cam_dir:
controllerAxisValue_x += 1 * mousesense if Input.is_action_pressed("cam_left"):
if Input.is_action_pressed("cam_right"): controllerAxisValue_x += 1 * mousesense
controllerAxisValue_x -= 1 * mousesense if Input.is_action_pressed("cam_right"):
if Input.is_action_pressed("cam_up"): controllerAxisValue_x -= 1 * mousesense
controllerAxisValue_y += 1 * mousesense if Input.is_action_pressed("cam_up"):
if Input.is_action_pressed("cam_down"): controllerAxisValue_y += 1 * mousesense
controllerAxisValue_y -= 1 * mousesense if Input.is_action_pressed("cam_down"):
neck.rotate_y(controllerAxisValue_x) controllerAxisValue_y -= 1 * mousesense
camera.rotate_x(controllerAxisValue_y) neck.rotate_y(controllerAxisValue_x)
else: camera.rotate_x(controllerAxisValue_y)
controllerAxisValue_x = 0 else:
controllerAxisValue_y = 0 controllerAxisValue_x = 0
var input_dir = Input.get_vector("player_left", "player_right", "player_forward", "player_backward") controllerAxisValue_y = 0
var direction = (neck.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized() var input_dir = Input.get_vector("player_left", "player_right", "player_forward", "player_backward")
if input_dir: var direction = (neck.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if not Input.is_action_pressed("sprint"): if input_dir:
rpc("teddy_play_anim", "walk") if not Input.is_action_pressed("sprint"):
else: rpc("teddy_play_anim", "walk")
rpc("teddy_play_anim", "idle") else:
if Input.is_action_pressed("sprint"): rpc("teddy_play_anim", "idle")
if Global.fatigue > 5: if Input.is_action_pressed("sprint"):
speed = SPEED * 2 if Global.fatigue > 5:
if Global.fatigue < 5: speed = SPEED * 2
speed = SPEED if Global.fatigue < 5:
if Input.is_action_pressed("sprint"): speed = SPEED
rpc("teddy_play_anim", "run") if Input.is_action_pressed("sprint"):
elif Global.fatigue > 5: rpc("teddy_play_anim", "run")
speed = SPEED elif Global.fatigue > 5:
if Input.is_action_just_released("sprint"): speed = SPEED
speed = SPEED if Input.is_action_just_released("sprint"):
if direction: speed = SPEED
velocity.x = direction.x * speed if direction:
velocity.z = direction.z * speed velocity.x = direction.x * speed
else: velocity.z = direction.z * speed
velocity.x = move_toward(velocity.x, 0, speed) else:
velocity.z = move_toward(velocity.z, 0, speed) velocity.x = move_toward(velocity.x, 0, speed)
if Global.playerDead: velocity.z = move_toward(velocity.z, 0, speed)
velocity.x = 0 if Global.playerDead:
velocity.z = 0 velocity.x = 0
if Input.is_action_just_pressed("shoot") and Global.roundInSession and menuScene.visible == false: velocity.z = 0
if menuOpen == false: if Input.is_action_just_pressed("shoot") and Global.roundInSession and menuScene.visible == false:
if Global.multiplayerCurrent == true: if menuOpen == false:
rpc("shoot_bullet") if Global.multiplayerCurrent == true:
shoot_bullet() rpc("shoot_bullet")
else: shoot_bullet()
shoot_bullet() else:
if Input.is_action_just_pressed("console"): shoot_bullet()
var scene_trs = load("res://scenes/console.tscn") if Input.is_action_just_pressed("console"):
var scene = scene_trs.instantiate() var scene_trs = load("res://scenes/console.tscn")
if not Global.consoleOpen: var scene = scene_trs.instantiate()
Global.consoleOpen = true if not Global.consoleOpen:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) Global.consoleOpen = true
add_child(scene) Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
elif Global.consoleOpen: add_child(scene)
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) elif Global.consoleOpen:
Global.consoleOpen = false # We remove the scene in console.gd Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
if Global.roundInSession == false: Global.consoleOpen = false # We remove the scene in console.gd
if teddyAuthority == 1: if Global.roundInSession == false:
if Global.HUDStartLabelText == "":
Global.HUDStartLabelText = "PRESS ENTER/RETURN TO START THE ROUND"
if Input.is_action_just_pressed("start_game"):
if teddyAuthority == 1: if teddyAuthority == 1:
Global.roundInSession = true if Global.HUDStartLabelText == "":
rpc("round_start") Global.HUDStartLabelText = "PRESS ENTER/RETURN TO START THE ROUND"
if Global.spawnCotton == true: if Input.is_action_just_pressed("start_game"):
Global.spawnCotton = false if teddyAuthority == 1:
rpc("spawn_cotton") Global.roundInSession = true
spawn_cotton() rpc("round_start")
rpc("remote_set_position", global_position, $CollisionShape3D/Neck/Teddy.global_rotation.y, $CollisionShape3D/Neck/Camera3D/BulletGenerator.global_position, $CollisionShape3D/Neck/Camera3D/BulletGenerator.global_rotation) if Global.spawnCotton == true:
rpc("set_teddy_name", teddyName, Global.playerName) Global.spawnCotton = false
move_and_slide() 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") @rpc("any_peer", "unreliable")
func remote_set_position(authority_position, teddy_rotation, bulletgenerator_position, bulletgenerator_rotation): 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="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"] [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://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://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="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"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_i5hsu"]
sky_top_color = Color(1, 1, 1, 1) 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="Farmland" parent="." instance=ExtResource("5_imhi6")]
[node name="Virtual joystick" parent="." instance=ExtResource("6_p8th3")] [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() restart_round()
rpc("restart_round") rpc("restart_round")
if Global.mapName == "Tutorial": if Global.mapName == "Tutorial":
tutorial() if not Global.playerDisable:
if not Global.tutorialComplete: tutorial()
$musicPanel.visible = false if not Global.tutorialComplete:
if Global.iAmSpecial and Global.gamemode == "Runner": $musicPanel.visible = false
rpc("sync_runner_hp", $Health.value) if Global.iAmSpecial and Global.gamemode == "Runner":
rpc("sync_runner_hp", $Health.value)
if Global.musicUpdated == true: if Global.musicUpdated == true:
Global.musicUpdated = false Global.musicUpdated = false
$musicPanel/playingLabel.text = Global.musicName $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 spawnCotton = false # bullet will change this to true
var addedMenuScene = false # Used for teddy.gd, fixes multiple menu bug 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 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): func _process(delta):
#if not spawnCoordsInitalized: #if not spawnCoordsInitalized:

View file

@ -11,6 +11,12 @@ func _ready():
func _process(delta): 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 Global.tutorialComplete:
if audio_stream_player.playing == false: if audio_stream_player.playing == false:
var randomnum = RandomNumberGenerator.new().randi_range(0, 6) var randomnum = RandomNumberGenerator.new().randi_range(0, 6)

BIN
videos/trailer.ogv Normal file

Binary file not shown.