Initial commit

This commit is contained in:
SEISYUNLie
2026-10-03 15:29:06 +08:00
commit ba36357b90
621 changed files with 13821 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
extends Area2D
var body_in = false
@export var hint:Label
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
body_entered.connect(_in)
body_exited.connect(_out)
hint.visible = false
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _in(body):
if body.is_in_group("player"):
hint.visible = true
func _out(body):
if body.is_in_group("player"):
hint.visible = false
+1
View File
@@ -0,0 +1 @@
uid://whsw7lw2j2ty
+41
View File
@@ -0,0 +1,41 @@
extends Area2D
@export var wall: Node2D
@export var ok:Sprite2D
@export var nook:Sprite2D
@export var label: Label
var body_in = false
var pressed = false
func _ready():
add_to_group("button")
body_entered.connect(_in)
body_exited.connect(_out)
nook.visible = false
label.visible = false
func _process(delta: float) -> void:
press()
func press():
if body_in and Input.is_action_just_pressed("interact") and not pressed:
wall.queue_free()
nook.visible = true
ok.visible = false
pressed = true
label.visible = true
get_tree().create_timer(1).timeout.connect(off)
func _in(body):
if body.is_in_group("player"):
body_in = true
func _out(body):
if body.is_in_group("player"):
body_in = false
func off():
label.visible = false
+1
View File
@@ -0,0 +1 @@
uid://cbh3alwjyg4u0
+22
View File
@@ -0,0 +1,22 @@
extends Camera2D
@export var shake_strength: float = 8.0
@export var shake_decay: float = 5.0
var shake_amount: float = 0.0
func _ready():
add_to_group("camera")
func _process(delta):
if shake_amount > 0:
shake_amount = max(shake_amount - shake_decay * delta, 0.0)
offset.x = randf_range(-1, 1) * shake_strength * shake_amount
offset.y = randf_range(-1, 1) * shake_strength * shake_amount
else:
offset = Vector2.ZERO
func shake(intensity: float = 1.0):
shake_amount = clamp(shake_amount + intensity, 0.0, 1.0)
+1
View File
@@ -0,0 +1 @@
uid://3pm2vt1do0dd
+45
View File
@@ -0,0 +1,45 @@
extends Area2D
var body_in = false
var player = null
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
body_entered.connect(_in)
body_exited.connect(_out)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
climb()
func _in(body):
if body.is_in_group("player"):
body_in = true
player = body
func _out(body):
if body.is_in_group("player"):
body_in = false
player.is_climbing = false
player = null
func climb():
if player == null:
return
if player.is_in_group("player") and Input.is_action_pressed("balance"):
if Input.is_action_pressed("jump"):
player.is_climbing = false
player.velocity.y = -80
return
if Input.is_action_pressed("squat"):
player.is_climbing = false
player.velocity.y = 80
return
player.reset_jump()
player.is_climbing = true
player.velocity.y = 0
else:
player.is_climbing = false
+1
View File
@@ -0,0 +1 @@
uid://hqjfwm6g6n2d
+52
View File
@@ -0,0 +1,52 @@
extends StaticBody2D
@onready var collision = $CollisionShape2D
@onready var sprite = $Sprite2D
@onready var area2D = $Area2D
var on_top = false
var player:Node2D = null
var blink_timer = 0.6
var is_run = false
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
player = get_tree().get_first_node_in_group("player")
$Area2D.body_entered.connect(beicai)
$Area2D.body_exited.connect(left)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if is_run:
blink_timer -= delta
var blink = fmod(blink_timer, 0.2)
modulate.a = 0.5 if blink < 0.1 else 1.0
func beicai(body):
if body.is_in_group("player") and not is_run:
is_run = true
on_top = true
get_tree().create_timer(0.6).timeout.connect(disappear)#控制真正消失
func left(body):
on_top = false
modulate.a = 1.0
blink_timer = 0.6
is_run = false
func disappear():
if not on_top:
return
area2D.monitoring = false
collision.set_deferred("disabled", true)
sprite.visible = false
get_tree().create_timer(1.5).timeout.connect(reappear)
func reappear():
collision.set_deferred("disabled", false)
sprite.visible = true
area2D.monitoring = true
blink_timer = 0.6
is_run = false
+1
View File
@@ -0,0 +1 @@
uid://dldku23tokg8g
+41
View File
@@ -0,0 +1,41 @@
extends Area2D
var body_in = false
var player:Node2D = null
var key = null
func _ready():
body_entered.connect(_on_body_entered)
body_exited.connect(_on_body_exited)
player = get_tree().get_first_node_in_group("player")
key = get_tree().get_first_node_in_group("key")
func _process(delta):
if body_in:
open()
func _on_body_entered(body):
if body.is_in_group("player"):
body_in = true
player = body
func _on_body_exited(body):
if body.is_in_group("player"):
body_in = false
player = null
func open():
if is_in_group("unlocked") and Input.is_action_just_pressed("interact"):
player.global_position = Vector2(560,130)
elif Input.is_action_just_pressed("interact") and player.is_in_group("has_key"):
player.global_position = Vector2(560,130)
add_to_group("unlocked")
player.remove_from_group("has_key")
key.queue_free()
+1
View File
@@ -0,0 +1 @@
uid://csipfcqva0gmy
+26
View File
@@ -0,0 +1,26 @@
extends Area2D
var body_in = false
var player:Node2D = null
func _ready():
body_entered.connect(_on_body_entered)
body_exited.connect(_on_body_exited)
func _process(delta):
if body_in:
open()
func _on_body_entered(body):
if body.is_in_group("player"):
body_in = true
player = body
func _on_body_exited(body):
if body.is_in_group("player"):
body_in = false
player = null
func open():
if Input.is_action_just_pressed("interact"):
player.global_position = Vector2(330,200)
+1
View File
@@ -0,0 +1 @@
uid://blv3emw6on4w0
+26
View File
@@ -0,0 +1,26 @@
extends Area2D
@export var label:Label
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
body_entered.connect(set_spownpoint)
body_exited.connect(out)
label.visible = false
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func set_spownpoint(body):
if body.is_in_group("player"):
body.respownpoint = global_position
label.visible = true
func out(body):
if body.is_in_group("player"):
get_tree().create_timer(1).timeout.connect(off)
func off():
label.visible = false
+1
View File
@@ -0,0 +1 @@
uid://dmo6gf7nah07f
+13
View File
@@ -0,0 +1,13 @@
extends HBoxContainer
@export var full_texture: Texture2D
@export var empty_texture: Texture2D
@export var max_health: int = 5
func update_health(current_health: int):
for i in range(get_child_count()):
var icon = get_child(i) as TextureRect
if i < current_health:
icon.texture = full_texture
else:
icon.texture = empty_texture
+1
View File
@@ -0,0 +1 @@
uid://cngafru67t0m6
+21
View File
@@ -0,0 +1,21 @@
extends Area2D
var ok = true
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
body_entered.connect(_in)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _in(body):
if body.is_in_group("player") and ok :
body.velocity.x = 300
body.reset_jump()
ok = false
get_tree().create_timer(0.2).timeout.connect(reset)
func reset():
ok = true
+1
View File
@@ -0,0 +1 @@
uid://bibf255rv8r4t
+30
View File
@@ -0,0 +1,30 @@
extends Area2D
var is_following = false
var target = null
var floating = true
var float_amplitude: float = 5.0 # 浮动幅度(像素)
var float_speed: float = 3.0
var time = 0
func _ready():
body_entered.connect(_on_body_entered)
add_to_group("key")
func _process(delta):
time += delta
if floating:
position.y += sin(time * float_speed) * float_amplitude * delta
func _on_body_entered(body):
if body.is_in_group("player") and not is_following:
body.add_to_group("has_key")
is_following = true
target = body
floating = false
set_deferred("monitoring", false)
func _physics_process(delta: float) -> void:
if is_following == true and target:
global_position = global_position.lerp(target.global_position,0.2)
+1
View File
@@ -0,0 +1 @@
uid://wicj671ou4fj
+16
View File
@@ -0,0 +1,16 @@
extends StaticBody2D
var collision = null
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
collision = $CollisionShape2D
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta: float) -> void:
if collision and Input.is_action_pressed("balance"):
collision.disabled = false
else:
collision.disabled = true
+1
View File
@@ -0,0 +1 @@
uid://dve2d7snw7pr0
+27
View File
@@ -0,0 +1,27 @@
extends Area2D
var button = null
var camera = null
func _ready():
camera = get_tree().get_first_node_in_group("camera")
button = get_tree().get_first_node_in_group("button")
print("camera: ", camera, " button: ", button)
body_entered.connect(update_camera)
func update_camera(body):
print("有物体进入摄像机区域:", body.name)
if not body.is_in_group("player"):
return
print("玩家进入,开始改摄像头限制")
if button.pressed:
camera.limit_left = -1465
camera.limit_right = 450
camera.limit_top = -235
camera.limit_bottom = 270
else:
camera.limit_left = 0
camera.limit_right = 450
camera.limit_top = 0
camera.limit_bottom = 290
+1
View File
@@ -0,0 +1 @@
uid://ciusqi5e480px
+182
View File
@@ -0,0 +1,182 @@
extends CharacterBody2D
@export var fail_label_1:Label
@export var fail_label_2:Label
@export_category("移动参数")
@export var health_bar: HBoxContainer # 在检查器里把 HealthBar 拖进来
@export var double_press_interval := 0.3
@export var move_speed: float = 75.0
@export var acceleration: float = 600.0
@export var deceleration: float = 800.0
@export var jump_velocity: float = -190.0
var respownpoint = null
var health = 4
@export var invincibility_duration: float = 1.0 # 无敌持续时间(秒)
var is_invincible: bool = false # 是否处于无敌帧
var invincibility_timer: float = 0.0
var is_climbing = false
var die = false
var huishoushang = true
@onready var sprite_jump: Sprite2D = $jump
@onready var sprite: Sprite2D = $idel
var flying : bool = false
var last_space_press_time := -1000
var jump_count = 0
func _ready():
add_to_group("player")
print(get_groups())
respownpoint = global_position
fail_label_1.visible = false
fail_label_2.visible = false
func _physics_process(delta: float) -> void:
if !flying:
apply_gravity(delta)
handle_jump()
else:
handle_vertical_movement(delta)
handle_horizontal_movement(delta)
update_sprite_direction()
move_and_slide()
func _process(delta):
#无敌帧
if is_invincible:
invincibility_timer -= delta
# 图像闪烁:在 0.5 和 1.0 的透明度之间快速切换
# 每 0.1 秒切换一次
var blink = fmod(invincibility_timer, 0.2)
modulate.a = 0.5 if blink < 0.1 else 1.0
if invincibility_timer <= 0:
is_invincible = false
modulate.a = 1.0
#死亡ui
if die and Input.is_action_just_pressed("reset"):
health = 4
global_position = respownpoint
fail_label_1.visible = false
fail_label_2.visible = false
die = false
set_physics_process(true)
health_bar.update_health(health)
func apply_gravity(delta: float) -> void:
if not is_on_floor() and not is_climbing:
velocity += get_gravity() * delta
func handle_vertical_movement(delta:float) -> void:
var direction := Input.get_axis("squat", "jump")
var target_speed := direction * jump_velocity
if direction != 0.0:
velocity.y = move_toward(
velocity.y,
target_speed,
acceleration * delta
)
else:
velocity.y = move_toward(
velocity.y,
0.0,
acceleration * delta
)
func handle_horizontal_movement(delta: float) -> void:
var direction := Input.get_axis("move_left", "move_right")
var target_speed := direction * move_speed
if direction != 0.0:
velocity.x = move_toward(
velocity.x,
target_speed,
acceleration * delta
)
else:
velocity.x = move_toward(
velocity.x,
0.0,
deceleration * delta
)
func handle_jump() -> void:
if is_on_floor():
jump_count = 0
if Input.is_action_just_pressed("jump"):
if jump_count <= 1:
velocity.y = jump_velocity
jump_count = jump_count + 1
else:
return
#掉落动画
if velocity.y < 0:
sprite_jump.visible = true
sprite.visible = false
else:
sprite_jump.visible = false
sprite.visible = true
#保持平衡用
func reset_jump():
jump_count = 0
func update_sprite_direction() -> void:
if velocity.x != 0.0:
sprite.flip_h = velocity.x < 0.0
sprite_jump.flip_h = velocity.x < 0.0
func take_damage(amount: int):
# 处于无敌帧
if is_invincible or not huishoushang:
return
health -= amount
if health < 0:
health = 0
health_bar.update_health(health)
var camera = get_tree().get_first_node_in_group("camera")
if camera and camera.has_method("shake"):
camera.shake(0.5) # 0.5 是震动强度,可调
# 进入无敌帧
is_invincible = true
invincibility_timer = invincibility_duration
# 死亡处理
if health == 0:
fail_label_1.visible = true
fail_label_2.visible = true
die = true
set_physics_process(false)
#还就那个创造模式
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("fly") and !event.is_echo():
handle_space_pressed()
func handle_space_pressed() -> void:
var current_time := Time.get_ticks_msec()
var elapsed_time := current_time - last_space_press_time
if elapsed_time <= double_press_interval * 1000.0 and is_in_group("has_shenqi"):
flying = not flying
last_space_press_time = -1000
else:
last_space_press_time = current_time
+1
View File
@@ -0,0 +1 @@
uid://b0gltif7vthau
+19
View File
@@ -0,0 +1,19 @@
extends Area2D
var button = null
var camera = null
func _ready():
camera = get_tree().get_first_node_in_group("camera")
button = get_tree().get_first_node_in_group("button")
body_entered.connect(update_camera)
func update_camera(body):
print("有物体进入摄像机区域:", body.name)
if not body.is_in_group("player"):
return
print("玩家进入,开始改摄像头限制")
camera.limit_left = 555
camera.limit_right = 1010
camera.limit_top = 0
camera.limit_bottom = 270
+1
View File
@@ -0,0 +1 @@
uid://coccx5jfos1oe