diff --git a/godot/scenes/bodies/body_blue_1.tscn b/godot/scenes/bodies/body_blue_1.tscn new file mode 100644 index 0000000..36039d9 --- /dev/null +++ b/godot/scenes/bodies/body_blue_1.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://c12qb0t5fukxy"] + +[ext_resource type="Texture2D" uid="uid://bt8qft2vpyl24" path="res://sprites/bodies/body_blue_1.svg" id="1_ppgo0"] + +[node name="BodyBlue1" type="Sprite2D"] +texture = ExtResource("1_ppgo0") diff --git a/godot/scenes/bodies/body_blue_2.tscn b/godot/scenes/bodies/body_blue_2.tscn new file mode 100644 index 0000000..24e7e14 --- /dev/null +++ b/godot/scenes/bodies/body_blue_2.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://b6r7nlhj70qxd"] + +[ext_resource type="Texture2D" uid="uid://dqxv2u4xiwiup" path="res://sprites/bodies/body_blue_2.svg" id="1_qalxe"] + +[node name="BodyBlue2" type="Sprite2D"] +texture = ExtResource("1_qalxe") diff --git a/godot/scenes/bodies/body_blue_3.tscn b/godot/scenes/bodies/body_blue_3.tscn new file mode 100644 index 0000000..80be0e5 --- /dev/null +++ b/godot/scenes/bodies/body_blue_3.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://dnpviu6dbg4dr"] + +[ext_resource type="Texture2D" uid="uid://7bw8nqowkthc" path="res://sprites/bodies/body_blue_3.svg" id="1_3emr7"] + +[node name="BodyBlue3" type="Sprite2D"] +texture = ExtResource("1_3emr7") diff --git a/godot/scenes/bodies/body_green_1.tscn b/godot/scenes/bodies/body_green_1.tscn new file mode 100644 index 0000000..9714efa --- /dev/null +++ b/godot/scenes/bodies/body_green_1.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://bwxnhtolf1j26"] + +[ext_resource type="Texture2D" uid="uid://baijihfhkfk0i" path="res://sprites/bodies/body_green_1.svg" id="1_cnx4p"] + +[node name="BodyGreen1" type="Sprite2D"] +texture = ExtResource("1_cnx4p") diff --git a/godot/scenes/bodies/body_green_2.tscn b/godot/scenes/bodies/body_green_2.tscn new file mode 100644 index 0000000..672dfb6 --- /dev/null +++ b/godot/scenes/bodies/body_green_2.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://6504thpoeyiq"] + +[ext_resource type="Texture2D" uid="uid://p557r4sksm4a" path="res://sprites/bodies/body_green_2.svg" id="1_31bmk"] + +[node name="BodyGreen2" type="Sprite2D"] +texture = ExtResource("1_31bmk") diff --git a/godot/scenes/bodies/body_green_3.tscn b/godot/scenes/bodies/body_green_3.tscn new file mode 100644 index 0000000..f7142a9 --- /dev/null +++ b/godot/scenes/bodies/body_green_3.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://budkcly8pgpvt"] + +[ext_resource type="Texture2D" uid="uid://bsy1pfhg1ante" path="res://sprites/bodies/body_green_3.svg" id="1_qcqxr"] + +[node name="BodyGreen3" type="Sprite2D"] +texture = ExtResource("1_qcqxr") diff --git a/godot/scenes/bodies/body_red_1.tscn b/godot/scenes/bodies/body_red_1.tscn new file mode 100644 index 0000000..6612a3d --- /dev/null +++ b/godot/scenes/bodies/body_red_1.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://5flf4apu2s33"] + +[ext_resource type="Texture2D" uid="uid://b6211hcc6kclc" path="res://sprites/bodies/body_red_1.svg" id="1_0fjdh"] + +[node name="BodyRed1" type="Sprite2D"] +texture = ExtResource("1_0fjdh") diff --git a/godot/scenes/bodies/body_red_2.tscn b/godot/scenes/bodies/body_red_2.tscn new file mode 100644 index 0000000..efb9808 --- /dev/null +++ b/godot/scenes/bodies/body_red_2.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://dl3dhmyn6ba8r"] + +[ext_resource type="Texture2D" uid="uid://c2cg5x7x14nd" path="res://sprites/bodies/body_red_2.svg" id="1_g6wgn"] + +[node name="BodyRed2" type="Sprite2D"] +texture = ExtResource("1_g6wgn") diff --git a/godot/scenes/bodies/body_red_3.tscn b/godot/scenes/bodies/body_red_3.tscn new file mode 100644 index 0000000..ed1c570 --- /dev/null +++ b/godot/scenes/bodies/body_red_3.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://cthh6v0gf4vqt"] + +[ext_resource type="Texture2D" uid="uid://bahxyel8pbh40" path="res://sprites/bodies/body_red_3.svg" id="1_fq8cf"] + +[node name="BodyRed3" type="Sprite2D"] +texture = ExtResource("1_fq8cf") diff --git a/godot/scenes/crowd/person.gd b/godot/scenes/crowd/person.gd index 9977bc0..5fd4de3 100644 --- a/godot/scenes/crowd/person.gd +++ b/godot/scenes/crowd/person.gd @@ -1,10 +1,13 @@ class_name AudienceMember -extends Sprite2D +extends Node2D @export var mood : float = 0. +@export_enum("blue", "green", "red") var color @export var head : Node2D @export var face : Node2D +@export var body : Node2D +@export var body_shape : Node2D @export var profile : AudienceProfile @export_enum("angry", "neutral", "happy", "laugh") var expression @@ -17,6 +20,27 @@ var known_faces : Array[String] = [ # Add more scenes as needed ] +var known_bodies = { + "blue" : [ + "res://scenes/bodies/body_blue_1.tscn", + "res://scenes/bodies/body_blue_2.tscn", + "res://scenes/bodies/body_blue_3.tscn", + # Add more scenes as needed + ], + "green" : [ + "res://scenes/bodies/body_green_1.tscn", + "res://scenes/bodies/body_green_2.tscn", + "res://scenes/bodies/body_green_3.tscn", + # Add more scenes as needed + ], + "red" : [ + "res://scenes/bodies/body_red_1.tscn", + "res://scenes/bodies/body_red_2.tscn", + "res://scenes/bodies/body_red_3.tscn", + # Add more scenes as needed + ], +} + const laughter_duration : float = 2. # seconds const laughter_bobs : int = 4 var laughter_left : float = 0. @@ -27,6 +51,9 @@ func _ready(): mood = randf_range(profile.lashout_threshold, profile.happy_threshold) update_expression() + if body_shape == null: + set_random_body(color) + if face == null: set_random_face() @@ -40,11 +67,16 @@ func _process(delta): elif mood < profile.lashout_threshold * .9: mood += profile.lashout_decay * delta - if Input.is_key_pressed(KEY_SPACE) and OS.is_debug_build(): - update_mood(1.) - update_expression() +func _input(event): + var just_pressed = event.is_pressed() and not event.is_echo() + if just_pressed and OS.is_debug_build(): + if Input.is_key_pressed(KEY_SPACE): + update_mood(1.) + elif Input.is_key_pressed(KEY_ENTER): + update_mood(-1.) + func hear_joke(): var change = randf_range(-3., 3.) update_mood(change) @@ -69,6 +101,16 @@ func update_expression(): expression = "angry" else: expression = "neutral" + +func set_random_body(for_color): + if str(for_color) not in known_bodies: + var keys = known_bodies.keys() + for_color = keys[randi() % keys.size()] + print(keys.size()) + var body_path = known_bodies[for_color][randi() % known_bodies[for_color].size()] + var body_res = load(body_path) + body_shape = body_res.instantiate() + body.add_child(body_shape) func set_random_face(): var face_res = load(known_faces[randi() % known_faces.size()]) diff --git a/godot/scenes/crowd/person.tscn b/godot/scenes/crowd/person.tscn index 8e2a221..2d317be 100644 --- a/godot/scenes/crowd/person.tscn +++ b/godot/scenes/crowd/person.tscn @@ -1,20 +1,21 @@ -[gd_scene load_steps=5 format=3 uid="uid://cl4fax7fbh2g7"] +[gd_scene load_steps=4 format=3 uid="uid://cl4fax7fbh2g7"] [ext_resource type="Script" path="res://scenes/crowd/person.gd" id="1_mx0i8"] [ext_resource type="Script" path="res://scenes/crowd/audience_profile.gd" id="2_bsodr"] -[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_kbo53"] -size = Vector2(20, 30) - [sub_resource type="RectangleShape2D" id="RectangleShape2D_5rd5b"] -[node name="Person" type="Sprite2D" node_paths=PackedStringArray("head", "profile")] -texture = SubResource("PlaceholderTexture2D_kbo53") +[node name="Person" type="Node2D" node_paths=PackedStringArray("head", "body", "profile")] script = ExtResource("1_mx0i8") head = NodePath("Head") +body = NodePath("Body") profile = NodePath("Profile") expression = 1 +[node name="Body" type="Node2D" parent="."] +position = Vector2(0, 15) +scale = Vector2(0.3, 0.3) + [node name="Head" type="Node2D" parent="."] position = Vector2(0, -16) scale = Vector2(0.3, 0.3)