test_one_way_collision.tscn 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. [gd_scene load_steps=9 format=3 uid="uid://c85275leeliuq"]
  2. [ext_resource type="Script" path="res://tests/functional/test_one_way_collision.gd" id="1"]
  3. [ext_resource type="Texture2D" uid="uid://brwp8bimc75uu" path="res://icon.webp" id="2"]
  4. [ext_resource type="PackedScene" uid="uid://blh3twy74kbkv" path="res://tests/test_options.tscn" id="3"]
  5. [ext_resource type="Script" path="res://utils/label_slider_value.gd" id="4"]
  6. [ext_resource type="Script" path="res://utils/slider.gd" id="5"]
  7. [sub_resource type="CircleShape2D" id="CircleShape2D_e5nt1"]
  8. radius = 16.0
  9. [sub_resource type="RectangleShape2D" id="2"]
  10. size = Vector2(128, 64)
  11. [sub_resource type="RectangleShape2D" id="3"]
  12. size = Vector2(64, 64)
  13. [node name="Test" type="Node2D"]
  14. script = ExtResource("1")
  15. [node name="LabelTestType" type="Label" parent="."]
  16. offset_left = 14.0
  17. offset_top = 79.0
  18. offset_right = 145.0
  19. offset_bottom = 93.0
  20. text = "Testing: "
  21. [node name="Options" parent="." instance=ExtResource("3")]
  22. [node name="Controls" type="VBoxContainer" parent="."]
  23. anchors_preset = 15
  24. anchor_right = 1.0
  25. anchor_bottom = 1.0
  26. offset_left = 25.0
  27. offset_top = 402.0
  28. offset_right = 425.0
  29. offset_bottom = 500.0
  30. grow_horizontal = 2
  31. grow_vertical = 2
  32. theme_override_constants/separation = 10
  33. [node name="PlatformSize" type="HBoxContainer" parent="Controls"]
  34. layout_mode = 2
  35. theme_override_constants/separation = 20
  36. alignment = 2
  37. [node name="Label" type="Label" parent="Controls/PlatformSize"]
  38. custom_minimum_size = Vector2(120, 2.08165e-12)
  39. layout_mode = 2
  40. size_flags_horizontal = 0
  41. text = "Platform size"
  42. [node name="HSlider" type="HSlider" parent="Controls/PlatformSize"]
  43. custom_minimum_size = Vector2(200, 2.08165e-12)
  44. layout_mode = 2
  45. min_value = 64.0
  46. max_value = 256.0
  47. value = 64.0
  48. script = ExtResource("5")
  49. [node name="LabelValue" type="Label" parent="Controls/PlatformSize"]
  50. custom_minimum_size = Vector2(60, 2.08165e-12)
  51. layout_mode = 2
  52. text = "64.0"
  53. script = ExtResource("4")
  54. [node name="PlatformAngle" type="HBoxContainer" parent="Controls"]
  55. layout_mode = 2
  56. theme_override_constants/separation = 20
  57. alignment = 2
  58. [node name="Label" type="Label" parent="Controls/PlatformAngle"]
  59. custom_minimum_size = Vector2(120, 2.08165e-12)
  60. layout_mode = 2
  61. text = "Platform angle"
  62. [node name="HSlider" type="HSlider" parent="Controls/PlatformAngle"]
  63. custom_minimum_size = Vector2(200, 2.08165e-12)
  64. layout_mode = 2
  65. max_value = 360.0
  66. script = ExtResource("5")
  67. snap_step = 5.0
  68. [node name="LabelValue" type="Label" parent="Controls/PlatformAngle"]
  69. custom_minimum_size = Vector2(60, 2.08165e-12)
  70. layout_mode = 2
  71. text = "0.0"
  72. script = ExtResource("4")
  73. [node name="BodyAngle" type="HBoxContainer" parent="Controls"]
  74. layout_mode = 2
  75. theme_override_constants/separation = 20
  76. alignment = 2
  77. [node name="Label" type="Label" parent="Controls/BodyAngle"]
  78. custom_minimum_size = Vector2(120, 2.08165e-12)
  79. layout_mode = 2
  80. text = "Body angle"
  81. [node name="HSlider" type="HSlider" parent="Controls/BodyAngle"]
  82. custom_minimum_size = Vector2(200, 2.08165e-12)
  83. layout_mode = 2
  84. max_value = 360.0
  85. script = ExtResource("5")
  86. snap_step = 5.0
  87. [node name="LabelValue" type="Label" parent="Controls/BodyAngle"]
  88. custom_minimum_size = Vector2(60, 2.08165e-12)
  89. layout_mode = 2
  90. text = "0.0"
  91. script = ExtResource("4")
  92. [node name="LabelResultTitle" type="Label" parent="."]
  93. anchors_preset = 8
  94. anchor_left = 0.5
  95. anchor_top = 0.5
  96. anchor_right = 0.5
  97. anchor_bottom = 0.5
  98. offset_left = 34.1273
  99. offset_top = 251.131
  100. offset_right = 88.1273
  101. offset_bottom = 265.131
  102. text = "RESULT: "
  103. [node name="LabelResult" type="Label" parent="."]
  104. anchors_preset = 8
  105. anchor_left = 0.5
  106. anchor_top = 0.5
  107. anchor_right = 0.5
  108. anchor_bottom = 0.5
  109. offset_left = 34.1273
  110. offset_top = 266.131
  111. offset_right = 88.1273
  112. offset_bottom = 280.131
  113. text = "..."
  114. [node name="LabelRestart" type="Label" parent="."]
  115. anchors_preset = 8
  116. anchor_left = 0.5
  117. anchor_top = 0.5
  118. anchor_right = 0.5
  119. anchor_bottom = 0.5
  120. offset_left = 34.1273
  121. offset_top = 304.841
  122. offset_right = 139.127
  123. offset_bottom = 318.841
  124. text = "SPACE - RESTART"
  125. [node name="Timer" type="Timer" parent="."]
  126. wait_time = 5.0
  127. one_shot = true
  128. [node name="TargetArea2D" type="Area2D" parent="."]
  129. position = Vector2(512, 300)
  130. [node name="CollisionShape2D" type="CollisionShape2D" parent="TargetArea2D"]
  131. shape = SubResource("CircleShape2D_e5nt1")
  132. [node name="OneWayStaticBody2D" type="StaticBody2D" parent="."]
  133. position = Vector2(512, 300)
  134. [node name="CollisionShape2D" type="CollisionShape2D" parent="OneWayStaticBody2D"]
  135. shape = SubResource("2")
  136. one_way_collision = true
  137. [node name="RigidBody2D" type="RigidBody2D" parent="."]
  138. position = Vector2(300, 300)
  139. collision_mask = 2147483649
  140. gravity_scale = 0.0
  141. contact_monitor = true
  142. [node name="Sprite" type="Sprite2D" parent="RigidBody2D"]
  143. self_modulate = Color(1, 1, 1, 0.501961)
  144. scale = Vector2(0.5, 0.5)
  145. texture = ExtResource("2")
  146. [node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
  147. shape = SubResource("3")
  148. [node name="CharacterBody2D" type="CharacterBody2D" parent="."]
  149. position = Vector2(300, 300)
  150. collision_mask = 2147483649
  151. [node name="Sprite" type="Sprite2D" parent="CharacterBody2D"]
  152. self_modulate = Color(1, 1, 1, 0.501961)
  153. scale = Vector2(0.5, 0.5)
  154. texture = ExtResource("2")
  155. [node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
  156. shape = SubResource("3")
  157. [connection signal="value_changed" from="Controls/PlatformSize/HSlider" to="." method="_update_platform_size"]
  158. [connection signal="value_changed" from="Controls/PlatformAngle/HSlider" to="." method="_update_platform_angle"]
  159. [connection signal="value_changed" from="Controls/BodyAngle/HSlider" to="." method="_update_rigidbody_angle"]