Transmit jokes to the audience

This commit is contained in:
Waldemar Tomme 2024-01-27 13:08:34 +01:00
parent f224391f30
commit 16afe2b983
4 changed files with 32 additions and 4 deletions

View File

@ -3,6 +3,7 @@ extends Node2D
@export var move_speed = 100
@export var boundary: Boundary
@export var tim_sprite : Sprite2D
@export var transmitter_area: Area2D
# Called when the node enters the scene tree for the first time.
func _ready():
@ -24,4 +25,9 @@ func _process(delta):
func _on_joke_button_button_pressed(joke):
pass # Replace with function body.
for body in transmitter_area.get_overlapping_bodies():
var person = body.find_parent("Person")
if not (person is Person):
continue
person.on_joke(joke)

View File

@ -1,3 +1,4 @@
class_name Person
extends Sprite2D
@export var head : Node2D
@ -24,3 +25,6 @@ func set_random_face():
var face_res = load(known_faces[randi() % known_faces.size()])
face = face_res.instantiate()
head.add_child(face)
func on_joke(joke: Joke):
pass

View File

@ -1,10 +1,12 @@
[gd_scene load_steps=3 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"]
[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")]
texture = SubResource("PlaceholderTexture2D_kbo53")
script = ExtResource("1_mx0i8")
@ -13,3 +15,8 @@ head = NodePath("Head")
[node name="Head" type="Node2D" parent="."]
position = Vector2(0, -16)
scale = Vector2(0.3, 0.3)
[node name="StaticBody2D" type="StaticBody2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
shape = SubResource("RectangleShape2D_5rd5b")

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=3 uid="uid://cicyfp5xjvvu4"]
[gd_scene load_steps=8 format=3 uid="uid://cicyfp5xjvvu4"]
[ext_resource type="Script" path="res://scenes/Tim.gd" id="1_g3k2b"]
[ext_resource type="Texture2D" uid="uid://kq63ictuirhc" path="res://sprites/tim_side.png" id="1_saxit"]
@ -11,6 +11,9 @@ size = Vector2(600, 200)
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_k2q2d"]
size = Vector2(150, 50)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_wmfel"]
size = Vector2(100, 10000)
[node name="Stage" type="Node2D"]
[node name="Sprite2D" type="Sprite2D" parent="."]
@ -18,10 +21,11 @@ scale = Vector2(1, 0.3)
texture = SubResource("PlaceholderTexture2D_3hx6l")
offset = Vector2(0, -100)
[node name="Tim" type="Node2D" parent="." node_paths=PackedStringArray("boundary", "tim_sprite")]
[node name="Tim" type="Node2D" parent="." node_paths=PackedStringArray("boundary", "tim_sprite", "transmitter_area")]
script = ExtResource("1_g3k2b")
boundary = NodePath("../Boundary")
tim_sprite = NodePath("Sprite2D")
transmitter_area = NodePath("Joke Transmitter/Area2D")
[node name="Sprite2D" type="Sprite2D" parent="Tim"]
position = Vector2(-12, -142)
@ -55,6 +59,13 @@ action = "joke_button_3"
position = Vector2(150, -50)
texture = SubResource("PlaceholderTexture2D_k2q2d")
[node name="Joke Transmitter" type="Node2D" parent="Tim"]
[node name="Area2D" type="Area2D" parent="Tim/Joke Transmitter"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Tim/Joke Transmitter/Area2D"]
shape = SubResource("RectangleShape2D_wmfel")
[node name="Boundary" type="Node2D" parent="."]
script = ExtResource("2_8p6ir")