Move scripts

This commit is contained in:
Vojta committed 2025-05-13 15:41:23 +02:00
1 parent 05614ce307
commit e840502098
6 files changed
+27 -4

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
extends Node3D
@onready var entry_portal: Portal3D = %EntryPortal
@onready var win_portal: Portal3D = %WinPortal
@onready var blue_portal: Portal3D = %BluePortal
@onready var red_portal: Portal3D = %RedPortal
@onready var win_indicator: Node3D = %WinIndicator
var red_completed: bool = false
var blue_completed: bool = false
func _ready() -> void:
win_indicator.visible = false
func _on_blue_portal_on_teleport(node: Node3D) -> void:
blue_completed = true
entry_portal.exit_portal = blue_portal
check_completion()
func _on_red_portal_on_teleport(node: Node3D) -> void:
red_completed = true
entry_portal.exit_portal = red_portal
check_completion()
func check_completion() -> void:
if blue_completed and red_completed:
entry_portal.exit_portal = win_portal
win_indicator.visible = true
+1
View File
@@ -0,0 +1 @@
uid://7uicahbwx5vb
+56
View File
@@ -0,0 +1,56 @@
extends CharacterBody3D
@export var camera: Camera3D
@export var SPEED = 4.0
const JUMP_VELOCITY = 4.5
const MOUSE_SENSITIVITY = 0.004
func _ready() -> void:
assert(camera != null, "Forgot to set camera in editor")
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
## Implements [member Portal3D.ON_TELEPORT_CALLBACK]
func on_teleport(portal: Portal3D) -> void:
pass
func _unhandled_input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
rotate_y(-event.screen_relative.x * MOUSE_SENSITIVITY)
camera.rotate_x(-event.screen_relative.y * MOUSE_SENSITIVITY)
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-80), deg_to_rad(80))
func _physics_process(delta: float) -> void:
var right: Vector3 = (global_transform.basis.x * Vector3(1, 0, 1)).normalized()
var forward: Vector3 = (-global_transform.basis.z * Vector3(1, 0, 1)).normalized()
var has_input = false
velocity.x = 0
velocity.z = 0
if Input.is_key_pressed(KEY_LEFT) or Input.is_key_pressed(KEY_A):
has_input = true
velocity -= right
if Input.is_key_pressed(KEY_RIGHT) or Input.is_key_pressed(KEY_D):
has_input = true
velocity += right
if Input.is_key_pressed(KEY_UP) or Input.is_key_pressed(KEY_W):
has_input = true
velocity += forward
if Input.is_key_pressed(KEY_DOWN) or Input.is_key_pressed(KEY_S):
has_input = true
velocity -= forward
if has_input:
var normalized_horizontal_velocity = Vector2(velocity.x, velocity.z).normalized()
velocity.x = normalized_horizontal_velocity.x * SPEED
velocity.z = normalized_horizontal_velocity.y * SPEED
if not is_on_floor():
velocity += get_gravity() * delta
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
move_and_slide()
+1
View File
@@ -0,0 +1 @@
uid://bdclx4q3c332j