tethering fixes
This commit is contained in:
parent
451ab8c868
commit
a8f6e482c6
30
Guest.gd
30
Guest.gd
|
@ -20,14 +20,14 @@ var delivered
|
||||||
|
|
||||||
enum states {
|
enum states {
|
||||||
waiting,
|
waiting,
|
||||||
tethered
|
tethered,
|
||||||
|
delivered
|
||||||
}
|
}
|
||||||
var colorList = [
|
var colorList = [
|
||||||
Color.yellow,
|
Color.yellow,
|
||||||
Color.violet,
|
Color.violet,
|
||||||
Color.red,
|
Color.red,
|
||||||
Color.turquoise,
|
Color.turquoise
|
||||||
Color.orange
|
|
||||||
]
|
]
|
||||||
var names = [
|
var names = [
|
||||||
'Dieter',
|
'Dieter',
|
||||||
|
@ -42,10 +42,12 @@ var names = [
|
||||||
var currentState = states.waiting
|
var currentState = states.waiting
|
||||||
|
|
||||||
var follow_node = null
|
var follow_node = null
|
||||||
|
var follow_guest = null
|
||||||
var follow_pos = global_position
|
var follow_pos = global_position
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
#linear_velocity = linear_velocity.clamped(100)
|
#linear_velocity = linear_velocity.clamped(100)
|
||||||
|
|
||||||
if currentState == states.waiting:
|
if currentState == states.waiting:
|
||||||
linear_velocity.move_toward(Vector2.ZERO,5.0)
|
linear_velocity.move_toward(Vector2.ZERO,5.0)
|
||||||
collision.disabled = false
|
collision.disabled = false
|
||||||
|
@ -56,23 +58,33 @@ func _physics_process(delta):
|
||||||
var rot_dir = get_angle_to(follow_pos)
|
var rot_dir = get_angle_to(follow_pos)
|
||||||
rotation += (rot_dir)
|
rotation += (rot_dir)
|
||||||
var distance = follow_pos.distance_to(global_position)
|
var distance = follow_pos.distance_to(global_position)
|
||||||
global_position = (follow_node.global_position)
|
global_position = follow_pos
|
||||||
pass
|
pass
|
||||||
|
elif currentState == states.delivered:
|
||||||
|
pickUpArea.monitorable = false
|
||||||
|
pickUpArea.monitoring = false
|
||||||
|
collision.disabled = true
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
if delivered != null and OS.get_system_time_msecs() - delivered > 10000:
|
if delivered != null and OS.get_system_time_msecs() - delivered > 1000:
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
|
|
||||||
if visible == false:
|
if visible == false:
|
||||||
follow_node = self
|
follow_node = self
|
||||||
delivered = OS.get_system_time_msecs()
|
if delivered == null:
|
||||||
if follow_node != null:
|
delivered = OS.get_system_time_msecs()
|
||||||
|
currentState = states.delivered
|
||||||
|
|
||||||
|
if follow_node != null and follow_node != self:
|
||||||
|
currentState = follow_node.currentState
|
||||||
if follow_node.visible == false:
|
if follow_node.visible == false:
|
||||||
follow_node = self
|
follow_node = self
|
||||||
if follow_node == self:
|
if follow_node == self:
|
||||||
currentState = states.waiting
|
currentState = states.waiting
|
||||||
else:
|
else:
|
||||||
currentState = states.tethered
|
currentState = states.tethered
|
||||||
follow_pos = follow_node.global_position
|
follow_pos = follow_node.get_node("Anchor/Joint/Rope/Anchor").global_position
|
||||||
else:
|
else:
|
||||||
currentState = states.waiting
|
currentState = states.waiting
|
||||||
follow_pos = global_position
|
follow_pos = global_position
|
||||||
|
@ -86,7 +98,7 @@ func _ready():
|
||||||
if spriteNum % 2 != 0:
|
if spriteNum % 2 != 0:
|
||||||
$SpriteSam.visible = true
|
$SpriteSam.visible = true
|
||||||
sprite = $SpriteSam
|
sprite = $SpriteSam
|
||||||
var n = rng.randi_range(0,4)
|
var n = rng.randi_range(0,colorList.size()-1)
|
||||||
destinationColor = colorList[n]
|
destinationColor = colorList[n]
|
||||||
sprite.modulate = destinationColor
|
sprite.modulate = destinationColor
|
||||||
var m = rng.randi_range(0,names.size()-1)
|
var m = rng.randi_range(0,names.size()-1)
|
||||||
|
|
15
Playa.gd
15
Playa.gd
|
@ -6,10 +6,17 @@ export var ACCELERATION = 60
|
||||||
export var MAX_SPEED = 150
|
export var MAX_SPEED = 150
|
||||||
export var FRICTION = 50
|
export var FRICTION = 50
|
||||||
|
|
||||||
|
enum states {
|
||||||
|
waiting,
|
||||||
|
tethered,
|
||||||
|
delivered
|
||||||
|
}
|
||||||
|
|
||||||
var velocity = Vector2.ZERO
|
var velocity = Vector2.ZERO
|
||||||
var last_in_line
|
var last_in_line
|
||||||
var destinationColor = Color.transparent
|
var destinationColor = Color.transparent
|
||||||
var guestName = 'Car'
|
var guestName = 'Car'
|
||||||
|
var currentState = states.tethered
|
||||||
|
|
||||||
signal scored(value)
|
signal scored(value)
|
||||||
var guests = []
|
var guests = []
|
||||||
|
@ -27,7 +34,7 @@ func add_Guest_to_Line(parent,guest):
|
||||||
var piece = rope.instance()
|
var piece = rope.instance()
|
||||||
parentAnchor.add_child(get_a_pinjoint(parent,piece))
|
parentAnchor.add_child(get_a_pinjoint(parent,piece))
|
||||||
var pieceAnchor = piece.get_node("Anchor")
|
var pieceAnchor = piece.get_node("Anchor")
|
||||||
guest.follow_node = pieceAnchor
|
guest.follow_node = parent
|
||||||
var pua = guest.get_node("PickUpArea")
|
var pua = guest.get_node("PickUpArea")
|
||||||
pua.monitorable = false
|
pua.monitorable = false
|
||||||
#springJoint.rotation = -rotation
|
#springJoint.rotation = -rotation
|
||||||
|
@ -41,6 +48,7 @@ func get_a_pinjoint(parent,piece):
|
||||||
joint.add_child(piece)
|
joint.add_child(piece)
|
||||||
joint.disable_collision = false
|
joint.disable_collision = false
|
||||||
joint.softness = 10
|
joint.softness = 10
|
||||||
|
joint.name = "Joint"
|
||||||
joint.node_a = parent.get_path()
|
joint.node_a = parent.get_path()
|
||||||
joint.node_b = piece.get_path()
|
joint.node_b = piece.get_path()
|
||||||
return joint
|
return joint
|
||||||
|
@ -85,8 +93,9 @@ func remove_Guests_from_Line(color):
|
||||||
for g in guests:
|
for g in guests:
|
||||||
if g.is_in_group('Player'):
|
if g.is_in_group('Player'):
|
||||||
continue
|
continue
|
||||||
if g.follow_node.get_parent() == i:
|
if g.follow_guest == i:
|
||||||
g.follow_node == g
|
g.follow_node = g
|
||||||
|
g.follow_guest = g
|
||||||
var scoreValue = get_score_from_guest(i)
|
var scoreValue = get_score_from_guest(i)
|
||||||
emit_signal("scored",scoreValue)
|
emit_signal("scored",scoreValue)
|
||||||
var pos = guests.find(i)
|
var pos = guests.find(i)
|
||||||
|
|
|
@ -8,6 +8,8 @@ extents = Vector2( 1, 10 )
|
||||||
|
|
||||||
[node name="Rope" type="RigidBody2D"]
|
[node name="Rope" type="RigidBody2D"]
|
||||||
position = Vector2( 0, 10 )
|
position = Vector2( 0, 10 )
|
||||||
|
collision_layer = 0
|
||||||
|
collision_mask = 0
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
|
Loading…
Reference in New Issue