Treehouse (Boomhut)
De boomhut interior scene - het thuis van de speler.
Scene Structuur
Boomhut (Control)
├── Background
│ └── BackgroundSprite (boomhut interior)
├── Character (Node2D)
│ ├── LeftLegSprite
│ ├── RightLegSprite
│ ├── BodySprite
│ ├── ClothesSprite
│ ├── FaceSprite
│ ├── EyesSprite
│ ├── PupilsSprite
│ └── HairSprite
├── InteractableObjects
│ ├── Bed
│ ├── Desk
│ ├── Storage
│ └── Door
├── UI (CanvasLayer)
│ ├── HUD
│ └── InteractionPrompt
└── FadeRect
Bestanden
- Scene:
scenes/boomhut.tscn - Script:
scripts/boomhut.gd - Background:
assets/scenes/boomhut_home.png
Features
Interactable Objects
| Object | Interactie | Functie |
|---|---|---|
| Bed | E / Tap | Slapen, tijd vooruit |
| Desk | E / Tap | Crafting interface |
| Storage | E / Tap | Persoonlijke opslag |
| Door | Walk into | Ga naar buiten (game.tscn) |
Zones
# Zone definities
const DOOR_ZONE_CENTER = Vector2(576, 600)
const DOOR_ZONE_RADIUS = 50.0
const BED_ZONE_CENTER = Vector2(200, 300)
const BED_ZONE_RADIUS = 60.0
Movement System
Zelfde als game.tscn:
# Pathfinding met walkable map
func _set_movement_target(pos: Vector2) -> void:
if not walkable_image:
return
if _is_walkable(pos):
current_path = _find_path(character.position, pos)
if current_path.size() > 0:
path_index = 0
is_moving = true
Walkable Map
Aparte walkable map voor interior:
const WALKABLE_MAP_PATH = "user://walkable_map_boomhut.png"
Scale System
Vaste schaal in interior (geen perspective):
const CHARACTER_SCALE = 0.04 # Vast voor interior
func _update_scale() -> void:
var flip = sign(character.scale.x) if character.scale.x != 0 else 1.0
character.scale = Vector2(CHARACTER_SCALE * flip, CHARACTER_SCALE)
Interactie Systeem
Zone Detection
func _check_interaction_zones() -> void:
# Check bed
if character.position.distance_to(BED_ZONE_CENTER) < BED_ZONE_RADIUS:
_show_interaction_prompt("Slapen")
if Input.is_action_just_pressed("interact"):
_sleep()
# Check storage
if character.position.distance_to(STORAGE_ZONE_CENTER) < STORAGE_ZONE_RADIUS:
_show_interaction_prompt("Opslag")
if Input.is_action_just_pressed("interact"):
_open_storage()
Interaction Prompt UI
@onready var interaction_prompt: Label = $UI/InteractionPrompt
func _show_interaction_prompt(text: String) -> void:
interaction_prompt.text = "[E] " + text
interaction_prompt.visible = true
interaction_prompt.position = character.position + Vector2(0, -100)
func _hide_interaction_prompt() -> void:
interaction_prompt.visible = false
Transitie naar Buiten
Door Zone
func _check_door_zone() -> void:
if is_transitioning:
return
var distance = character.position.distance_to(DOOR_ZONE_CENTER)
if distance < DOOR_ZONE_RADIUS:
_exit_treehouse()
func _exit_treehouse() -> void:
is_transitioning = true
is_moving = false
GameState.came_from_scene = "boomhut"
var tween = create_tween()
tween.tween_property(fade_rect, "color:a", 1.0, 0.5)
tween.tween_callback(func():
get_tree().change_scene_to_file("res://scenes/game.tscn")
)
Decoratie Systeem
Furniture Placement
# Toekomstig: meubels plaatsen
var placed_furniture: Array = []
func place_furniture(furniture_id: String, position: Vector2) -> void:
# Valideer positie
if not _is_valid_placement(position):
return
# Voeg toe aan scene
var furniture_scene = load("res://scenes/furniture/" + furniture_id + ".tscn")
var instance = furniture_scene.instantiate()
instance.position = position
$InteractableObjects.add_child(instance)
placed_furniture.append({
"id": furniture_id,
"position": position
})
# Sync naar server
_save_furniture_layout()
Room Unlocking
# Toekomstig: extra kamers
var unlocked_rooms: int = 1
func unlock_room(room_index: int) -> void:
if room_index <= unlocked_rooms:
return # Al unlocked
# Check requirements
if not _can_unlock_room(room_index):
return
unlocked_rooms = room_index
_reveal_room(room_index)
Assets Nodig
| Asset | Pad | Beschrijving |
|---|---|---|
| Interior BG | assets/scenes/boomhut_home.png | Boomhut achtergrond |
| Walkable Map | user://walkable_map_boomhut.png | Loopbaar gebied |
| Bed | assets/furniture/bed.png | Bed sprite |
| Desk | assets/furniture/desk.png | Bureau sprite |
| Storage | assets/furniture/chest.png | Opslag kist |