+random faces
This commit is contained in:
parent
b63482566f
commit
5dcf2b35f8
|
@ -1,14 +1,14 @@
|
||||||
class_name Boundary
|
class_name Boundary
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
@export var width = 200
|
@export var width = 200.
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(delta):
|
func _process(_delta):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func get_most_left_position():
|
func get_most_left_position():
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
extends Sprite2D
|
||||||
|
|
||||||
|
@export var head : Node2D
|
||||||
|
@export var face : Node2D
|
||||||
|
|
||||||
|
var known_faces : Array[String] = [
|
||||||
|
"res://scenes/faces/face_curly.tscn",
|
||||||
|
"res://scenes/faces/face_moritz.tscn",
|
||||||
|
"res://scenes/faces/face_ronald.tscn",
|
||||||
|
# Add more scenes as needed
|
||||||
|
]
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
pass # Replace with function body.
|
||||||
|
if face == null:
|
||||||
|
set_random_face()
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(_delta):
|
||||||
|
pass
|
||||||
|
|
||||||
|
func set_random_face():
|
||||||
|
var face_res = load(known_faces[randi() % known_faces.size()])
|
||||||
|
face = face_res.instantiate()
|
||||||
|
head.add_child(face)
|
|
@ -1,13 +1,16 @@
|
||||||
[gd_scene load_steps=3 format=3 uid="uid://cl4fax7fbh2g7"]
|
[gd_scene load_steps=3 format=3 uid="uid://cl4fax7fbh2g7"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://bvc6fbd5cgb0i" path="res://scenes/faces/face_curly.tscn" id="1_jccgy"]
|
[ext_resource type="Script" path="res://scenes/crowd/person.gd" id="1_mx0i8"]
|
||||||
|
|
||||||
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_kbo53"]
|
[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_kbo53"]
|
||||||
size = Vector2(20, 30)
|
size = Vector2(20, 30)
|
||||||
|
|
||||||
[node name="Person" type="Sprite2D"]
|
[node name="Person" type="Sprite2D" node_paths=PackedStringArray("head", "face")]
|
||||||
texture = SubResource("PlaceholderTexture2D_kbo53")
|
texture = SubResource("PlaceholderTexture2D_kbo53")
|
||||||
|
script = ExtResource("1_mx0i8")
|
||||||
|
head = NodePath("Head")
|
||||||
|
face = NodePath("")
|
||||||
|
|
||||||
[node name="FaceCurly" parent="." instance=ExtResource("1_jccgy")]
|
[node name="Head" type="Node2D" parent="."]
|
||||||
position = Vector2(0, -16)
|
position = Vector2(0, -16)
|
||||||
scale = Vector2(0.3, 0.3)
|
scale = Vector2(0.3, 0.3)
|
||||||
|
|
Loading…
Reference in New Issue