initialising physics-based approach to laying cards on a board
This commit is contained in:
parent
2fb69e6df1
commit
5642df52dc
|
|
@ -0,0 +1,17 @@
|
||||||
|
extends Area2D
|
||||||
|
|
||||||
|
@export_range(1.0, 10.0) var bounce_speed: float = 5
|
||||||
|
|
||||||
|
@onready var diameter = $CollisionShape2D.shape.radius * 2
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta):
|
||||||
|
if get_overlapping_areas().size() > 0:
|
||||||
|
for area in get_overlapping_areas():
|
||||||
|
var diff:Vector2 = position - area.position
|
||||||
|
position -= diff.normalized() * ((diff.length()-diameter)/diameter) * bounce_speed * (delta/(1.0/60))
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
extends PanelContainer
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta):
|
||||||
|
pass
|
||||||
|
|
@ -0,0 +1,132 @@
|
||||||
|
[gd_scene load_steps=9 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="Shader" path="res://logic-scenes/board/physics-board.gdshader" id="1_ggnth"]
|
||||||
|
[ext_resource type="Script" path="res://logic-scenes/board/card-board.gd" id="3_8v4c4"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dy5rd437h5hsw" path="res://logic-scenes/board/card.tscn" id="3_mg053"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bvowj4l8dtceu" path="res://dev-util/board of devs.tscn" id="4_sskx2"]
|
||||||
|
[ext_resource type="Script" path="res://logic-scenes/board/bouncy-card.gd" id="6_gcxd7"]
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ttqei"]
|
||||||
|
shader = ExtResource("1_ggnth")
|
||||||
|
shader_parameter/magic_scale_factor = 1500.0
|
||||||
|
shader_parameter/tex = ExtResource("1_8brxc")
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_x8rl2"]
|
||||||
|
radius = 154.052
|
||||||
|
|
||||||
|
[node name="Panel" type="PanelContainer"]
|
||||||
|
material = SubResource("ShaderMaterial_ttqei")
|
||||||
|
clip_contents = true
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
size_flags_horizontal = 6
|
||||||
|
size_flags_vertical = 6
|
||||||
|
script = ExtResource("3_8v4c4")
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="VSeparator" type="VSeparator" parent="HBoxContainer"]
|
||||||
|
custom_minimum_size = Vector2(20, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="VBoxContainer2" type="VBoxContainer" parent="HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="GridContainer" type="VFlowContainer" parent="HBoxContainer/VBoxContainer2"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="card-ancor" type="Panel" parent="HBoxContainer/VBoxContainer2/GridContainer"]
|
||||||
|
custom_minimum_size = Vector2(400, 250)
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="card" parent="HBoxContainer/VBoxContainer2/GridContainer/card-ancor" instance=ExtResource("3_mg053")]
|
||||||
|
layout_mode = 2
|
||||||
|
offset_left = 0.0
|
||||||
|
offset_top = 0.0
|
||||||
|
offset_right = 0.0
|
||||||
|
offset_bottom = 0.0
|
||||||
|
|
||||||
|
[node name="card-ancor2" type="Panel" parent="HBoxContainer/VBoxContainer2/GridContainer"]
|
||||||
|
custom_minimum_size = Vector2(400, 250)
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="card" parent="HBoxContainer/VBoxContainer2/GridContainer/card-ancor2" instance=ExtResource("3_mg053")]
|
||||||
|
layout_mode = 2
|
||||||
|
offset_left = 0.0
|
||||||
|
offset_top = 0.0
|
||||||
|
offset_right = 0.0
|
||||||
|
offset_bottom = 0.0
|
||||||
|
|
||||||
|
[node name="VBoxContainer3" type="VBoxContainer" parent="HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 8
|
||||||
|
|
||||||
|
[node name="CenterContainer" type="ScrollContainer" parent="HBoxContainer/VBoxContainer3"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
horizontal_scroll_mode = 0
|
||||||
|
|
||||||
|
[node name="post-ancor" type="Panel" parent="HBoxContainer/VBoxContainer3/CenterContainer"]
|
||||||
|
custom_minimum_size = Vector2(320, 110)
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="board of devs" parent="." instance=ExtResource("4_sskx2")]
|
||||||
|
visible = false
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="RigidBody2D" type="Area2D" parent="Node2D"]
|
||||||
|
position = Vector2(686, 379)
|
||||||
|
script = ExtResource("6_gcxd7")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Node2D/RigidBody2D"]
|
||||||
|
shape = SubResource("CircleShape2D_x8rl2")
|
||||||
|
|
||||||
|
[node name="ancor" type="Node2D" parent="Node2D/RigidBody2D"]
|
||||||
|
position = Vector2(-151, -107)
|
||||||
|
|
||||||
|
[node name="card2" parent="Node2D/RigidBody2D/ancor" instance=ExtResource("3_mg053")]
|
||||||
|
offset_left = 0.0
|
||||||
|
offset_top = 0.0
|
||||||
|
offset_right = 0.0
|
||||||
|
offset_bottom = 0.0
|
||||||
|
|
||||||
|
[node name="RigidBody2D2" type="Area2D" parent="Node2D"]
|
||||||
|
position = Vector2(742, 323)
|
||||||
|
script = ExtResource("6_gcxd7")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Node2D/RigidBody2D2"]
|
||||||
|
shape = SubResource("CircleShape2D_x8rl2")
|
||||||
|
|
||||||
|
[node name="ancor" type="Node2D" parent="Node2D/RigidBody2D2"]
|
||||||
|
position = Vector2(-151, -107)
|
||||||
|
|
||||||
|
[node name="card2" parent="Node2D/RigidBody2D2/ancor" instance=ExtResource("3_mg053")]
|
||||||
|
offset_left = 0.0
|
||||||
|
offset_top = 0.0
|
||||||
|
offset_right = 0.0
|
||||||
|
offset_bottom = 0.0
|
||||||
|
|
||||||
|
[node name="RigidBody2D3" type="Area2D" parent="Node2D"]
|
||||||
|
position = Vector2(694, 353)
|
||||||
|
script = ExtResource("6_gcxd7")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Node2D/RigidBody2D3"]
|
||||||
|
shape = SubResource("CircleShape2D_x8rl2")
|
||||||
|
|
||||||
|
[node name="ancor" type="Node2D" parent="Node2D/RigidBody2D3"]
|
||||||
|
position = Vector2(-151, -107)
|
||||||
|
|
||||||
|
[node name="card2" parent="Node2D/RigidBody2D3/ancor" instance=ExtResource("3_mg053")]
|
||||||
|
offset_left = 0.0
|
||||||
|
offset_top = 0.0
|
||||||
|
offset_right = 0.0
|
||||||
|
offset_bottom = 0.0
|
||||||
Loading…
Reference in New Issue