feat(poc): implement Sprint 1 proof of concept

- project.godot with autoload configuration
- Reception room with placeholder visuals
- Draggable Character with DragDropComponent
- Interactive flower object with bounce animation
- GameState, SaveManager, AudioManager, InputManager autoloads
- HUD with back button and music toggle

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Steven Wroblewski
2026-04-17 10:38:29 +02:00
parent c2028edb2f
commit 9a1e30d808
14 changed files with 547 additions and 5 deletions

View File

@@ -0,0 +1,63 @@
## AudioManager — music playback with cross-fade, SFX playback, volume control.
extends Node
const DEFAULT_MUSIC_VOLUME: float = 0.6
const CROSSFADE_DURATION: float = 1.0
var _music_player_a: AudioStreamPlayer
var _music_player_b: AudioStreamPlayer
var _active_player: AudioStreamPlayer
var _sfx_player: AudioStreamPlayer
var _music_volume: float = DEFAULT_MUSIC_VOLUME
var _sfx_volume: float = 1.0
var _is_fading: bool = false
func _ready() -> void:
_music_player_a = AudioStreamPlayer.new()
_music_player_b = AudioStreamPlayer.new()
_sfx_player = AudioStreamPlayer.new()
add_child(_music_player_a)
add_child(_music_player_b)
add_child(_sfx_player)
_active_player = _music_player_a
_apply_music_volume()
func play_music(stream: AudioStream) -> void:
if _active_player.stream == stream and _active_player.playing:
return
var next_player: AudioStreamPlayer = _music_player_b if _active_player == _music_player_a else _music_player_a
next_player.stream = stream
next_player.volume_db = linear_to_db(0.0)
next_player.play()
var tween: Tween = create_tween()
tween.set_parallel(true)
tween.tween_property(_active_player, "volume_db", linear_to_db(0.0), CROSSFADE_DURATION)
tween.tween_property(next_player, "volume_db", linear_to_db(_music_volume), CROSSFADE_DURATION)
var prev_player: AudioStreamPlayer = _active_player
tween.tween_callback(prev_player.stop).set_delay(CROSSFADE_DURATION)
_active_player = next_player
func play_sfx(stream: AudioStream) -> void:
_sfx_player.stream = stream
_sfx_player.volume_db = linear_to_db(_sfx_volume)
_sfx_player.play()
func set_music_volume(value: float) -> void:
_music_volume = clampf(value, 0.0, 1.0)
_apply_music_volume()
func set_sfx_volume(value: float) -> void:
_sfx_volume = clampf(value, 0.0, 1.0)
func get_music_volume() -> float:
return _music_volume
func _apply_music_volume() -> void:
_active_player.volume_db = linear_to_db(_music_volume)

View File

@@ -0,0 +1,45 @@
## GameState — global game state: character positions, object states, current room.
extends Node
signal state_changed
signal character_moved(character_id: String, position: Vector2)
var _character_positions: Dictionary = {}
var _object_states: Dictionary = {}
var current_room: String = "reception"
func get_character_position(id: String) -> Vector2:
return _character_positions.get(id, Vector2.ZERO)
func set_character_position(id: String, pos: Vector2) -> void:
_character_positions[id] = pos
character_moved.emit(id, pos)
state_changed.emit()
func get_object_state(id: String) -> String:
return _object_states.get(id, "idle")
func set_object_state(id: String, state: String) -> void:
_object_states[id] = state
state_changed.emit()
func get_save_data() -> Dictionary:
return {
"character_positions": _character_positions,
"object_states": _object_states,
"current_room": current_room,
}
func apply_save_data(data: Dictionary) -> void:
if data.has("character_positions"):
_character_positions = data["character_positions"]
if data.has("object_states"):
_object_states = data["object_states"]
if data.has("current_room"):
current_room = data["current_room"]

View File

@@ -0,0 +1,30 @@
## InputManager — abstracts touch and mouse input into unified drag signals.
extends Node
signal drag_started(position: Vector2)
signal drag_moved(position: Vector2)
signal drag_ended(position: Vector2)
var _is_dragging: bool = false
func _input(event: InputEvent) -> void:
if event is InputEventScreenTouch:
if event.pressed:
_is_dragging = true
drag_started.emit(event.position)
else:
_is_dragging = false
drag_ended.emit(event.position)
elif event is InputEventScreenDrag:
if _is_dragging:
drag_moved.emit(event.position)
elif event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
if event.pressed:
_is_dragging = true
drag_started.emit(event.position)
else:
_is_dragging = false
drag_ended.emit(event.position)
elif event is InputEventMouseMotion and _is_dragging:
drag_moved.emit(event.position)

View File

@@ -0,0 +1,40 @@
## SaveManager — persists game state as JSON to user://savegame.json, auto-saves on state_changed.
extends Node
const SAVE_PATH: String = "user://savegame.json"
func _ready() -> void:
GameState.state_changed.connect(_on_state_changed)
func save_game() -> void:
var data: Dictionary = GameState.get_save_data()
var file: FileAccess = FileAccess.open(SAVE_PATH, FileAccess.WRITE)
if file == null:
return
file.store_string(JSON.stringify(data))
file.close()
func load_game() -> void:
if not FileAccess.file_exists(SAVE_PATH):
return
var file: FileAccess = FileAccess.open(SAVE_PATH, FileAccess.READ)
if file == null:
return
var raw: String = file.get_as_text()
file.close()
var parsed = JSON.parse_string(raw)
if parsed is Dictionary:
GameState.apply_save_data(parsed)
func reset_game() -> void:
if FileAccess.file_exists(SAVE_PATH):
DirAccess.remove_absolute(SAVE_PATH)
GameState.apply_save_data({})
func _on_state_changed() -> void:
save_game()