replace with multiplayer-coop files

This commit is contained in:
2026-01-08 16:47:52 +01:00
parent 1725c615ce
commit 22c7025ac4
1230 changed files with 20555 additions and 17232 deletions

88
src/scripts/door.gd Normal file
View File

@@ -0,0 +1,88 @@
extends StaticBody2D
@export_enum("GateDoor", "KeyDoor", "StoneDoor") var type: String = "StoneDoor"
@export_enum("Left", "Up", "Right", "Down") var direction: String = "Up"
#KeyDoors should always be closed at start
#StoneDoor and GateDoor CAN be opened in start, and become closed when entering it's room
#Then you must press a switch in the room or maybe you need to defeat all enemies in the room
@export var is_closed: bool = true
var is_closing:bool = false
var is_opening:bool = false
var time_to_move:float = 0.5
var move_timer:float = 0.0
var initial_position:Vector2 = Vector2.ZERO
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
if direction == "Left":
self.rotate(-PI/2)
elif direction == "Right":
self.rotate(PI/2)
elif direction == "Down":
self.rotate(PI)
initial_position = global_position
var amount = 16
set_collision_layer_value(7, false)
if is_closed:
set_collision_layer_value(7, true)
amount = 0
if direction == "Up":
position.y = initial_position.y - amount
elif direction == "Down":
position.y = initial_position.y + amount
elif direction == "Left":
position.x = initial_position.x - amount
elif direction == "Right":
position.x = initial_position.x + amount
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
# TODO write code to open/close door here
# when door is open, ofcourse
if is_opening or is_closing:
move_timer+=delta
#move 16 pixels in direction under 0.5 seconds
var amount = clamp(16*(move_timer/time_to_move),0,16)
if is_closing:
amount = 16-amount
if direction == "Up":
position.y = initial_position.y - amount
elif direction == "Down":
position.y = initial_position.y + amount
elif direction == "Left":
position.x = initial_position.x - amount
elif direction == "Right":
position.x = initial_position.x + amount
if move_timer >= time_to_move:
if is_opening:
is_closed = false
set_collision_layer_value(7, false)
else:
is_closed = true
set_collision_layer_value(7, true)
is_opening = false
is_closing = false
move_timer = 0
pass
func _open():
$SfxOpenKeyDoor.play()
is_opening = true
is_closing = false
move_timer = 0.0
pass
func _close():
$SfxOpenStoneDoor.play()
is_opening = false
is_closing = true
move_timer = 0.0
pass