Merge branch 'main' of https://github.com/mightypanders/GMTKJam2021
This commit is contained in:
commit
89e326a5f7
1
Guest.gd
1
Guest.gd
|
@ -10,6 +10,7 @@ signal dropped_off_idle
|
|||
signal dropped_off_fail
|
||||
var rng = RandomNumberGenerator.new()
|
||||
onready var sprite = $Sprite
|
||||
onready var exclusionZoneShape = $ExclusionZone/CollisionShape2D
|
||||
|
||||
var colorList = [
|
||||
Color.yellow,
|
||||
|
|
21
Guest.tscn
21
Guest.tscn
|
@ -1,13 +1,16 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://assets/placeholder_white.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Guest.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=3]
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
radius = 124.702
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=2]
|
||||
radius = 6.04475
|
||||
height = 3.32129
|
||||
|
||||
[sub_resource type="CircleShape2D" id=2]
|
||||
[sub_resource type="CircleShape2D" id=3]
|
||||
radius = 24.5545
|
||||
|
||||
[node name="Guest" type="RigidBody2D" groups=[
|
||||
|
@ -18,6 +21,16 @@ collision_mask = 3
|
|||
mass = 10.4357
|
||||
gravity_scale = 128.0
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_horizontal_guides_": [ ]
|
||||
}
|
||||
|
||||
[node name="ExclusionZone" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="ExclusionZone"]
|
||||
modulate = Color( 0.0823529, 1, 0.027451, 1 )
|
||||
show_behind_parent = true
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
|
@ -29,7 +42,7 @@ disabled = true
|
|||
[node name="PickUpArea" type="Area2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="PickUpArea"]
|
||||
shape = SubResource( 2 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="Anchor" type="Position2D" parent="."]
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
extends Timer
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
52
World.gd
52
World.gd
|
@ -1,18 +1,54 @@
|
|||
extends Node2D
|
||||
|
||||
onready var streets = $Streets
|
||||
onready var used_cells = streets.get_used_cells()
|
||||
onready var guests = $Guests
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
var Guest = load("res://Guest.tscn")
|
||||
|
||||
var rng = RandomNumberGenerator.new()
|
||||
var spawn_tries = 0
|
||||
const MAX_SPAWN_TRIES = 50
|
||||
|
||||
onready var radius_guests = guests.get_child(0).exclusionZoneShape.shape.radius * 2
|
||||
export var max_guests = 10
|
||||
|
||||
func _on_Guest_picked_up(destinationColor,name):
|
||||
print('Picked Up %s with name %s' % [destinationColor,name])
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
rng.randomize()
|
||||
print(radius_guests)
|
||||
|
||||
func _physics_process(delta):
|
||||
pass
|
||||
|
||||
func _on_GuestTimer_timeout():
|
||||
create_new_guest()
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
func create_new_guest():
|
||||
if guests.get_children().size() >= max_guests:
|
||||
return
|
||||
|
||||
var position_found = false;
|
||||
var new_guest_position
|
||||
|
||||
while !position_found:
|
||||
if spawn_tries >= MAX_SPAWN_TRIES:
|
||||
print("Max spawn tries reached!")
|
||||
return
|
||||
position_found = true;
|
||||
var new_guest_cell = used_cells[rng.randi_range(0, used_cells.size()) -1]
|
||||
new_guest_position = streets.map_to_world(new_guest_cell)
|
||||
|
||||
for guest in guests.get_children():
|
||||
if (new_guest_position - guest.position).length() < radius_guests:
|
||||
position_found = false
|
||||
spawn_tries+=1
|
||||
break
|
||||
|
||||
var new_guest = Guest.instance()
|
||||
new_guest.position = new_guest_position;
|
||||
guests.add_child(new_guest)
|
||||
spawn_tries = 0
|
||||
|
|
20
World.tscn
20
World.tscn
|
@ -626,6 +626,7 @@ points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
|||
[node name="World" type="Node2D"]
|
||||
position = Vector2( 2, -3 )
|
||||
script = ExtResource( 6 )
|
||||
max_guests = 30
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
modulate = Color( 0.0352941, 0.121569, 0, 1 )
|
||||
|
@ -687,17 +688,14 @@ position = Vector2( 520.662, 230.739 )
|
|||
[node name="DropOffPoint3" parent="." instance=ExtResource( 4 )]
|
||||
position = Vector2( 166.312, 322.885 )
|
||||
|
||||
[node name="Guest" parent="." instance=ExtResource( 5 )]
|
||||
position = Vector2( 232.884, 104.841 )
|
||||
[node name="GuestTimer" type="Timer" parent="."]
|
||||
wait_time = 1.019
|
||||
autostart = true
|
||||
|
||||
[node name="Guest2" parent="." instance=ExtResource( 5 )]
|
||||
position = Vector2( 759.456, 102.634 )
|
||||
guestName = "Peter"
|
||||
destinationColor = Color( 1, 0, 0, 1 )
|
||||
[node name="Guests" type="Node" parent="."]
|
||||
|
||||
[node name="Guest3" parent="." instance=ExtResource( 5 )]
|
||||
position = Vector2( 758.143, 376.075 )
|
||||
guestName = "Hans"
|
||||
destinationColor = Color( 1, 0, 0, 1 )
|
||||
[node name="Guest" parent="Guests" instance=ExtResource( 5 )]
|
||||
position = Vector2( 337.119, 100.387 )
|
||||
|
||||
[connection signal="picked_up" from="Guest" to="." method="_on_Guest_picked_up"]
|
||||
[connection signal="timeout" from="GuestTimer" to="." method="_on_GuestTimer_timeout"]
|
||||
[connection signal="picked_up" from="Guests/Guest" to="." method="_on_Guest_picked_up"]
|
||||
|
|
Loading…
Reference in New Issue