This commit is contained in:
dusk 2024-08-30 01:32:01 +03:00
parent 11479c65f0
commit 10e88590de
Signed by: dusk
SSH Key Fingerprint: SHA256:Abmvag+juovVufZTxyWY8KcVgrznxvBjQpJesv071Aw
11 changed files with 75 additions and 51 deletions

1
.gitattributes vendored
View File

@ -1,3 +1,4 @@
# Normalize EOL for all files that Git considers text files. # Normalize EOL for all files that Git considers text files.
* text=auto eol=lf * text=auto eol=lf
addons/boids/lib/* filter=lfs diff=lfs merge=lfs -text addons/boids/lib/* filter=lfs diff=lfs merge=lfs -text
resources/*.gif filter=lfs diff=lfs merge=lfs -text

View File

@ -3,6 +3,8 @@
[ext_resource type="Texture2D" uid="uid://rk5u1wthr0n0" path="res://examples/boids/2d/example_boid.svg" id="2_jx2vb"] [ext_resource type="Texture2D" uid="uid://rk5u1wthr0n0" path="res://examples/boids/2d/example_boid.svg" id="2_jx2vb"]
[sub_resource type="BoidProperties" id="BoidProperties_a6wou"] [sub_resource type="BoidProperties" id="BoidProperties_a6wou"]
alignment = 1.0
cohesion = 0.8
[sub_resource type="GDScript" id="GDScript_ldfpo"] [sub_resource type="GDScript" id="GDScript_ldfpo"]
resource_name = "example_boid_sprite" resource_name = "example_boid_sprite"

View File

@ -1,14 +1,19 @@
extends Node2D extends Node2D
func _ready() -> void: func _ready() -> void:
for i in 40: spawnBoid() for flock in get_children():
if flock is not Flock2D: continue
var color = Color(randf_range(0.8, 1.5), randf_range(0.8, 1.5), randf_range(0.2, 1.5), 1)
for i in 100: spawnBoid(flock, color)
func _process(delta: float) -> void: func _process(delta: float) -> void:
$Path2D/PathFollow2D.progress_ratio += delta * 0.1 $Path2D/PathFollow2D.progress_ratio += delta * 0.125
$Path2D2/PathFollow2D.progress_ratio += delta * 0.1
$Path2D3/PathFollow2D.progress_ratio += delta * 0.08
func spawnBoid() -> void: func spawnBoid(flock: Flock2D, color: Color) -> void:
var boid: Boid2D = preload("../example_boid.tscn").instantiate() var boid: Boid2D = preload("../example_boid.tscn").instantiate()
var screensize := get_viewport_rect().size var screensize := get_viewport_rect().size
boid.modulate = Color(randf(), randf(), randf(), 1) boid.modulate = color
boid.global_position = Vector2((randf_range(200, screensize.x - 200)), (randf_range(200, screensize.y - 200))) boid.global_position = Vector2((randf_range(200, screensize.x - 200)), (randf_range(200, screensize.y - 200)))
$Flock.add_child(boid) flock.add_child(boid)

View File

@ -1,15 +1,33 @@
[gd_scene load_steps=4 format=3 uid="uid://ckc0dhvrksfh4"] [gd_scene load_steps=7 format=3 uid="uid://ckc0dhvrksfh4"]
[ext_resource type="Script" path="res://examples/boids/2d/follow/example.gd" id="1_cb4mx"] [ext_resource type="Script" path="res://examples/boids/2d/follow/example.gd" id="1_cb4mx"]
[sub_resource type="Curve2D" id="Curve2D_ncwi0"] [sub_resource type="Curve2D" id="Curve2D_ncwi0"]
_data = { _data = {
"points": PackedVector2Array(69.2957, 57.9564, -69.2957, -57.9564, 1117, 34, 79.375, -118.433, -79.375, 118.433, 34, 28, -61.7361, -114.653, 61.7361, 114.653, 22, 624, -42.8373, 69.2957, 42.8373, -69.2957, 1126, 622, 66.7758, 73.0754, -66.7758, -73.0754, 1117, 34) "points": PackedVector2Array(69.2957, 57.9564, -69.2957, -57.9564, 1025, 158, 79.375, -118.433, -79.375, 118.433, 129, 149, -61.7361, -114.653, 61.7361, 114.653, 126, 517, -42.8373, 69.2957, 42.8373, -69.2957, 1041, 487, 66.7758, 73.0754, -66.7758, -73.0754, 1025, 158)
} }
point_count = 5 point_count = 5
[sub_resource type="Curve2D" id="Curve2D_pef6d"]
_data = {
"points": PackedVector2Array(0, 0, 0, 0, 90, 76, 0, 0, 0, 0, 1037, 568, 0, 0, 0, 0, 1030, 72, 0, 0, 0, 0, 89, 560, 0, 0, 0, 0, 90, 76)
}
point_count = 5
[sub_resource type="Curve2D" id="Curve2D_fq51g"]
_data = {
"points": PackedVector2Array(0, 0, 0, 0, 37, 310, 0, 0, 0, 0, 1118, 324, 0, 0, 0, 0, 567, 315, 0, 0, 0, 0, 567, 19, 0, 0, 0, 0, 571, 635, 0, 0, 0, 0, 569, 311, 0, 0, 0, 0, 37, 310)
}
point_count = 7
[sub_resource type="FlockProperties" id="FlockProperties_id14j"] [sub_resource type="FlockProperties" id="FlockProperties_id14j"]
[sub_resource type="Environment" id="Environment_8ucif"]
background_mode = 3
glow_enabled = true
glow_bloom = 0.2
glow_blend_mode = 1
[node name="Example" type="Node2D"] [node name="Example" type="Node2D"]
script = ExtResource("1_cb4mx") script = ExtResource("1_cb4mx")
@ -17,9 +35,34 @@ script = ExtResource("1_cb4mx")
curve = SubResource("Curve2D_ncwi0") curve = SubResource("Curve2D_ncwi0")
[node name="PathFollow2D" type="PathFollow2D" parent="Path2D"] [node name="PathFollow2D" type="PathFollow2D" parent="Path2D"]
position = Vector2(1117, 34) position = Vector2(1025, 158)
rotation = -2.44507 rotation = -2.44507
[node name="Path2D2" type="Path2D" parent="."]
curve = SubResource("Curve2D_pef6d")
[node name="PathFollow2D" type="PathFollow2D" parent="Path2D2"]
position = Vector2(90, 76)
rotation = 0.479153
[node name="Path2D3" type="Path2D" parent="."]
curve = SubResource("Curve2D_fq51g")
[node name="PathFollow2D" type="PathFollow2D" parent="Path2D3"]
position = Vector2(37, 310)
rotation = 0.0129502
[node name="Flock" type="Flock2D" parent="." node_paths=PackedStringArray("target")] [node name="Flock" type="Flock2D" parent="." node_paths=PackedStringArray("target")]
properties = SubResource("FlockProperties_id14j") properties = SubResource("FlockProperties_id14j")
target = NodePath("../Path2D/PathFollow2D") target = NodePath("../Path2D/PathFollow2D")
[node name="Flock2" type="Flock2D" parent="." node_paths=PackedStringArray("target")]
properties = SubResource("FlockProperties_id14j")
target = NodePath("../Path2D2/PathFollow2D")
[node name="Flock3" type="Flock2D" parent="." node_paths=PackedStringArray("target")]
properties = SubResource("FlockProperties_id14j")
target = NodePath("../Path2D3/PathFollow2D")
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_8ucif")

View File

@ -2,11 +2,13 @@ extends Node2D
func _ready() -> void: func _ready() -> void:
for flock in get_children(): for flock in get_children():
for i in 1000: spawnBoid(flock) if flock is not Flock2D: continue
var color = Color(randf(), randf(), randf(), 1)
for i in 2000: spawnBoid(flock, color)
func spawnBoid(flock: Flock2D) -> void: func spawnBoid(flock: Flock2D, color: Color) -> void:
var boid: Boid2D = preload("../example_boid.tscn").instantiate() var boid: Boid2D = preload("../example_boid.tscn").instantiate()
var screensize := get_viewport_rect().size var screensize := get_viewport_rect().size
boid.modulate = Color(randf(), randf(), randf(), 1) boid.modulate = color
boid.global_position = Vector2((randf_range(200, screensize.x - 200)), (randf_range(200, screensize.y - 200))) boid.global_position = Vector2((randf_range(200, screensize.x - 200)), (randf_range(200, screensize.y - 200)))
flock.add_child(boid) flock.add_child(boid)

View File

@ -1,11 +1,20 @@
[gd_scene load_steps=3 format=3 uid="uid://op0qicvpbjt6"] [gd_scene load_steps=4 format=3 uid="uid://op0qicvpbjt6"]
[ext_resource type="Script" path="res://examples/boids/2d/simple/example.gd" id="1_3gcrf"] [ext_resource type="Script" path="res://examples/boids/2d/simple/example.gd" id="1_3gcrf"]
[sub_resource type="Environment" id="Environment_jxsqf"]
background_mode = 3
glow_enabled = true
glow_bloom = 0.2
glow_blend_mode = 1
[sub_resource type="FlockProperties" id="FlockProperties_cvyp0"] [sub_resource type="FlockProperties" id="FlockProperties_cvyp0"]
[node name="Example" type="Node2D"] [node name="Example" type="Node2D"]
script = ExtResource("1_3gcrf") script = ExtResource("1_3gcrf")
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_jxsqf")
[node name="Flock" type="Flock2D" parent="."] [node name="Flock" type="Flock2D" parent="."]
properties = SubResource("FlockProperties_cvyp0") properties = SubResource("FlockProperties_cvyp0")

View File

@ -24,5 +24,4 @@ enabled=PackedStringArray("res://addons/boids/plugin.cfg")
[rendering] [rendering]
renderer/rendering_method="gl_compatibility" environment/defaults/default_clear_color=Color(0, 0, 0, 1)
renderer/rendering_method.mobile="gl_compatibility"

0
resources/.gdignore Normal file
View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cp6l2f1oac4ce"
path="res://.godot/imported/boid_2d.png-b56b7a427c09dbbdb1e601cb745d4254.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://resources/boid_2d.png"
dest_files=["res://.godot/imported/boid_2d.png-b56b7a427c09dbbdb1e601cb745d4254.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
resources/boids.gif (Stored with Git LFS)

Binary file not shown.