diff options
| -rw-r--r-- | DeadBody.tscn | 12 | ||||
| -rw-r--r-- | Level.tscn | 20 | ||||
| -rw-r--r-- | Player.gd | 9 |
3 files changed, 35 insertions, 6 deletions
diff --git a/DeadBody.tscn b/DeadBody.tscn index b0d0062..77b4aeb 100644 --- a/DeadBody.tscn +++ b/DeadBody.tscn @@ -1,12 +1,18 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=2] [ext_resource path="res://Assets/kenny_complete/Base pack/Player/p1_duck.png" type="Texture" id=1] +[sub_resource type="PhysicsMaterial" id=2] +friction = 5.64 + [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 34.8766, 35.7335 ) -[node name="DeadBody" type="RigidBody2D"] -gravity_scale = 3.49 +[node name="DeadBody" type="RigidBody2D" groups=[ +"bodies", +]] +physics_material_override = SubResource( 2 ) +gravity_scale = 20.0 [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource( 1 ) @@ -29,5 +29,23 @@ position = Vector2( 0, 472 ) script = ExtResource( 4 ) [node name="DeadBody" parent="." instance=ExtResource( 5 )] -position = Vector2( 237.602, 353.733 ) +position = Vector2( 235.224, 350.165 ) + +[node name="DeadBody2" parent="." instance=ExtResource( 5 )] +position = Vector2( 191.223, 268.11 ) + +[node name="DeadBody3" parent="." instance=ExtResource( 5 )] +position = Vector2( 157.925, 352.544 ) + +[node name="DeadBody4" parent="." instance=ExtResource( 5 )] +position = Vector2( 318.468, 356.111 ) + +[node name="DeadBody5" parent="." instance=ExtResource( 5 )] +position = Vector2( 274.467, 272.867 ) + +[node name="DeadBody6" parent="." instance=ExtResource( 5 )] +position = Vector2( 643.122, 426.275 ) + +[node name="DeadBody7" parent="." instance=ExtResource( 5 )] +position = Vector2( 545.607, 244.326 ) [connection signal="died" from="Player" to="GhostSpawner" method="_on_Player_died"] @@ -47,12 +47,17 @@ func _physics_process(delta): if self.is_on_ceiling(): velocity.y = 1 - + # We don't need to multiply velocity by delta because "move_and_slide" already takes delta time into account. # The second parameter of "move_and_slide" is the normal pointing up. # In the case of a 2D platformer, in Godot, upward is negative y, which translates to -1 as a normal. - move_and_slide(velocity, Vector2(0, -1)) + move_and_slide(velocity, Vector2.UP, false, 4, PI/4, false) + for index in get_slide_count(): + var collision = get_slide_collision(index) + if collision.collider.is_in_group("bodies"): + print(collision.normal) + collision.collider.apply_central_impulse(-collision.normal * velocity.length() * 0.3) func respawn(): position = respawn_position |
