Menu
CoddyTech

던전 탈출하기

Coddy Godot 여정의 프로젝트 섹션에 포함된 레슨. 33개 중 33번째.

먼 구석에 있는 계단이 출구입니다. 계단은 Exit라는 Area2D입니다. 영웅이 계단을 밟으면 플레이어가 승리합니다.

func _on_exit_body_entered(body):
	$HUD/Message.text = "You Escaped!"
	get_tree().paused = true

다른 신호와 함께 _ready에서 연결하세요. 게임이 일시 정지되었는지만 확인하기 때문에, 승리한 뒤에도 Enter 키를 누르면 새 게임이 시작됩니다.

던전을 플레이해 보세요. 그런 다음 던전을 바꿔 보세요. 경비병을 한 명 더 추가하거나, 벽을 옮기거나, 열쇠를 더 찾기 어려운 곳에 숨겨 보세요.

challenge icon

챌린지

쉬움

main.gd에서 $Exit.body_entered를 $HUD/Message에 You Escaped!를 표시하고 게임을 일시 정지하는 함수에 연결하세요.

직접 해보기

extends Node2D

var has_key = false
var health = 3

func _ready():
	$Key.body_entered.connect(_on_key_body_entered)
	$DoorZone.body_entered.connect(_on_door_zone_body_entered)
	$Enemy.body_entered.connect(_on_enemy_body_entered)

func _process(delta):
	if get_tree().paused and Input.is_action_just_pressed("action"):
		get_tree().paused = false
		get_tree().reload_current_scene()

func _on_key_body_entered(body):
	has_key = true
	$Key.queue_free()
	$HUD/KeyIcon.visible = true

func _on_door_zone_body_entered(body):
	if has_key:
		$Door.queue_free()
		$DoorZone.queue_free()

func _on_enemy_body_entered(body):
	health -= 1
	$HUD/Hearts.get_child(health).visible = false
	$Hero.flash()
	if health == 0:
		$HUD/Message.text = "Game Over"
		get_tree().paused = true
quiz icon실력 점검

이 레슨에는 짧은 퀴즈가 포함되어 있습니다. 레슨을 시작해 문제를 풀고 진행 상황을 기록하세요.

프로젝트의 모든 레슨

직접 연습해 보세요: Godot 플레이그라운드