adding borders to keep cards on board
This commit is contained in:
parent
b2f944379e
commit
2af5d11966
|
|
@ -96,6 +96,9 @@ func _process(delta: float) -> void:
|
||||||
if get_overlapping_areas().size() > 0:
|
if get_overlapping_areas().size() > 0:
|
||||||
for area in get_overlapping_areas():
|
for area in get_overlapping_areas():
|
||||||
if area.get_meta("type") != "post-it" and not area.is_dragged:
|
if area.get_meta("type") != "post-it" and not area.is_dragged:
|
||||||
|
if "direction" in area:
|
||||||
|
position += area.direction * delta
|
||||||
|
else:
|
||||||
var diff:Vector2 = position - area.position
|
var diff:Vector2 = position - area.position
|
||||||
position -= diff.normalized() * ((diff.length()-diameter)/diameter) * bounce_speed * (delta/(1.0/60))
|
position -= diff.normalized() * ((diff.length()-diameter)/diameter) * bounce_speed * (delta/(1.0/60))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=7 format=3 uid="uid://bnskiyx1sksww"]
|
[gd_scene load_steps=10 format=3 uid="uid://bnskiyx1sksww"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://bi3xqdknw5tpe" path="res://logic-scenes/board/board-texture/Cork002_2K_Color.png" id="1_8brxc"]
|
[ext_resource type="Texture2D" uid="uid://bi3xqdknw5tpe" path="res://logic-scenes/board/board-texture/Cork002_2K_Color.png" id="1_8brxc"]
|
||||||
[ext_resource type="Shader" path="res://logic-scenes/board/physics-board.gdshader" id="1_ggnth"]
|
[ext_resource type="Shader" path="res://logic-scenes/board/physics-board.gdshader" id="1_ggnth"]
|
||||||
|
|
@ -11,6 +11,20 @@ shader = ExtResource("1_ggnth")
|
||||||
shader_parameter/magic_scale_factor = 1500.0
|
shader_parameter/magic_scale_factor = 1500.0
|
||||||
shader_parameter/tex = ExtResource("1_8brxc")
|
shader_parameter/tex = ExtResource("1_8brxc")
|
||||||
|
|
||||||
|
[sub_resource type="GDScript" id="GDScript_f5ap5"]
|
||||||
|
script/source = "extends Area2D
|
||||||
|
|
||||||
|
var is_dragged: bool = false
|
||||||
|
@export var direction: Vector2 = Vector2.ZERO
|
||||||
|
|
||||||
|
"
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ivo5o"]
|
||||||
|
size = Vector2(4249, 766.5)
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5ri3m"]
|
||||||
|
size = Vector2(4262, 766.5)
|
||||||
|
|
||||||
[node name="board" type="PanelContainer"]
|
[node name="board" type="PanelContainer"]
|
||||||
material = SubResource("ShaderMaterial_ttqei")
|
material = SubResource("ShaderMaterial_ttqei")
|
||||||
clip_contents = true
|
clip_contents = true
|
||||||
|
|
@ -69,3 +83,66 @@ position = Vector2(105, 57)
|
||||||
process_mode = 4
|
process_mode = 4
|
||||||
visible = false
|
visible = false
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="border_right" type="Area2D" parent="."]
|
||||||
|
position = Vector2(1872, 461)
|
||||||
|
script = SubResource("GDScript_f5ap5")
|
||||||
|
direction = Vector2(-100, 0)
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="border_right"]
|
||||||
|
rotation = 1.5708
|
||||||
|
shape = SubResource("RectangleShape2D_ivo5o")
|
||||||
|
|
||||||
|
[node name="up" type="Control" parent="."]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
size_flags_vertical = 0
|
||||||
|
|
||||||
|
[node name="border_up" type="Area2D" parent="up"]
|
||||||
|
script = SubResource("GDScript_f5ap5")
|
||||||
|
direction = Vector2(0, 100)
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="up/border_up"]
|
||||||
|
position = Vector2(-58, -423)
|
||||||
|
shape = SubResource("RectangleShape2D_5ri3m")
|
||||||
|
|
||||||
|
[node name="left" type="Control" parent="."]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 0
|
||||||
|
size_flags_vertical = 4
|
||||||
|
|
||||||
|
[node name="border_left" type="Area2D" parent="left"]
|
||||||
|
script = SubResource("GDScript_f5ap5")
|
||||||
|
direction = Vector2(100, 0)
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="left/border_left"]
|
||||||
|
position = Vector2(-476, -22.5)
|
||||||
|
rotation = 1.5708
|
||||||
|
shape = SubResource("RectangleShape2D_ivo5o")
|
||||||
|
|
||||||
|
[node name="down" type="Control" parent="."]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 4
|
||||||
|
size_flags_vertical = 8
|
||||||
|
|
||||||
|
[node name="border_down" type="Area2D" parent="down"]
|
||||||
|
script = SubResource("GDScript_f5ap5")
|
||||||
|
direction = Vector2(0, -100)
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="down/border_down"]
|
||||||
|
position = Vector2(2, 416)
|
||||||
|
shape = SubResource("RectangleShape2D_5ri3m")
|
||||||
|
|
||||||
|
[node name="right" type="Control" parent="."]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 8
|
||||||
|
size_flags_vertical = 4
|
||||||
|
|
||||||
|
[node name="border_left" type="Area2D" parent="right"]
|
||||||
|
script = SubResource("GDScript_f5ap5")
|
||||||
|
direction = Vector2(-100, 0)
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="right/border_left"]
|
||||||
|
position = Vector2(12, 13)
|
||||||
|
rotation = 1.5708
|
||||||
|
shape = SubResource("RectangleShape2D_ivo5o")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue