mirror of
https://github.com/mightypanders/GMTKJam2021.git
synced 2025-01-30 21:59:55 +01:00
do some evil things with guests, how the get removed and what they follow
This commit is contained in:
parent
d7747b4979
commit
79dbae2221
41
Guest.gd
41
Guest.gd
@ -1,6 +1,7 @@
|
|||||||
extends RigidBody2D
|
extends RigidBody2D
|
||||||
|
|
||||||
onready var pickUpArea = $PickUpArea
|
onready var pickUpArea = $PickUpArea
|
||||||
|
onready var collision = $PhysicsCollision
|
||||||
export var guestName = "Dieter"
|
export var guestName = "Dieter"
|
||||||
export var PICKUPTRESHOLD = 100
|
export var PICKUPTRESHOLD = 100
|
||||||
export var destinationColor = Color.yellow
|
export var destinationColor = Color.yellow
|
||||||
@ -15,6 +16,8 @@ var rng = RandomNumberGenerator.new()
|
|||||||
onready var exclusionZoneShape = $ExclusionZone/CollisionShape2D
|
onready var exclusionZoneShape = $ExclusionZone/CollisionShape2D
|
||||||
var sprite
|
var sprite
|
||||||
|
|
||||||
|
var delivered
|
||||||
|
|
||||||
enum states {
|
enum states {
|
||||||
waiting,
|
waiting,
|
||||||
tethered
|
tethered
|
||||||
@ -39,24 +42,40 @@ var names = [
|
|||||||
var currentState = states.waiting
|
var currentState = states.waiting
|
||||||
|
|
||||||
var follow_node = null
|
var follow_node = null
|
||||||
|
var follow_pos = global_position
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
|
|
||||||
if false:
|
|
||||||
if follow_node != null:
|
|
||||||
currentState = states.tethered
|
|
||||||
mode = RigidBody2D.MODE_STATIC
|
|
||||||
var rot_dir = get_angle_to(follow_node.global_position)
|
|
||||||
rotation += (rot_dir)
|
|
||||||
var distance = follow_node.global_position.distance_to(global_position)
|
|
||||||
global_position = (follow_node.global_position + Vector2(10,0) )
|
|
||||||
|
|
||||||
#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
|
||||||
|
|
||||||
elif currentState == states.tethered:
|
elif currentState == states.tethered:
|
||||||
|
collision.disabled = true
|
||||||
|
mode = RigidBody2D.MODE_STATIC
|
||||||
|
var rot_dir = get_angle_to(follow_pos)
|
||||||
|
rotation += (rot_dir)
|
||||||
|
var distance = follow_pos.distance_to(global_position)
|
||||||
|
global_position = (follow_node.global_position)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
if delivered != null and OS.get_system_time_msecs() - delivered > 10000:
|
||||||
|
queue_free()
|
||||||
|
if visible == false:
|
||||||
|
follow_node = self
|
||||||
|
delivered = OS.get_system_time_msecs()
|
||||||
|
if follow_node != null:
|
||||||
|
if follow_node.visible == false:
|
||||||
|
follow_node = self
|
||||||
|
if follow_node == self:
|
||||||
|
currentState = states.waiting
|
||||||
|
else:
|
||||||
|
currentState = states.tethered
|
||||||
|
follow_pos = follow_node.global_position
|
||||||
|
else:
|
||||||
|
currentState = states.waiting
|
||||||
|
follow_pos = global_position
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
rng.randomize()
|
rng.randomize()
|
||||||
@ -76,8 +95,6 @@ func _ready():
|
|||||||
func _on_PickUpArea_body_entered(body):
|
func _on_PickUpArea_body_entered(body):
|
||||||
print(body.name)
|
print(body.name)
|
||||||
if body.name == "Playa":
|
if body.name == "Playa":
|
||||||
|
|
||||||
|
|
||||||
pickup_time = OS.get_system_time_msecs()
|
pickup_time = OS.get_system_time_msecs()
|
||||||
emit_signal("picked_up",destinationColor,guestName)
|
emit_signal("picked_up",destinationColor,guestName)
|
||||||
# start pickup process
|
# start pickup process
|
||||||
|
@ -15,8 +15,8 @@ radius = 6.0
|
|||||||
height = 9.75
|
height = 9.75
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id=6]
|
[sub_resource type="CapsuleShape2D" id=6]
|
||||||
radius = 4.71085
|
radius = 8.02541
|
||||||
height = 5.19882
|
height = 10.5115
|
||||||
|
|
||||||
[node name="Guest" type="RigidBody2D" groups=[
|
[node name="Guest" type="RigidBody2D" groups=[
|
||||||
"Guest",
|
"Guest",
|
||||||
@ -50,7 +50,7 @@ visible = false
|
|||||||
scale = Vector2( 0.25, 0.25 )
|
scale = Vector2( 0.25, 0.25 )
|
||||||
texture = ExtResource( 3 )
|
texture = ExtResource( 3 )
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="PhysicsCollision" type="CollisionShape2D" parent="."]
|
||||||
modulate = Color( 0, 1, 0.976471, 1 )
|
modulate = Color( 0, 1, 0.976471, 1 )
|
||||||
shape = SubResource( 3 )
|
shape = SubResource( 3 )
|
||||||
|
|
||||||
|
54
Playa.gd
54
Playa.gd
@ -1,5 +1,7 @@
|
|||||||
extends KinematicBody2D
|
extends KinematicBody2D
|
||||||
|
|
||||||
|
var rope = preload("res://Rope.tscn")
|
||||||
|
|
||||||
export var ACCELERATION = 60
|
export var ACCELERATION = 60
|
||||||
export var MAX_SPEED = 150
|
export var MAX_SPEED = 150
|
||||||
export var FRICTION = 50
|
export var FRICTION = 50
|
||||||
@ -21,13 +23,28 @@ func add_Guest_to_Line(parent,guest):
|
|||||||
guests.append(guest)
|
guests.append(guest)
|
||||||
print('Picked up Guest %s with color %s'%[guest.guestName,guest.destinationColor])
|
print('Picked up Guest %s with color %s'%[guest.guestName,guest.destinationColor])
|
||||||
var parentAnchor = parent.get_node("Anchor")
|
var parentAnchor = parent.get_node("Anchor")
|
||||||
parentAnchor.add_child(get_a_springjoint(parent,guest))
|
#parentAnchor.add_child(get_a_springjoint(parent,guest))
|
||||||
|
var piece = rope.instance()
|
||||||
|
parentAnchor.add_child(get_a_pinjoint(parent,piece))
|
||||||
|
var pieceAnchor = piece.get_node("Anchor")
|
||||||
|
guest.follow_node = pieceAnchor
|
||||||
var pua = guest.get_node("PickUpArea")
|
var pua = guest.get_node("PickUpArea")
|
||||||
pua.monitorable = false
|
pua.monitorable = false
|
||||||
guest.follow_node = parentAnchor
|
|
||||||
#springJoint.rotation = -rotation
|
#springJoint.rotation = -rotation
|
||||||
|
piece.start()
|
||||||
return guest
|
return guest
|
||||||
|
|
||||||
|
func get_a_pinjoint(parent,piece):
|
||||||
|
var jointAnchor = parent.get_node("Anchor")
|
||||||
|
piece.anchor_ahead = jointAnchor
|
||||||
|
var joint = PinJoint2D.new()
|
||||||
|
joint.add_child(piece)
|
||||||
|
joint.disable_collision = false
|
||||||
|
joint.softness = 10
|
||||||
|
joint.node_a = parent.get_path()
|
||||||
|
joint.node_b = piece.get_path()
|
||||||
|
return joint
|
||||||
|
|
||||||
func get_a_springjoint(parent,child):
|
func get_a_springjoint(parent,child):
|
||||||
var springJoint = DampedSpringJoint2D.new()
|
var springJoint = DampedSpringJoint2D.new()
|
||||||
#springJoint.rotation+=get_angle_to(guest.global_position)
|
#springJoint.rotation+=get_angle_to(guest.global_position)
|
||||||
@ -44,26 +61,40 @@ func get_a_springjoint(parent,child):
|
|||||||
|
|
||||||
func get_score_from_guest(guest):
|
func get_score_from_guest(guest):
|
||||||
var now = OS.get_system_time_msecs()
|
var now = OS.get_system_time_msecs()
|
||||||
var diff = now - guest.pickup_time
|
var subtract = 0
|
||||||
|
if guest.pickup_time != null:
|
||||||
|
subtract = guest.pickup_time
|
||||||
|
else:
|
||||||
|
subtract = now + 50000
|
||||||
|
var diff = now - subtract
|
||||||
var score = diff / 1000
|
var score = diff / 1000
|
||||||
score = 50 - score
|
score = 50 - score
|
||||||
return score
|
return score
|
||||||
|
|
||||||
func remove_Guests_from_Line(color):
|
func remove_Guests_from_Line(color):
|
||||||
|
|
||||||
var colormatches = []
|
var colormatches = []
|
||||||
|
var firstFound
|
||||||
for g in range(guests.size()):
|
for g in range(guests.size()):
|
||||||
if guests[g]!= null:
|
if guests[g]!= null:
|
||||||
if guests[g].destinationColor == color:
|
if guests[g].destinationColor == color:
|
||||||
colormatches.append(guests[g])
|
colormatches.append(guests[g])
|
||||||
|
if firstFound == null:
|
||||||
|
firstFound = g
|
||||||
|
|
||||||
for i in colormatches:
|
for i in colormatches:
|
||||||
|
for g in guests:
|
||||||
|
if g.is_in_group('Player'):
|
||||||
|
continue
|
||||||
|
if g.follow_node.get_parent() == i:
|
||||||
|
g.follow_node == 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)
|
||||||
i.queue_free()
|
#i.queue_free()
|
||||||
guests.remove(pos)
|
i.visible = false
|
||||||
|
#guests.remove(pos)
|
||||||
|
if firstFound != null:
|
||||||
|
guests = guests.slice(0,firstFound-1,1,true)
|
||||||
return guests.back()
|
return guests.back()
|
||||||
|
|
||||||
func _on_PickupCheckArea_area_entered(area):
|
func _on_PickupCheckArea_area_entered(area):
|
||||||
@ -78,10 +109,11 @@ func _on_PickupCheckArea_area_entered(area):
|
|||||||
pass
|
pass
|
||||||
if area.get_parent().is_in_group("Guest"):
|
if area.get_parent().is_in_group("Guest"):
|
||||||
if guests.has(area.get_parent()):
|
if guests.has(area.get_parent()):
|
||||||
print("Area has parent %s" % area.get_parent())
|
#print("Area has parent %s" % area.get_parent())
|
||||||
print("Guests we have:")
|
#print("Guests we have:")
|
||||||
print(guests)
|
#print(guests)
|
||||||
print("We already have you in line")
|
#print("We already have you in line")
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
print("Area has parent %s" % area.get_parent())
|
print("Area has parent %s" % area.get_parent())
|
||||||
print("It's a Guest")
|
print("It's a Guest")
|
||||||
|
Loading…
Reference in New Issue
Block a user