From cba738c98c947221492e78e2d9952edd84c1a59a Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 17 Dec 2023 02:45:48 +0100 Subject: [PATCH] Implemented 2 test scripts. --- test.gd | 1 - test_2d_phys.gd | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ test_ui.gd | 19 ++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) delete mode 100644 test.gd create mode 100644 test_2d_phys.gd create mode 100644 test_ui.gd diff --git a/test.gd b/test.gd deleted file mode 100644 index b0abb24..0000000 --- a/test.gd +++ /dev/null @@ -1 +0,0 @@ -extends SceneTree \ No newline at end of file diff --git a/test_2d_phys.gd b/test_2d_phys.gd new file mode 100644 index 0000000..2e37fdd --- /dev/null +++ b/test_2d_phys.gd @@ -0,0 +1,51 @@ +extends SceneTree + +func _initialize(): + print("_initialize") + + debug_collisions_hint = true + + # Ground + var static_body = StaticBody2D.new() + root.add_child(static_body) + static_body.transform.origin = Vector2(500, 621) + + var cs = CollisionShape2D.new() + static_body.add_child(cs) + cs.shape = RectangleShape2D.new() + cs.shape.extents = Vector2(1000, 40) + + # "player" + var rigid_body = RigidBody2D.new() + root.add_child(rigid_body) + rigid_body.transform.origin = Vector2(500, 0) + rigid_body.angular_velocity = 0.1 + + cs = CollisionShape2D.new() + rigid_body.add_child(cs) + cs.shape = CapsuleShape2D.new() + cs.shape.radius = 145 + cs.shape.height = 108 + + var s = Sprite.new() + rigid_body.add_child(s) + + var img = Image.new() + img.load("icon.png") + print(img) + print(img.get_size()) + + var tex = ImageTexture.new() + tex.create_from_image(img) + s.texture = tex + + + + + + + + + + + diff --git a/test_ui.gd b/test_ui.gd new file mode 100644 index 0000000..10e98d0 --- /dev/null +++ b/test_ui.gd @@ -0,0 +1,19 @@ +extends SceneTree + +func _initialize(): + print("_initialize") + + var pc = PanelContainer.new() + root.add_child(pc) + pc.set_anchors_and_margins_preset(Control.PRESET_WIDE) + + var vb = VBoxContainer.new() + pc.add_child(vb) + + var b = Button.new() + vb.add_child(b) + b.text = "test" + + + +