diff --git a/levels/base_level/base_level.tscn b/levels/base_level/base_level.tscn index 9888a29..fb898ac 100644 --- a/levels/base_level/base_level.tscn +++ b/levels/base_level/base_level.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=15 format=3 uid="uid://cother2aiigge"] +[gd_scene load_steps=16 format=3 uid="uid://cother2aiigge"] [ext_resource type="Script" path="res://levels/base_level/base_level.gd" id="1_diojb"] [ext_resource type="PackedScene" uid="uid://bepyyenjtc0p3" path="res://levels/chapter_menu/level_menu/level_button/level_button.tscn" id="2_0egdl"] @@ -12,6 +12,7 @@ [ext_resource type="Texture2D" uid="uid://cuyseoi8y3567" path="res://objects/styled_button/replay1.png" id="7_xfna7"] [ext_resource type="Texture2D" uid="uid://dhjiokm51casd" path="res://objects/styled_button/replay2.png" id="8_60asn"] [ext_resource type="Texture2D" uid="uid://btyxqeveaeh6h" path="res://objects/styled_button/replay3.png" id="9_gpaci"] +[ext_resource type="PackedScene" uid="uid://csl5lwjicxroy" path="res://levels/base_level/scroll_area/scroll_area.tscn" id="11_jgqxp"] [sub_resource type="SpriteFrames" id="SpriteFrames_yulkh"] animations = [{ @@ -81,6 +82,13 @@ sprite_frames = SubResource("SpriteFrames_5hm0m") animation = &"replay" centered = false +[node name="ScrollLeftArea" parent="HUDs" instance=ExtResource("11_jgqxp")] +position = Vector2(32, 135) + +[node name="ScrollRightArea" parent="HUDs" instance=ExtResource("11_jgqxp")] +position = Vector2(448, 135) +is_on_left = false + [node name="Cards" type="Node" parent="."] [node name="Blocks" type="Node" parent="."] diff --git a/levels/base_level/scroll_area/scroll_area.gd b/levels/base_level/scroll_area/scroll_area.gd new file mode 100644 index 0000000..b5d532f --- /dev/null +++ b/levels/base_level/scroll_area/scroll_area.gd @@ -0,0 +1,41 @@ +extends Area2D + + +const WIDTH := 1920 / 4 +const PADDING := 32 +const SPEED := 300 + + +@export var is_on_left := true + +var is_mouse_on = false + + + +func _process(delta: float): + if self.is_mouse_on: + if get_tree().root.has_node("BaseLevel/HUDs/TableCloth"): + var table_cloth_node = get_tree().root.get_node("BaseLevel/HUDs/TableCloth") + var offset := 0 + + if table_cloth_node.size.x < WIDTH: + return + + if self.is_on_left and table_cloth_node.position.x < PADDING: + offset = min(PADDING - table_cloth_node.position.x, int(delta * SPEED + 0.5)) + elif not self.is_on_left and table_cloth_node.position.x + table_cloth_node.size.x > WIDTH - PADDING: + offset = -min(table_cloth_node.position.x + table_cloth_node.size.x - (WIDTH - PADDING), int(delta * SPEED + 0.5)) + + if offset != 0: + table_cloth_node.position.x += offset + for block: Block in get_tree().root.get_node("BaseLevel/Blocks").get_children(): + block.position.x += offset + if block.occupied_card != null: + block.occupied_card.position.x += offset + + +func _on_mouse_exited(): + self.is_mouse_on = false + +func _on_mouse_entered(): + self.is_mouse_on = true diff --git a/levels/base_level/scroll_area/scroll_area.tscn b/levels/base_level/scroll_area/scroll_area.tscn new file mode 100644 index 0000000..9b13e66 --- /dev/null +++ b/levels/base_level/scroll_area/scroll_area.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=3 format=3 uid="uid://csl5lwjicxroy"] + +[ext_resource type="Script" path="res://levels/base_level/scroll_area/scroll_area.gd" id="1_j4m6q"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_dbovb"] +size = Vector2(64, 200) + +[node name="ScrollArea" type="Area2D"] +script = ExtResource("1_j4m6q") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_dbovb") +debug_color = Color(0, 0.6, 0.701961, 0.419608) + +[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"] +[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]