第一次提交作业

This commit is contained in:
2026-10-07 19:35:15 +08:00
commit b3fdeabc44
567 changed files with 12412 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
extends Label
# Called when the node enters the scene tree for the first time.
# Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _ready():
var player = %Player
if player:
player.coin_changed.connect(_on_coin_changed)
_on_coin_changed(player.coins) # 初始化显示
print("信号已连接")
func _on_coin_changed(total: int):
text = "金币: %d/12" % total
+1
View File
@@ -0,0 +1 @@
uid://hujmjdovlvsd
+19
View File
@@ -0,0 +1,19 @@
extends Label
# Called when the node enters the scene tree for the first time.
# Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _ready():
visible = false
%tip.body_entered.connect(_on_body_entered)
func _on_body_entered(body: Node2D):
if body.has_method("take_damage"):
visible = true
await get_tree().create_timer(3.0).timeout
visible = false
+1
View File
@@ -0,0 +1 @@
uid://cquhgo8be1fvu
+19
View File
@@ -0,0 +1,19 @@
extends Area2D
signal win
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
body_entered.connect(_on_body_entered) # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
signal not_enough_coins
func _on_body_entered(body: Node2D) -> void:
if body.has_method("take_damage"):
if body.coins >= 12:
win.emit()
print("胜利")
else:
not_enough_coins.emit()
+1
View File
@@ -0,0 +1 @@
uid://cblfchy71se8r
+11
View File
@@ -0,0 +1,11 @@
extends CollisionShape2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
+1
View File
@@ -0,0 +1 @@
uid://dy3ryl8eq8tsl
+19
View File
@@ -0,0 +1,19 @@
extends Label
# Called when the node enters the scene tree for the first time.
# Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _ready():
var player = %Player
if player:
player.health_changed.connect(_on_health_changed)
_on_health_changed(player.hp,player.max_hp) # 初始化显示
print("信号已连接")
func _on_health_changed(current: int, max_hp: int):
text = "生命: %d/%d" % [current,max_hp]
+1
View File
@@ -0,0 +1 @@
uid://bewbqlagxmcui
+23
View File
@@ -0,0 +1,23 @@
extends Label
# Called when the node enters the scene tree for the first time.
func _ready():
visible = false
var goal = get_tree().get_first_node_in_group("goal")
if goal:
goal.win.connect(_on_win)
func _on_win():
visible = true
text = "你赢了!"
var player = get_tree().get_first_node_in_group("player")
if player:
player.set_physics_process(false)
player.velocity = Vector2.ZERO
# Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
+1
View File
@@ -0,0 +1 @@
uid://bdxrp5fomye2j
+890
View File
File diff suppressed because one or more lines are too long
+21
View File
@@ -0,0 +1,21 @@
extends Label
# Called when the node enters the scene tree for the first time.
# Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func _ready():
visible = false
var goal = get_tree().get_first_node_in_group("goal")
if goal:
goal.not_enough_coins.connect(_on_not_enough_coins)
func _on_not_enough_coins():
visible = true
text = "金币不够!"
await get_tree().create_timer(3.0).timeout # 等 3 秒
visible = false
+1
View File
@@ -0,0 +1 @@
uid://cdydf8w5xfkak
+30
View File
@@ -0,0 +1,30 @@
[gd_scene format=3 uid="uid://c1u8k6ny02t4y"]
[ext_resource type="Texture2D" uid="uid://cgkn1cd8uhunb" path="res://assets/game/characters/player_green_idle.png" id="1_character"]
[ext_resource type="Script" uid="uid://b0gltif7vthau" path="res://scripts/player_controller.gd" id="1_g2els"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_player"]
radius = 5.0
height = 17.0
[node name="Player" type="CharacterBody2D" unique_id=2098904787]
collision_layer = 2
collision_mask = 4
script = ExtResource("1_g2els")
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=921388463]
texture_filter = 1
texture = ExtResource("1_character")
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=151099089]
position = Vector2(0, 2)
shape = SubResource("CapsuleShape2D_player")
[node name="Camera2D" type="Camera2D" parent="." unique_id=580107698]
zoom = Vector2(2, 2)
limit_left = 0
limit_top = 0
limit_right = 2107
limit_bottom = 635
position_smoothing_enabled = true
position_smoothing_speed = 6.0
@@ -0,0 +1,19 @@
extends Area2D
# Called when the node enters the scene tree for the first time.
# Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
@export var value: int = 1 # 这枚金币值多少分
func _ready():
body_entered.connect(_on_body_entered)
func _on_body_entered(body: Node2D) -> void:
if body.has_method("add_coin"): # 确认是主角
body.add_coin(value)
queue_free()
@@ -0,0 +1 @@
uid://dg06y7uamg1c2
@@ -0,0 +1,19 @@
[gd_scene format=3 uid="uid://cnqt0sdrsanc0"]
[ext_resource type="Script" uid="uid://dg06y7uamg1c2" path="res://scenes/prefabs/collectibles/coin_gold_round.gd" id="1_1q6pd"]
[ext_resource type="Texture2D" uid="uid://cb8de6nm1sbvw" path="res://assets/game/collectibles/coin_gold_round.png" id="1_texture"]
[sub_resource type="CircleShape2D" id="Shape_coin"]
radius = 5.0
[node name="CoinGoldRound" type="Area2D" unique_id=23388588 groups=["collectible"]]
collision_layer = 15
collision_mask = 2
script = ExtResource("1_1q6pd")
[node name="Sprite" type="Sprite2D" parent="." unique_id=222829881]
texture_filter = 1
texture = ExtResource("1_texture")
[node name="PickupArea" type="CollisionShape2D" parent="." unique_id=185188105]
shape = SubResource("Shape_coin")
@@ -0,0 +1,18 @@
[gd_scene load_steps=3 format=3]
[ext_resource type="Texture2D" path="res://assets/game/collectibles/coin_gold_thin.png" id="1_texture"]
[sub_resource type="RectangleShape2D" id="Shape_coin"]
size = Vector2(7, 13)
[node name="CoinGoldThin" type="Area2D" groups=["collectible"]]
collision_layer = 16
collision_mask = 2
[node name="Sprite" type="Sprite2D" parent="."]
texture_filter = 1
texture = ExtResource("1_texture")
[node name="PickupArea" type="CollisionShape2D" parent="."]
shape = SubResource("Shape_coin")
+18
View File
@@ -0,0 +1,18 @@
[gd_scene load_steps=3 format=3]
[ext_resource type="Texture2D" path="res://assets/game/collectibles/gem_blue.png" id="1_texture"]
[sub_resource type="CircleShape2D" id="Shape_gem"]
radius = 6.0
[node name="GemBlue" type="Area2D" groups=["collectible"]]
collision_layer = 16
collision_mask = 2
[node name="Sprite" type="Sprite2D" parent="."]
texture_filter = 1
texture = ExtResource("1_texture")
[node name="PickupArea" type="CollisionShape2D" parent="."]
shape = SubResource("Shape_gem")
@@ -0,0 +1,28 @@
[gd_scene load_steps=5 format=3]
[ext_resource type="Texture2D" path="res://assets/game/vegetation/tree_canopy_left.png" id="1_left"]
[ext_resource type="Texture2D" path="res://assets/game/vegetation/tree_canopy_middle.png" id="2_middle"]
[ext_resource type="Texture2D" path="res://assets/game/vegetation/tree_canopy_right.png" id="3_right"]
[ext_resource type="Texture2D" path="res://assets/game/vegetation/tree_trunk.png" id="4_trunk"]
[node name="TreeSmall" type="Node2D"]
[node name="CanopyLeft" type="Sprite2D" parent="."]
texture_filter = 1
position = Vector2(-18, -18)
texture = ExtResource("1_left")
[node name="CanopyMiddle" type="Sprite2D" parent="."]
texture_filter = 1
position = Vector2(0, -18)
texture = ExtResource("2_middle")
[node name="CanopyRight" type="Sprite2D" parent="."]
texture_filter = 1
position = Vector2(18, -18)
texture = ExtResource("3_right")
[node name="Trunk" type="Sprite2D" parent="."]
texture_filter = 1
texture = ExtResource("4_trunk")
+16
View File
@@ -0,0 +1,16 @@
extends Area2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass
func _on_body_entered(body: Node2D) -> void:
if body.is_in_group("hazard"):
if body.has_method("take_damage"):
body.take_damage()
# Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
@@ -0,0 +1 @@
uid://3ugbvq1iadqi
+19
View File
@@ -0,0 +1,19 @@
[gd_scene load_steps=3 format=3]
[ext_resource type="Texture2D" path="res://assets/game/obstacles/spikes_double.png" id="1_texture"]
[sub_resource type="RectangleShape2D" id="Shape_spikes"]
size = Vector2(14, 6)
[node name="SpikesDouble" type="Area2D" groups=["hazard"]]
collision_layer = 4
collision_mask = 2
[node name="Sprite" type="Sprite2D" parent="."]
texture_filter = 1
texture = ExtResource("1_texture")
[node name="DetectionArea" type="CollisionShape2D" parent="."]
position = Vector2(0, 4)
shape = SubResource("Shape_spikes")
@@ -0,0 +1,19 @@
[gd_scene load_steps=3 format=3]
[ext_resource type="Texture2D" path="res://assets/game/interactables/spring_red.png" id="1_texture"]
[sub_resource type="RectangleShape2D" id="Shape_spring"]
size = Vector2(14, 8)
[node name="SpringRed" type="Area2D" groups=["spring"]]
collision_layer = 8
collision_mask = 2
[node name="Sprite" type="Sprite2D" parent="."]
texture_filter = 1
texture = ExtResource("1_texture")
[node name="ActivationArea" type="CollisionShape2D" parent="."]
position = Vector2(0, 3)
shape = SubResource("Shape_spring")
@@ -0,0 +1,9 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Texture2D" path="res://assets/game/signs/direction_sign_left.png" id="1_texture"]
[node name="DirectionSignLeft" type="Node2D"]
[node name="Sprite" type="Sprite2D" parent="."]
texture_filter = 1
texture = ExtResource("1_texture")
@@ -0,0 +1,10 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Texture2D" path="res://assets/game/signs/direction_sign_right.png" id="1_texture"]
[node name="DirectionSignRight" type="Node2D"]
[node name="Sprite" type="Sprite2D" parent="."]
texture_filter = 1
texture = ExtResource("1_texture")
+18
View File
@@ -0,0 +1,18 @@
[gd_scene load_steps=3 format=3]
[ext_resource type="Texture2D" path="res://assets/game/structures/crate.png" id="1_texture"]
[sub_resource type="RectangleShape2D" id="Shape_crate"]
size = Vector2(18, 18)
[node name="Crate" type="StaticBody2D"]
collision_layer = 1
collision_mask = 0
[node name="Sprite" type="Sprite2D" parent="."]
texture_filter = 1
texture = ExtResource("1_texture")
[node name="Collision" type="CollisionShape2D" parent="."]
shape = SubResource("Shape_crate")
+19
View File
@@ -0,0 +1,19 @@
extends Area2D
# Called when the node enters the scene tree for the first time.
# Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
signal hint_triggered
func _ready():
body_entered.connect(_on_body_entered)
add_to_group("hint")
func _on_body_entered(body: Node2D) -> void:
if body.has_method("take_damage"): # 是主角
hint_triggered.emit()
+1
View File
@@ -0,0 +1 @@
uid://lqqumn66xv11
+19
View File
@@ -0,0 +1,19 @@
extends Label
# Called when the node enters the scene tree for the first time.
func _ready():
visible = false
# 等主角就绪后连接
var player = get_tree().get_first_node_in_group("player")
if player:
player.died.connect(_on_player_died)
func _on_player_died():
visible = true
text = "游戏结束"
print("游戏结束")
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
+1
View File
@@ -0,0 +1 @@
uid://b5vxolycwic32