Add basic collision

This commit is contained in:
~erin 2022-05-11 12:43:05 -04:00
parent 72f25f7960
commit d96a68947e
No known key found for this signature in database
GPG Key ID: DA70E064A8C70F44
3 changed files with 18 additions and 3 deletions

View File

@ -21,4 +21,4 @@ func _physics_process(delta):
else:
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
move_and_collide(velocity * delta)
velocity = move_and_slide(velocity)

View File

@ -1,9 +1,13 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=5 format=2]
[ext_resource path="res://World/Bush.png" type="Texture" id=1]
[ext_resource path="res://Player/Player.png" type="Texture" id=2]
[ext_resource path="res://Player/Player.gd" type="Script" id=3]
[sub_resource type="CapsuleShape2D" id=1]
radius = 4.0
height = 6.0
[node name="World" type="Node2D"]
[node name="Bush" type="Sprite" parent="."]
@ -11,7 +15,7 @@ position = Vector2( 63, 65 )
texture = ExtResource( 1 )
[node name="Player" type="KinematicBody2D" parent="."]
position = Vector2( 101, 35 )
position = Vector2( 101, 34 )
script = ExtResource( 3 )
__meta__ = {
"_edit_group_": true
@ -20,3 +24,13 @@ __meta__ = {
[node name="Sprite" type="Sprite" parent="Player"]
texture = ExtResource( 2 )
hframes = 60
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player"]
position = Vector2( 0, 9 )
rotation = -1.5708
shape = SubResource( 1 )
[node name="StaticBody2D" type="StaticBody2D" parent="."]
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PoolVector2Array( 0, 0, 64, 0, 40, 48, 64, 80, 24, 88, 96, 120, 112, 168, 200, 160, 272, 104, 240, 104, 240, 64, 280, 64, 288, 8, 320, 0, 320, 176, 0, 176 )

View File

@ -31,6 +31,7 @@ window/size/height=180
window/size/test_width=1280
window/size/test_height=720
window/stretch/mode="2d"
window/stretch/aspect="keep"
[importer_defaults]