alles heeft een einde
en een worst zelfs twee
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
extends Node3D
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
+33
-11
@@ -1,34 +1,56 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
|
||||
const WALK_SPEED = 3.0
|
||||
const WALK_SPEED = 2.0
|
||||
const MOUSE_SENS = 0.002
|
||||
var has_flashlight = false
|
||||
var has_key = false
|
||||
@onready var flashlight = $"../FlashLight"
|
||||
@export var win: Node
|
||||
var won = false
|
||||
@export var win_position: Node
|
||||
|
||||
var mouse_mode = 2
|
||||
|
||||
func _ready():
|
||||
Input.set_mouse_mode(mouse_mode)
|
||||
add_collision_exception_with($"../Room/Doorframe/Door")
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventMouseMotion and mouse_mode == 2:
|
||||
$Pivot.rotate_y(-event.relative.x*MOUSE_SENS)
|
||||
$Pivot/Camera.rotate_x(-event.relative.y*MOUSE_SENS)
|
||||
elif event.is_action_pressed("mode"):
|
||||
mouse_mode = mouse_mode ^ 1
|
||||
Input.set_mouse_mode(mouse_mode)
|
||||
elif event.is_action_pressed("alt") and has_flashlight:
|
||||
$Pivot/Camera/FlashLight/SpotLight3D.visible = !$Pivot/Camera/FlashLight/SpotLight3D.visible
|
||||
if !won:
|
||||
if event is InputEventMouseMotion and mouse_mode == 2:
|
||||
$Pivot.rotate_y(-event.relative.x*MOUSE_SENS)
|
||||
$Pivot/Camera.rotate_x(-event.relative.y*MOUSE_SENS)
|
||||
elif event.is_action_pressed("mode"):
|
||||
mouse_mode = mouse_mode ^ 1
|
||||
Input.set_mouse_mode(mouse_mode)
|
||||
elif event.is_action_pressed("alt") and has_flashlight:
|
||||
$Pivot/Camera/FlashLight/SpotLight3D.visible = !$Pivot/Camera/FlashLight/SpotLight3D.visible
|
||||
|
||||
func _physics_process(delta):
|
||||
if mouse_mode == 2:
|
||||
if mouse_mode == 2 and !won:
|
||||
var input_dir = Input.get_vector("move_left", "move_right", "move_forward", "move_back")
|
||||
var direction = ($Pivot.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
velocity.x = direction.x * WALK_SPEED
|
||||
velocity.z = direction.z * WALK_SPEED
|
||||
move_and_slide()
|
||||
var bump = move_and_collide(velocity*delta)
|
||||
if bump and bump.get_collider() == win:
|
||||
won = true
|
||||
$Pivot/Camera/FlashLight.visible = false
|
||||
$Pivot/Camera.basis = Basis()
|
||||
elif won:
|
||||
var a = Quaternion($Pivot.transform.basis)
|
||||
var b = Quaternion(win_position.transform.basis)
|
||||
var c = a.slerp(b,delta*0.1)
|
||||
$Pivot.transform.basis = Basis(c)
|
||||
var d = win_position.position
|
||||
position = position.slerp(win_position.position, delta * 0.5)
|
||||
if (a - b).length() < 0.1 :
|
||||
$"../WorldEnvironment".environment.background_energy_multiplier += delta
|
||||
if $"../WorldEnvironment".environment.background_energy_multiplier > 2.0:
|
||||
$"../Einde/Thx".visible = true
|
||||
if $"../WorldEnvironment".environment.background_energy_multiplier > 10.0:
|
||||
get_tree().quit()
|
||||
|
||||
func _on_flash_light_input_event(camera, event, position, normal, shape_idx):
|
||||
if event is InputEventMouseButton and event.is_action_pressed("interact"):
|
||||
|
||||
+6
-1
@@ -16,4 +16,9 @@ func _on_static_body_3d_input_event(camera, event, position, normal, shape_idx):
|
||||
if event is InputEventMouseButton and event.is_action_pressed("interact"):
|
||||
$Body/Knop/Audio.playing = true
|
||||
if get_number() == combination:
|
||||
$Congratulations.playing = true
|
||||
$".."/Room/Doorframe/Door.visible = false
|
||||
$".."/Room/Doorframe/Door/Deur.set_collision_layer(0)
|
||||
$"../IndirectLightDoor".visible = true
|
||||
$"../Einde/Wincamera/AudioStreamPlayer3D".playing = true
|
||||
$"../Einde/Wincamera/AudioStreamPlayer3D2".playing = true
|
||||
$"../Einde/Wincamera/AudioStreamPlayer3D3".playing = true
|
||||
|
||||
Reference in New Issue
Block a user