Compare commits

...

2 Commits

Author SHA1 Message Date
54a4feb82c
chore: add resources 2024-08-30 01:33:02 +03:00
10e88590de
wip 2024-08-30 01:32:01 +03:00
12 changed files with 155 additions and 50 deletions

1
.gitattributes vendored
View File

@ -1,3 +1,4 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf
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"]
[sub_resource type="BoidProperties" id="BoidProperties_a6wou"]
alignment = 1.0
cohesion = 0.8
[sub_resource type="GDScript" id="GDScript_ldfpo"]
resource_name = "example_boid_sprite"

View File

@ -1,14 +1,19 @@
extends Node2D
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:
$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 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)))
$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"]
[sub_resource type="Curve2D" id="Curve2D_ncwi0"]
_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
[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="Environment" id="Environment_8ucif"]
background_mode = 3
glow_enabled = true
glow_bloom = 0.2
glow_blend_mode = 1
[node name="Example" type="Node2D"]
script = ExtResource("1_cb4mx")
@ -17,9 +35,34 @@ script = ExtResource("1_cb4mx")
curve = SubResource("Curve2D_ncwi0")
[node name="PathFollow2D" type="PathFollow2D" parent="Path2D"]
position = Vector2(1117, 34)
position = Vector2(1025, 158)
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")]
properties = SubResource("FlockProperties_id14j")
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:
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 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)))
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"]
[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"]
[node name="Example" type="Node2D"]
script = ExtResource("1_3gcrf")
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_jxsqf")
[node name="Flock" type="Flock2D" parent="."]
properties = SubResource("FlockProperties_cvyp0")

View File

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

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.

78
resources/flock_2d.svg Normal file
View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="16"
height="16"
viewBox="0 0 16 16.000001"
version="1.1"
id="svg1"
inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)"
sodipodi:docname="flock_2d..svg"
inkscape:export-filename="..\..\resources\boid_2d.png"
inkscape:export-xdpi="768"
inkscape:export-ydpi="768"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="px"
showgrid="true"
inkscape:zoom="24.544781"
inkscape:cx="9.513224"
inkscape:cy="7.3131636"
inkscape:window-width="1920"
inkscape:window-height="1027"
inkscape:window-x="1912"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<inkscape:grid
id="grid1"
units="px"
originx="0"
originy="0"
spacingx="1"
spacingy="1.0000001"
empcolor="#0099e5"
empopacity="0.30196078"
color="#0099e5"
opacity="0.14901961"
empspacing="5"
dotted="false"
gridanglex="30"
gridanglez="30"
visible="true" />
</sodipodi:namedview>
<defs
id="defs1" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:#8da5f3;fill-opacity:1;stroke-width:26.4565;stroke-linejoin:bevel"
d="m 1,0.47939285 c 0,0 7,2.33333335 7,2.97323935 0,0.526761 -7,2.860094 -7,2.860094 2.333333,-2.333333 2.333333,-3.5 0,-5.83333335 z"
id="path1"
sodipodi:nodetypes="cscc" />
<path
style="fill:#8da5f3;fill-opacity:1;stroke-width:26.4565;stroke-linejoin:bevel"
d="m 8.5092732,5.0267612 c 0,0 6.9999998,2.3333333 6.9999998,2.9732393 0,0.526761 -6.9999998,2.8600945 -6.9999998,2.8600945 2.3333328,-2.3333335 2.3333328,-3.5000005 0,-5.8333338 z"
id="path2"
sodipodi:nodetypes="cscc" />
<path
style="fill:#8da5f3;fill-opacity:1;stroke-width:26.4565;stroke-linejoin:bevel"
d="m 2.4897504,9.4619873 c 0,0 7,2.3333327 7,2.9732387 0,0.526761 -7,2.860095 -7,2.860095 2.333333,-2.333334 2.333333,-3.500001 0,-5.8333337 z"
id="path3"
sodipodi:nodetypes="cscc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB