diff --git a/Playa.gd b/Playa.gd index 2f2c476..04d2eac 100644 --- a/Playa.gd +++ b/Playa.gd @@ -4,33 +4,72 @@ export var ACCELERATION = 60 export var MAX_SPEED = 150 export var FRICTION = 50 +var ROPEPIECE = preload("res://Rope.tscn") var velocity = Vector2.ZERO var last_in_line +var destinationColor = Color.transparent +onready var guestListNode = $GuestList var guests = [] func _ready(): last_in_line = $Anchor + guests.append(last_in_line.get_parent()) pass # Replace with function body. func add_Guest_to_Line(parent,guest): guests.append(guest) - var joint = parent.get_node("CollisionShape2D/Joint") - joint.add_child(guest) - joint.node_a = parent.get_path() - joint.node_b = guest.get_path() - return guest + guestListNode.add_child(guest) + + var springJoint = DampedSpringJoint2D.new() + #springJoint.rotation+=get_angle_to(guest.global_position) + springJoint.length = 50 + springJoint.rest_length = 10 + springJoint.stiffness = 64 + springJoint.damping = 1.0 + springJoint.disable_collision =false + springJoint.node_a =parent.get_parent().get_path() + springJoint.node_b =guest.get_path() + springJoint.add_child(guest) + parent.add_child(springJoint) + var pua = guest.get_node("PickUpArea") + pua.monitoring = false + pua.monitorable = false + var guestAnchor = guest.get_node("Anchor") + springJoint.rotation = -rotation + return guestAnchor + + +func remove_Guests_from_Line(color): + + var colorPositions = [] + + for g in range(guests.size()): + if guests[g].destinationColor == color: + guests[g].queue_free() + colorPositions.append(g) + + for i in colorPositions: + guests.remove(i) + return guests.back() func _on_PickupCheckArea_area_entered(area): if area.get_parent().is_in_group("DropOffPoint"): print("It's a DOP") + var dop = area.get_parent() + var color = dop.destinationColor + print(color) + last_in_line= remove_Guests_from_Line(color) #drop all guests after first guest.color == DOP.color, also vanish all guests.color == DOP.color pass if area.get_parent().is_in_group("Guest"): - print("It's a Guest") - last_in_line = add_Guest_to_Line(last_in_line,area.get_parent()) - print(last_in_line) + if guests.has(area.get_parent()): + print("We already have you in line") + else: + print("It's a Guest") + last_in_line = add_Guest_to_Line(last_in_line,area.get_parent()) + print(last_in_line) print(guests) @@ -50,7 +89,7 @@ func _physics_process(delta): if steer_dir != 0 && velocity.length() > 0: var direction_new = direction.rotated(PI/1.5 * steer_dir * delta) - print(velocity.length()) + #print(velocity.length()) #print(velocity.angle_to(velocity.rotated(direction_new.angle()))) velocity = velocity.rotated(direction.angle_to(direction_new)) rotate(direction.angle_to(direction_new)) diff --git a/Playa.tscn b/Playa.tscn index 347126e..84ca5f8 100644 --- a/Playa.tscn +++ b/Playa.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://assets/car/Autoi cut.png" type="Texture" id=1] [ext_resource path="res://Playa.gd" type="Script" id=2] @@ -11,10 +11,6 @@ height = 19.9256 radius = 12.9279 height = 25.8183 -[sub_resource type="CapsuleShape2D" id=3] -radius = 5.0 -height = 4.0 - [node name="Playa" type="KinematicBody2D" groups=[ "Player", ]] @@ -33,14 +29,9 @@ shape = SubResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="PickupCheckArea"] shape = SubResource( 2 ) -[node name="Anchor" type="Area2D" parent="."] +[node name="Anchor" type="Position2D" parent="."] position = Vector2( 0, 25 ) -[node name="CollisionShape2D" type="CollisionShape2D" parent="Anchor"] -shape = SubResource( 3 ) - -[node name="Joint" type="PinJoint2D" parent="Anchor/CollisionShape2D"] -node_a = NodePath("../../..") -softness = 2.0 +[node name="GuestList" type="Node2D" parent="."] [connection signal="area_entered" from="PickupCheckArea" to="." method="_on_PickupCheckArea_area_entered"]