Compare commits
7 Commits
adefc59bea
...
cda31fcac9
| Author | SHA1 | Date | |
|---|---|---|---|
| cda31fcac9 | |||
| c697b996d8 | |||
| ec473dc4e3 | |||
| 2cb265c922 | |||
| 666648c154 | |||
| 6a5a18ca42 | |||
| 14a50364f3 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,10 +1,12 @@
|
|||||||
[gd_scene load_steps=6 format=3 uid="uid://cozypaw_gardenparty"]
|
[gd_scene load_steps=8 format=3 uid="uid://cozypaw_gardenparty"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" path="res://scenes/objects/GiftBox.tscn" id="1_giftbox"]
|
[ext_resource type="PackedScene" path="res://scenes/objects/GiftBox.tscn" id="1_giftbox"]
|
||||||
[ext_resource type="PackedScene" path="res://scenes/objects/TeaPot.tscn" id="2_teapot"]
|
[ext_resource type="PackedScene" path="res://scenes/objects/TeaPot.tscn" id="2_teapot"]
|
||||||
[ext_resource type="PackedScene" path="res://scenes/objects/HomeButton.tscn" id="3_homebtn"]
|
[ext_resource type="PackedScene" path="res://scenes/objects/HomeButton.tscn" id="3_homebtn"]
|
||||||
[ext_resource type="Script" path="res://scripts/objects/snap_point.gd" id="4_snap"]
|
[ext_resource type="Script" path="res://scripts/objects/snap_point.gd" id="4_snap"]
|
||||||
[ext_resource type="Script" path="res://scripts/objects/room_chest.gd" id="5_chest"]
|
[ext_resource type="Script" path="res://scripts/objects/room_chest.gd" id="5_chest"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/objects/balloon.gd" id="6_balloon"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/objects/cake.gd" id="7_cake"]
|
||||||
|
|
||||||
[node name="GardenParty" type="Node2D"]
|
[node name="GardenParty" type="Node2D"]
|
||||||
|
|
||||||
@@ -59,8 +61,24 @@ position = Vector2(640, 464)
|
|||||||
[node name="GiftBox2" parent="." instance=ExtResource("1_giftbox")]
|
[node name="GiftBox2" parent="." instance=ExtResource("1_giftbox")]
|
||||||
position = Vector2(730, 464)
|
position = Vector2(730, 464)
|
||||||
|
|
||||||
[node name="GiftBox3" parent="." instance=ExtResource("1_giftbox")]
|
[node name="Cake" type="Node2D" parent="."]
|
||||||
position = Vector2(820, 464)
|
position = Vector2(820, 464)
|
||||||
|
script = ExtResource("7_cake")
|
||||||
|
|
||||||
|
[node name="Base" type="ColorRect" parent="Cake"]
|
||||||
|
offset_left = -40.0
|
||||||
|
offset_top = -20.0
|
||||||
|
offset_right = 40.0
|
||||||
|
offset_bottom = 20.0
|
||||||
|
color = Color(0.72, 0.52, 0.32, 1)
|
||||||
|
|
||||||
|
[node name="Slice" type="ColorRect" parent="Cake"]
|
||||||
|
offset_left = 5.0
|
||||||
|
offset_top = -22.0
|
||||||
|
offset_right = 33.0
|
||||||
|
offset_bottom = 18.0
|
||||||
|
color = Color(0.88, 0.74, 0.58, 1)
|
||||||
|
rotation = 0.15
|
||||||
|
|
||||||
[node name="TeaCup" type="ColorRect" parent="."]
|
[node name="TeaCup" type="ColorRect" parent="."]
|
||||||
offset_left = 558.0
|
offset_left = 558.0
|
||||||
@@ -69,28 +87,50 @@ offset_right = 590.0
|
|||||||
offset_bottom = 464.0
|
offset_bottom = 464.0
|
||||||
color = Color(0.96, 0.92, 0.84, 1)
|
color = Color(0.96, 0.92, 0.84, 1)
|
||||||
|
|
||||||
[node name="Balloon1" type="ColorRect" parent="."]
|
[node name="Balloon1" type="Node2D" parent="."]
|
||||||
offset_left = 180.0
|
position = Vector2(200, 150)
|
||||||
offset_top = 120.0
|
script = ExtResource("6_balloon")
|
||||||
offset_right = 220.0
|
|
||||||
offset_bottom = 180.0
|
[node name="Body" type="ColorRect" parent="Balloon1"]
|
||||||
|
offset_left = -20.0
|
||||||
|
offset_top = -30.0
|
||||||
|
offset_right = 20.0
|
||||||
|
offset_bottom = 30.0
|
||||||
color = Color(0.96, 0.44, 0.44, 1)
|
color = Color(0.96, 0.44, 0.44, 1)
|
||||||
|
|
||||||
[node name="Balloon2" type="ColorRect" parent="."]
|
[node name="Balloon2" type="Node2D" parent="."]
|
||||||
offset_left = 1020.0
|
position = Vector2(1040, 130)
|
||||||
offset_top = 100.0
|
script = ExtResource("6_balloon")
|
||||||
offset_right = 1060.0
|
|
||||||
offset_bottom = 160.0
|
[node name="Body" type="ColorRect" parent="Balloon2"]
|
||||||
|
offset_left = -20.0
|
||||||
|
offset_top = -30.0
|
||||||
|
offset_right = 20.0
|
||||||
|
offset_bottom = 30.0
|
||||||
color = Color(0.56, 0.76, 0.96, 1)
|
color = Color(0.56, 0.76, 0.96, 1)
|
||||||
|
|
||||||
[node name="HomeButtonReturn" parent="." instance=ExtResource("3_homebtn")]
|
[node name="HomeButtonReturn" parent="." instance=ExtResource("3_homebtn")]
|
||||||
position = Vector2(100, 620)
|
position = Vector2(100, 620)
|
||||||
go_to_garden = false
|
go_to_garden = false
|
||||||
|
|
||||||
|
[node name="ChairLeft" type="ColorRect" parent="."]
|
||||||
|
offset_left = 500.0
|
||||||
|
offset_top = 476.0
|
||||||
|
offset_right = 560.0
|
||||||
|
offset_bottom = 496.0
|
||||||
|
color = Color(0.60, 0.42, 0.26, 1)
|
||||||
|
|
||||||
[node name="SnapTableLeft" type="Node2D" parent="."]
|
[node name="SnapTableLeft" type="Node2D" parent="."]
|
||||||
position = Vector2(530, 455)
|
position = Vector2(530, 455)
|
||||||
script = ExtResource("4_snap")
|
script = ExtResource("4_snap")
|
||||||
|
|
||||||
|
[node name="ChairRight" type="ColorRect" parent="."]
|
||||||
|
offset_left = 720.0
|
||||||
|
offset_top = 476.0
|
||||||
|
offset_right = 780.0
|
||||||
|
offset_bottom = 496.0
|
||||||
|
color = Color(0.60, 0.42, 0.26, 1)
|
||||||
|
|
||||||
[node name="SnapTableRight" type="Node2D" parent="."]
|
[node name="SnapTableRight" type="Node2D" parent="."]
|
||||||
position = Vector2(750, 455)
|
position = Vector2(750, 455)
|
||||||
script = ExtResource("4_snap")
|
script = ExtResource("4_snap")
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
## Balloon — tap to pop, auto-respawns after a delay.
|
||||||
|
class_name Balloon extends Node2D
|
||||||
|
|
||||||
|
enum State { IDLE, POPPING, POPPED, RESPAWNING }
|
||||||
|
|
||||||
|
const POP_DURATION: float = 0.15
|
||||||
|
const RESPAWN_DURATION: float = 0.30
|
||||||
|
const RESPAWN_DELAY: float = 5.0
|
||||||
|
const BUTTON_HALF_SIZE: float = 20.0
|
||||||
|
|
||||||
|
var _state: State = State.IDLE
|
||||||
|
|
||||||
|
|
||||||
|
func _input(event: InputEvent) -> void:
|
||||||
|
if _state != State.IDLE:
|
||||||
|
return
|
||||||
|
if not event is InputEventScreenTouch:
|
||||||
|
return
|
||||||
|
var touch: InputEventScreenTouch = event as InputEventScreenTouch
|
||||||
|
if not touch.pressed:
|
||||||
|
return
|
||||||
|
var local: Vector2 = to_local(touch.position)
|
||||||
|
if abs(local.x) > BUTTON_HALF_SIZE or abs(local.y) > BUTTON_HALF_SIZE:
|
||||||
|
return
|
||||||
|
_start_pop()
|
||||||
|
|
||||||
|
|
||||||
|
func _start_pop() -> void:
|
||||||
|
AudioManager.play_sfx("object_tap")
|
||||||
|
_state = State.POPPING
|
||||||
|
var tween: Tween = create_tween()
|
||||||
|
tween.set_ease(Tween.EASE_IN)
|
||||||
|
tween.set_trans(Tween.TRANS_BACK)
|
||||||
|
tween.tween_property(self, "scale", Vector2.ZERO, POP_DURATION)
|
||||||
|
tween.tween_callback(_on_pop_complete)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_pop_complete() -> void:
|
||||||
|
_state = State.POPPED
|
||||||
|
var tween: Tween = create_tween()
|
||||||
|
tween.tween_interval(RESPAWN_DELAY)
|
||||||
|
tween.tween_callback(_start_respawn)
|
||||||
|
|
||||||
|
|
||||||
|
func _start_respawn() -> void:
|
||||||
|
_state = State.RESPAWNING
|
||||||
|
var tween: Tween = create_tween()
|
||||||
|
tween.set_ease(Tween.EASE_OUT)
|
||||||
|
tween.set_trans(Tween.TRANS_BACK)
|
||||||
|
tween.tween_property(self, "scale", Vector2.ONE, RESPAWN_DURATION)
|
||||||
|
tween.tween_callback(_on_respawn_complete)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_respawn_complete() -> void:
|
||||||
|
_state = State.IDLE
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
## Cake — tap to cut a slice, slice auto-respawns after a delay.
|
||||||
|
class_name Cake extends Node2D
|
||||||
|
|
||||||
|
enum State { WHOLE, CUTTING, CUT, RESETTING }
|
||||||
|
|
||||||
|
const CUT_DURATION: float = 0.3
|
||||||
|
const RESET_DURATION: float = 0.3
|
||||||
|
const RESET_DELAY: float = 3.0
|
||||||
|
const BUTTON_HALF_WIDTH: float = 40.0
|
||||||
|
const BUTTON_HALF_HEIGHT: float = 20.0
|
||||||
|
|
||||||
|
var _state: State = State.WHOLE
|
||||||
|
|
||||||
|
|
||||||
|
func _input(event: InputEvent) -> void:
|
||||||
|
if _state != State.WHOLE:
|
||||||
|
return
|
||||||
|
if not event is InputEventScreenTouch:
|
||||||
|
return
|
||||||
|
var touch: InputEventScreenTouch = event as InputEventScreenTouch
|
||||||
|
if not touch.pressed:
|
||||||
|
return
|
||||||
|
var local: Vector2 = to_local(touch.position)
|
||||||
|
if abs(local.x) > BUTTON_HALF_WIDTH or abs(local.y) > BUTTON_HALF_HEIGHT:
|
||||||
|
return
|
||||||
|
_start_cutting()
|
||||||
|
|
||||||
|
|
||||||
|
func _start_cutting() -> void:
|
||||||
|
AudioManager.play_sfx("object_tap")
|
||||||
|
_state = State.CUTTING
|
||||||
|
var slice: Node2D = get_node_or_null("Slice") as Node2D
|
||||||
|
var tween: Tween = create_tween()
|
||||||
|
if slice != null:
|
||||||
|
tween.tween_property(slice, "modulate:a", 0.0, CUT_DURATION)
|
||||||
|
tween.tween_callback(_on_cut_complete)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_cut_complete() -> void:
|
||||||
|
_state = State.CUT
|
||||||
|
var tween: Tween = create_tween()
|
||||||
|
tween.tween_interval(RESET_DELAY)
|
||||||
|
tween.tween_callback(_start_reset)
|
||||||
|
|
||||||
|
|
||||||
|
func _start_reset() -> void:
|
||||||
|
_state = State.RESETTING
|
||||||
|
var slice: Node2D = get_node_or_null("Slice") as Node2D
|
||||||
|
var tween: Tween = create_tween()
|
||||||
|
if slice != null:
|
||||||
|
tween.tween_property(slice, "modulate:a", 1.0, RESET_DURATION)
|
||||||
|
tween.tween_callback(_on_reset_complete)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_reset_complete() -> void:
|
||||||
|
_state = State.WHOLE
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
## GiftBox — tap while closed to open: lid rises and fades out, gift inside fades in.
|
## GiftBox — tap while closed to open: lid rises and fades out, gift inside fades in.
|
||||||
|
## Auto-resets after RESET_DELAY seconds.
|
||||||
class_name GiftBox extends Node2D
|
class_name GiftBox extends Node2D
|
||||||
|
|
||||||
enum State { CLOSED, OPENING, OPEN }
|
enum State { CLOSED, OPENING, RESETTING }
|
||||||
|
|
||||||
const LID_OPEN_Y: float = -120.0
|
const LID_OPEN_Y: float = -120.0
|
||||||
|
const CLOSED_LID_Y: float = -60.0
|
||||||
const OPEN_DURATION: float = 0.5
|
const OPEN_DURATION: float = 0.5
|
||||||
const GIFT_FADE_DURATION: float = 0.4
|
const GIFT_FADE_DURATION: float = 0.4
|
||||||
|
const RESET_DELAY: float = 3.0
|
||||||
const BUTTON_HALF_WIDTH: float = 40.0
|
const BUTTON_HALF_WIDTH: float = 40.0
|
||||||
const BUTTON_HALF_HEIGHT: float = 50.0
|
const BUTTON_HALF_HEIGHT: float = 50.0
|
||||||
|
|
||||||
@@ -37,7 +40,7 @@ func _start_opening() -> void:
|
|||||||
_state = State.OPENING
|
_state = State.OPENING
|
||||||
var lid: Node2D = get_node_or_null("Lid") as Node2D
|
var lid: Node2D = get_node_or_null("Lid") as Node2D
|
||||||
if lid == null:
|
if lid == null:
|
||||||
_state = State.OPEN
|
_on_lid_opened()
|
||||||
return
|
return
|
||||||
var tween: Tween = create_tween()
|
var tween: Tween = create_tween()
|
||||||
tween.set_ease(Tween.EASE_OUT)
|
tween.set_ease(Tween.EASE_OUT)
|
||||||
@@ -48,9 +51,26 @@ func _start_opening() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_lid_opened() -> void:
|
func _on_lid_opened() -> void:
|
||||||
_state = State.OPEN
|
_state = State.RESETTING
|
||||||
var gift: Node2D = get_node_or_null("Gift") as Node2D
|
var gift: Node2D = get_node_or_null("Gift") as Node2D
|
||||||
if gift == null:
|
|
||||||
return
|
|
||||||
var tween: Tween = create_tween()
|
var tween: Tween = create_tween()
|
||||||
|
if gift != null:
|
||||||
tween.tween_property(gift, "modulate:a", 1.0, GIFT_FADE_DURATION)
|
tween.tween_property(gift, "modulate:a", 1.0, GIFT_FADE_DURATION)
|
||||||
|
tween.tween_interval(RESET_DELAY)
|
||||||
|
tween.tween_callback(_start_close_lid)
|
||||||
|
|
||||||
|
|
||||||
|
func _start_close_lid() -> void:
|
||||||
|
var lid: Node2D = get_node_or_null("Lid") as Node2D
|
||||||
|
var gift: Node2D = get_node_or_null("Gift") as Node2D
|
||||||
|
var tween: Tween = create_tween()
|
||||||
|
if lid != null:
|
||||||
|
tween.parallel().tween_property(lid, "position:y", CLOSED_LID_Y, OPEN_DURATION)
|
||||||
|
tween.parallel().tween_property(lid, "modulate:a", 1.0, OPEN_DURATION)
|
||||||
|
if gift != null:
|
||||||
|
tween.parallel().tween_property(gift, "modulate:a", 0.0, OPEN_DURATION)
|
||||||
|
tween.tween_callback(_on_reset_complete)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_reset_complete() -> void:
|
||||||
|
_state = State.CLOSED
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
## Tests for Balloon — state machine transitions.
|
||||||
|
extends GutTest
|
||||||
|
|
||||||
|
const BalloonScript = preload("res://scripts/objects/balloon.gd")
|
||||||
|
|
||||||
|
var _balloon: Node2D
|
||||||
|
|
||||||
|
|
||||||
|
func before_each() -> void:
|
||||||
|
_balloon = BalloonScript.new()
|
||||||
|
add_child_autofree(_balloon)
|
||||||
|
|
||||||
|
|
||||||
|
func test_initial_state_is_idle() -> void:
|
||||||
|
assert_eq(_balloon._state, BalloonScript.State.IDLE)
|
||||||
|
|
||||||
|
|
||||||
|
func test_start_pop_transitions_to_popping() -> void:
|
||||||
|
_balloon._start_pop()
|
||||||
|
assert_eq(_balloon._state, BalloonScript.State.POPPING)
|
||||||
|
|
||||||
|
|
||||||
|
func test_on_pop_complete_transitions_to_popped() -> void:
|
||||||
|
_balloon._on_pop_complete()
|
||||||
|
assert_eq(_balloon._state, BalloonScript.State.POPPED)
|
||||||
|
|
||||||
|
|
||||||
|
func test_on_respawn_complete_transitions_to_idle() -> void:
|
||||||
|
_balloon._state = BalloonScript.State.RESPAWNING
|
||||||
|
_balloon._on_respawn_complete()
|
||||||
|
assert_eq(_balloon._state, BalloonScript.State.IDLE)
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
## Tests for Cake — state machine transitions.
|
||||||
|
extends GutTest
|
||||||
|
|
||||||
|
const CakeScript = preload("res://scripts/objects/cake.gd")
|
||||||
|
|
||||||
|
var _cake: Node2D
|
||||||
|
|
||||||
|
|
||||||
|
func before_each() -> void:
|
||||||
|
_cake = CakeScript.new()
|
||||||
|
add_child_autofree(_cake)
|
||||||
|
|
||||||
|
|
||||||
|
func test_initial_state_is_whole() -> void:
|
||||||
|
assert_eq(_cake._state, CakeScript.State.WHOLE)
|
||||||
|
|
||||||
|
|
||||||
|
func test_start_cutting_transitions_to_cutting() -> void:
|
||||||
|
_cake._start_cutting()
|
||||||
|
assert_eq(_cake._state, CakeScript.State.CUTTING)
|
||||||
|
|
||||||
|
|
||||||
|
func test_on_cut_complete_transitions_to_cut() -> void:
|
||||||
|
_cake._on_cut_complete()
|
||||||
|
assert_eq(_cake._state, CakeScript.State.CUT)
|
||||||
|
|
||||||
|
|
||||||
|
func test_on_reset_complete_transitions_to_whole() -> void:
|
||||||
|
_cake._state = CakeScript.State.RESETTING
|
||||||
|
_cake._on_reset_complete()
|
||||||
|
assert_eq(_cake._state, CakeScript.State.WHOLE)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
## Tests for GiftBox — CLOSED/OPENING/OPEN state machine transitions.
|
## Tests for GiftBox — CLOSED/OPENING/RESETTING state machine transitions.
|
||||||
extends GutTest
|
extends GutTest
|
||||||
|
|
||||||
var _box: GiftBox
|
var _box: GiftBox
|
||||||
@@ -23,10 +23,10 @@ func test_start_opening_transitions_to_opening() -> void:
|
|||||||
assert_eq(_box._state, GiftBox.State.OPENING)
|
assert_eq(_box._state, GiftBox.State.OPENING)
|
||||||
|
|
||||||
|
|
||||||
func test_on_lid_opened_transitions_to_open() -> void:
|
func test_on_lid_opened_transitions_to_resetting() -> void:
|
||||||
_box._start_opening()
|
_box._start_opening()
|
||||||
_box._on_lid_opened()
|
_box._on_lid_opened()
|
||||||
assert_eq(_box._state, GiftBox.State.OPEN)
|
assert_eq(_box._state, GiftBox.State.RESETTING)
|
||||||
|
|
||||||
|
|
||||||
func test_input_ignored_when_state_is_opening() -> void:
|
func test_input_ignored_when_state_is_opening() -> void:
|
||||||
@@ -38,13 +38,13 @@ func test_input_ignored_when_state_is_opening() -> void:
|
|||||||
assert_eq(_box._state, GiftBox.State.OPENING)
|
assert_eq(_box._state, GiftBox.State.OPENING)
|
||||||
|
|
||||||
|
|
||||||
func test_input_ignored_when_state_is_open() -> void:
|
func test_input_ignored_when_state_is_resetting() -> void:
|
||||||
_box._state = GiftBox.State.OPEN
|
_box._state = GiftBox.State.RESETTING
|
||||||
var event: InputEventScreenTouch = InputEventScreenTouch.new()
|
var event: InputEventScreenTouch = InputEventScreenTouch.new()
|
||||||
event.pressed = true
|
event.pressed = true
|
||||||
event.position = _box.global_position
|
event.position = _box.global_position
|
||||||
_box._input(event)
|
_box._input(event)
|
||||||
assert_eq(_box._state, GiftBox.State.OPEN)
|
assert_eq(_box._state, GiftBox.State.RESETTING)
|
||||||
|
|
||||||
|
|
||||||
func test_tap_outside_hitbox_does_not_open() -> void:
|
func test_tap_outside_hitbox_does_not_open() -> void:
|
||||||
@@ -61,3 +61,9 @@ func test_release_event_does_not_open() -> void:
|
|||||||
event.position = _box.global_position
|
event.position = _box.global_position
|
||||||
_box._input(event)
|
_box._input(event)
|
||||||
assert_eq(_box._state, GiftBox.State.CLOSED)
|
assert_eq(_box._state, GiftBox.State.CLOSED)
|
||||||
|
|
||||||
|
|
||||||
|
func test_on_reset_complete_transitions_to_closed() -> void:
|
||||||
|
_box._state = GiftBox.State.RESETTING
|
||||||
|
_box._on_reset_complete()
|
||||||
|
assert_eq(_box._state, GiftBox.State.CLOSED)
|
||||||
|
|||||||
Reference in New Issue
Block a user