Skip to content

Commit

Permalink
Add VisualShape2D demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Xrayez committed Jul 4, 2020
1 parent f8cd266 commit 966935d
Show file tree
Hide file tree
Showing 6 changed files with 232 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 2d/visual_shapes/concave_polygon.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[gd_resource type="ConcavePolygonShape2D" format=2]

[resource]
segments = PoolVector2Array( -128, -128, -64, -152, -64, -152, 104, -56, 104, -56, 200, -64, 200, -64, 240, -56, 240, -56, 264, -8, 264, -8, 320, 40, 320, 40, 224, 160, 224, 160, 168, 104, 168, 104, 144, 152, 144, 152, 88, 40, 88, 40, 56, 80, 56, 80, 16, 8, 16, 8, -32, 24, -32, 24, -64, -56, -64, -56, -88, 8, -88, 8, -96, -56, -96, -56, -200, -8, -200, -8, -168, -80, -168, -80, -128, -128 )
4 changes: 4 additions & 0 deletions 2d/visual_shapes/convex_polygon.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[gd_resource type="ConvexPolygonShape2D" format=2]

[resource]
points = PoolVector2Array( 32, 16, 0, -32, -32, 16 )
Binary file added 2d/visual_shapes/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions 2d/visual_shapes/icon.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
26 changes: 26 additions & 0 deletions 2d/visual_shapes/project.godot
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters

config_version=4

_global_script_classes=[ ]
_global_script_class_icons={

}

[application]

config/name="Goost Visual Shapes"
run/main_scene="res://visual_shapes.tscn"
boot_splash/image="res://icon.png"
boot_splash/fullsize=false
config/icon="res://icon.png"

[physics]

2d/default_gravity=700
164 changes: 164 additions & 0 deletions 2d/visual_shapes/visual_shapes.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
[gd_scene load_steps=13 format=2]

[ext_resource path="res://concave_polygon.tres" type="Shape2D" id=1]

[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 200, 50 )

[sub_resource type="CircleShape2D" id=2]
radius = 40.0

[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 200, 50 )

[sub_resource type="CircleShape2D" id=4]
radius = 44.0

[sub_resource type="PhysicsMaterial" id=5]
bounce = 1.0

[sub_resource type="CapsuleShape2D" id=6]
radius = 20.0

[sub_resource type="PhysicsMaterial" id=7]
bounce = 0.6

[sub_resource type="RectangleShape2D" id=8]
extents = Vector2( 32, 32 )

[sub_resource type="SegmentShape2D" id=9]
a = Vector2( 150, 0 )
b = Vector2( 0, 100 )

[sub_resource type="RectangleShape2D" id=10]
extents = Vector2( 150, 64 )

[sub_resource type="Animation" id=11]
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("ghost_shape:color")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Color( 1, 1, 1, 0.184314 ), Color( 1, 1, 1, 0.572549 ) ]
}

[node name="visual_shapes" type="Node2D"]

[node name="rectangle_left" type="StaticBody2D" parent="."]
position = Vector2( 221, 210 )
rotation = 0.448909

[node name="collision" type="CollisionShape2D" parent="rectangle_left"]
shape = SubResource( 1 )

[node name="shape" type="VisualShape2D" parent="rectangle_left/collision"]
shape = SubResource( 2 )
use_parent_shape = true
color = Color( 0.721569, 0.760784, 0.34902, 1 )

[node name="rectangle_right" type="StaticBody2D" parent="."]
position = Vector2( 688, 184 )
rotation = -0.748333

[node name="collision" type="CollisionShape2D" parent="rectangle_right"]
shape = SubResource( 3 )

[node name="shape" type="VisualShape2D" parent="rectangle_right/collision"]
use_parent_shape = true
color = Color( 0.721569, 0.760784, 0.34902, 1 )

[node name="concave" type="StaticBody2D" parent="."]
position = Vector2( 216, 416 )

[node name="collision" type="CollisionShape2D" parent="concave"]
shape = ExtResource( 1 )
__meta__ = {
"_edit_lock_": true
}

[node name="shape" type="VisualShape2D" parent="concave/collision"]
shape = ExtResource( 1 )
use_parent_shape = true
color = Color( 0.721569, 0.760784, 0.34902, 1 )

[node name="circle" type="RigidBody2D" parent="."]
position = Vector2( 108, 48 )

[node name="collision" type="CollisionShape2D" parent="circle"]
shape = SubResource( 4 )
__meta__ = {
"_edit_lock_": true
}

[node name="shape" type="VisualShape2D" parent="circle/collision"]
use_parent_shape = true
color = Color( 0.945098, 0.219608, 0.219608, 1 )

[node name="capsule" type="RigidBody2D" parent="."]
position = Vector2( 160, 304 )
physics_material_override = SubResource( 5 )

[node name="collision" type="CollisionShape2D" parent="capsule"]
shape = SubResource( 6 )
__meta__ = {
"_edit_lock_": true
}

[node name="shape" type="VisualShape2D" parent="capsule/collision"]
use_parent_shape = true
color = Color( 0.921569, 0.219608, 0.945098, 1 )

[node name="triangle" type="RigidBody2D" parent="."]
position = Vector2( 184, -120 )
physics_material_override = SubResource( 7 )

[node name="collision" type="CollisionPolygon2D" parent="triangle"]
polygon = PoolVector2Array( 0, -32, -32, 24, 32, 24 )

[node name="shape" type="VisualShape2D" parent="triangle/collision"]
use_parent_shape = true
color = Color( 0.447059, 0.858824, 0.0392157, 1 )
__meta__ = {
"_editor_description_": "Note that it's possible to edit the polygon shape through this node, as long as the resource is saved on disk and shared between this shape and collision shape node."
}

[node name="box" type="RigidBody2D" parent="."]
position = Vector2( 315.811, 92.517 )

[node name="collision" type="CollisionShape2D" parent="box"]
shape = SubResource( 8 )
__meta__ = {
"_edit_lock_": true
}

[node name="shape" type="VisualShape2D" parent="box/collision"]
use_parent_shape = true
color = Color( 0.0313726, 0.494118, 0.831373, 1 )

[node name="segment" type="StaticBody2D" parent="."]
position = Vector2( 584, 472 )

[node name="collision" type="CollisionShape2D" parent="segment"]
shape = SubResource( 9 )
__meta__ = {
"_edit_lock_": true
}

[node name="shape" type="VisualShape2D" parent="segment/collision"]
use_parent_shape = true
color = Color( 0.768627, 0.741176, 0.345098, 1 )

[node name="ghost_shape" type="VisualShape2D" parent="."]
position = Vector2( 696, 432 )
shape = SubResource( 10 )
color = Color( 1, 1, 1, 0.184314 )

[node name="anim" type="AnimationPlayer" parent="."]
autoplay = "banner"
anims/banner = SubResource( 11 )

0 comments on commit 966935d

Please sign in to comment.