From 4fceb866f73373d91ce031474f9e2e74061725b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20C=2E=20R=C4=83dulescu?= Date: Mon, 3 Feb 2020 18:07:43 +0200 Subject: [PATCH] Use beginner 2d platformer visual style --- project/assets/sprites/background.png | Bin 0 -> 25173 bytes project/assets/sprites/background.png.import | 34 +++++++++++++++++ project/demos/Arrive/ArriveDemo.gd | 4 +- project/demos/Arrive/ArriveDemo.tscn | 24 ++++++++---- .../AvoidCollisions/AvoidCollisionsDemo.tscn | 14 +++++-- project/demos/AvoidCollisions/Avoider.gd | 6 +-- project/demos/AvoidCollisions/Avoider.tscn | 10 ++--- project/demos/AvoidCollisions/Spawner.gd | 15 ++++---- project/demos/Face/FaceDemo.tscn | 35 ++++++++++++------ project/demos/Face/Turret.gd | 4 +- project/demos/FollowPath/FollowPathDemo.tscn | 24 ++++++++---- .../GroupBehaviors/GroupBehaviorsDemo.tscn | 10 ++++- project/demos/GroupBehaviors/Member.gd | 6 ++- project/demos/GroupBehaviors/Member.tscn | 8 ++-- .../demos/PursueSeek/PursueVSSeekDemo.tscn | 14 +++++-- project/demos/SeekFlee/Boundary.gd | 4 +- project/demos/SeekFlee/Player.gd | 5 ++- project/demos/SeekFlee/SeekFleeDemo.tscn | 15 ++++---- project/demos/SeekFlee/Seeker.tscn | 10 ++--- project/demos/Utils/CircleDraw.gd | 26 +++++++++++++ 20 files changed, 193 insertions(+), 75 deletions(-) create mode 100644 project/assets/sprites/background.png create mode 100644 project/assets/sprites/background.png.import create mode 100644 project/demos/Utils/CircleDraw.gd diff --git a/project/assets/sprites/background.png b/project/assets/sprites/background.png new file mode 100644 index 0000000000000000000000000000000000000000..ad7e8ba7e8da722876971620db68de9dec412643 GIT binary patch literal 25173 zcmeHQ3v?4@+AboC;3B(T4pwZl`?G+`u3ap(XiG+v1usC?MFjzgZly&kgi>l+nwjvg z*D5sYf(tFQQF|!LEmXGD-X`h-S%2C_sBIS8WPo6&B{V}wn`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Nr3asU6Jr1DyBSZ+QAoiJfyYM*?k(uye-E-LOU@MzXj0euZZo&Qiox4@+z)WSEwB@OcO~;nq%*gF zlKE9sFy_(2{H7U@^ZhH2kcHuX5uY?eTv3P*79>v4eQ9^CZtqgeS74jbZRlq3>o-=x zrGbqDTbB*3_uo?MVaY>qX&+n>n3V;$?u8p%h_ub5@bqDGTh=7I|D@>2S^MhRohP@i z1{MfDpVps}`e1EK&r>PDN_U~n3GT9qJ3E0*a~9Tp3*54W{fpd!<-LtMw(#E&;#T-w zh~k6A_;!hYxBSweb4RB1epo#x53^XO%g|Zf7c@_Q>~b*oKv0*x(;a%Ns@$&r4uas) zZXf{#rVOT*$W%55=mf5Z`B)ZsMC-k+siyG>veR# zLgRhB_e4Ly(28%i_kz{C7cMn}C+pnee!v8bX?IdvCotsMvZ{t8lNw*{^*P#CW*xEH7ZfhX9$QJ^Pp`@&xghz91P4uxmbnQrW3Q-|l|3n&E1QcI#u6SXjL?}b zPuu|T-|1w*O--fY_*IDAAe5C;16=|^c#FcZM8nfnj5@ACqz|SBUu(AH_b!`LMwMvw z>1bl!fZ?8#9v6r-HH?6vd!Q-xkkcSP=y52dUZw3&F#edt88h~ zEGep6O=ZvqGPaf}?*P)B8?cNYJ2>TCC0*+`ze_SP zv{8&Vx2s-kAjcQ@c3+2FX!j)O;_6+$zR-;}cy726#(PhskTqb<0?TAhZ8I5ZSMLdK zyXF^R^A$sbRkDe#RQ!1FA7snR0z?;^=|y48S1&E_mtKqyjGvhbJu>V1G6Hf=3(|))x;Fmj6=Duz#R`a5f5nmL7Qvh#s zF_1&ug3pRqD8CgvH6hd;RHzvky)Nk4rFt^+ARRxs%%3my>dfx(nEG(A!UX?Z!OP(s zFfdndFoNP(r*B^FWs7gi4om00Bl0SWgXcT7sANn407ihyD_x)aANc%*>MVBr`>(%L U);!7vJysdH?_b literal 0 HcmV?d00001 diff --git a/project/assets/sprites/background.png.import b/project/assets/sprites/background.png.import new file mode 100644 index 0000000..8d1c5f6 --- /dev/null +++ b/project/assets/sprites/background.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/background.png-dde469fb1f19281f3784b52d4bea96cd.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/sprites/background.png" +dest_files=[ "res://.import/background.png-dde469fb1f19281f3784b52d4bea96cd.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/project/demos/Arrive/ArriveDemo.gd b/project/demos/Arrive/ArriveDemo.gd index a412870..6a8e86e 100644 --- a/project/demos/Arrive/ArriveDemo.gd +++ b/project/demos/Arrive/ArriveDemo.gd @@ -7,8 +7,8 @@ export(float, 0, 100, 0.1) var arrival_tolerance := 25.0 setget set_arrival_tole export(float, 0, 500, 10) var deceleration_radius := 125.0 setget set_deceleration_radius const COLORS := { - deceleration_radius = Color(0.9, 1, 0, 0.1), - arrival_tolerance = Color(0.5, 0.7, 0.9, 0.2) + deceleration_radius = Color(1.0, 0.419, 0.592, 0.5), + arrival_tolerance = Color(0.278, 0.231, 0.47, 0.3) } onready var arriver := $Arriver diff --git a/project/demos/Arrive/ArriveDemo.tscn b/project/demos/Arrive/ArriveDemo.tscn index 948a36f..07cfa90 100644 --- a/project/demos/Arrive/ArriveDemo.tscn +++ b/project/demos/Arrive/ArriveDemo.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://demos/Arrive/Arriver.gd" type="Script" id=1] [ext_resource path="res://assets/theme/gdquest.theme" type="Theme" id=2] [ext_resource path="res://demos/Arrive/ArriveDemo.gd" type="Script" id=3] -[ext_resource path="res://assets/sprites/small_circle.png" type="Texture" id=4] +[ext_resource path="res://assets/sprites/background.png" type="Texture" id=5] +[ext_resource path="res://demos/Utils/CircleDraw.gd" type="Script" id=6] [sub_resource type="CircleShape2D" id=1] radius = 16.0 @@ -11,6 +12,13 @@ radius = 16.0 [node name="ArriveDemo" type="Node2D"] script = ExtResource( 3 ) +[node name="BackgroudLayer" type="CanvasLayer" parent="."] +layer = -1 + +[node name="Background" type="Sprite" parent="BackgroudLayer"] +texture = ExtResource( 5 ) +centered = false + [node name="Arriver" type="KinematicBody2D" parent="."] show_behind_parent = true position = Vector2( 512, 300 ) @@ -18,10 +26,10 @@ script = ExtResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="Arriver"] shape = SubResource( 1 ) - -[node name="Sprite" type="Sprite" parent="Arriver"] -modulate = Color( 0.952941, 0.172549, 0.0431373, 1 ) -texture = ExtResource( 4 ) +script = ExtResource( 6 ) +inner_color = Color( 0.235294, 0.639216, 0.439216, 1 ) +outer_color = Color( 0.560784, 0.870588, 0.364706, 1 ) +stroke = 4.0 [node name="GUI" type="PanelContainer" parent="."] anchor_right = 1.0 @@ -45,7 +53,7 @@ margin_bottom = 71.0 rect_min_size = Vector2( 0, 55 ) bbcode_enabled = true bbcode_text = "Arrive Demo -Mouse click to make the [color=red]red \"Player\"[/color] move to the [color=yellow]yellow target[/color]" +Mouse click to make the [color=lime]green \"Player\"[/color] move to the [color=fuchsia]purple target[/color]" text = "Arrive Demo -Mouse click to make the red \"Player\" move to the yellow target" +Mouse click to make the green \"Player\" move to the purple target" scroll_active = false diff --git a/project/demos/AvoidCollisions/AvoidCollisionsDemo.tscn b/project/demos/AvoidCollisions/AvoidCollisionsDemo.tscn index 1e22796..2525f2d 100644 --- a/project/demos/AvoidCollisions/AvoidCollisionsDemo.tscn +++ b/project/demos/AvoidCollisions/AvoidCollisionsDemo.tscn @@ -1,19 +1,27 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://demos/AvoidCollisions/Spawner.gd" type="Script" id=1] [ext_resource path="res://demos/AvoidCollisions/AvoidCollisionsDemo.gd" type="Script" id=2] [ext_resource path="res://demos/AvoidCollisions/Avoider.tscn" type="PackedScene" id=3] [ext_resource path="res://assets/theme/gdquest.theme" type="Theme" id=4] +[ext_resource path="res://assets/sprites/background.png" type="Texture" id=5] [node name="AvoidCollisionsDemo" type="Node2D"] script = ExtResource( 2 ) proximity_radius = 100.0 +[node name="BackgroudLayer" type="CanvasLayer" parent="."] +layer = -1 + +[node name="Background" type="Sprite" parent="BackgroudLayer"] +texture = ExtResource( 5 ) +centered = false + [node name="Spawner" type="Node2D" parent="."] script = ExtResource( 1 ) avoider_template = ExtResource( 3 ) -normal_color = Color( 0.94902, 0.0588235, 0.0588235, 1 ) -highlight_color = Color( 0.0901961, 0.929412, 0.929412, 1 ) +inner_color = Color( 0.235294, 0.639216, 0.439216, 1 ) +outer_color = Color( 0.560784, 0.870588, 0.364706, 1 ) [node name="GUI" type="PanelContainer" parent="."] margin_right = 1024.0 diff --git a/project/demos/AvoidCollisions/Avoider.gd b/project/demos/AvoidCollisions/Avoider.gd index de899ad..ad87840 100644 --- a/project/demos/AvoidCollisions/Avoider.gd +++ b/project/demos/AvoidCollisions/Avoider.gd @@ -9,7 +9,8 @@ var _radius: float var _accel := GSTTargetAcceleration.new() var _velocity := Vector2.ZERO var _direction := Vector2() -var _drag: = 0.1 +var _drag := 0.1 +var _color := Color(0.4, 1.0, 0.89, 0.3) onready var collision := $CollisionShape2D onready var agent := GSTSteeringAgent.new() @@ -18,12 +19,11 @@ onready var avoid := GSTAvoidCollisions.new(agent, proximity) onready var target := GSTAgentLocation.new() onready var seek := GSTSeek.new(agent, target) onready var priority := GSTPriority.new(agent, 0.0001) -onready var sprite := $Sprite func _draw() -> void: if draw_proximity: - draw_circle(Vector2.ZERO, proximity.radius, Color(0, 1, 0, 0.1)) + draw_circle(Vector2.ZERO, proximity.radius, _color) func _physics_process(delta: float) -> void: diff --git a/project/demos/AvoidCollisions/Avoider.tscn b/project/demos/AvoidCollisions/Avoider.tscn index 0e3386f..f550a14 100644 --- a/project/demos/AvoidCollisions/Avoider.tscn +++ b/project/demos/AvoidCollisions/Avoider.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=2] -[ext_resource path="res://assets/sprites/small_circle.png" type="Texture" id=1] +[ext_resource path="res://demos/Utils/CircleDraw.gd" type="Script" id=1] [ext_resource path="res://demos/AvoidCollisions/Avoider.gd" type="Script" id=2] [sub_resource type="CircleShape2D" id=1] @@ -11,7 +11,7 @@ script = ExtResource( 2 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource( 1 ) - -[node name="Sprite" type="Sprite" parent="."] -modulate = Color( 0.94902, 0.211765, 0.0901961, 1 ) -texture = ExtResource( 1 ) +script = ExtResource( 1 ) +inner_color = Color( 0.890196, 0.411765, 0.337255, 1 ) +outer_color = Color( 1, 0.709804, 0.439216, 1 ) +stroke = 4.0 diff --git a/project/demos/AvoidCollisions/Spawner.gd b/project/demos/AvoidCollisions/Spawner.gd index 8960d9f..035be60 100644 --- a/project/demos/AvoidCollisions/Spawner.gd +++ b/project/demos/AvoidCollisions/Spawner.gd @@ -2,14 +2,15 @@ extends Node2D export var avoider_template: PackedScene -export var normal_color := Color() -export var highlight_color := Color() +export var inner_color := Color() +export var outer_color := Color() var boundaries: Vector2 func _ready() -> void: - boundaries = Vector2(ProjectSettings["display/window/size/width"], + boundaries = Vector2( + ProjectSettings["display/window/size/width"], ProjectSettings["display/window/size/height"]) var rng: = RandomNumberGenerator.new() var avoiders := [] @@ -28,7 +29,9 @@ func _ready() -> void: ) avoider_agents.append(avoider.agent) avoider.set_random_nonoverlapping_position(avoiders, 16) - avoider.sprite.modulate = normal_color if i != 0 or not owner.draw_proximity else highlight_color + if i == 0: + avoider.collision.inner_color = inner_color + avoider.collision.outer_color = outer_color avoiders.append(avoider) for child in get_children(): child.set_proximity_agents(avoider_agents) @@ -58,8 +61,4 @@ func set_proximity_radius(value: float) -> void: func set_draw_proximity(value: bool) -> void: var child := get_child(0) child.draw_proximity = value - if not value: - child.sprite.modulate = normal_color - else: - child.sprite.modulate = highlight_color child.update() diff --git a/project/demos/Face/FaceDemo.tscn b/project/demos/Face/FaceDemo.tscn index 5108dd5..a7865b6 100644 --- a/project/demos/Face/FaceDemo.tscn +++ b/project/demos/Face/FaceDemo.tscn @@ -3,9 +3,9 @@ [ext_resource path="res://demos/Face/Turret.gd" type="Script" id=1] [ext_resource path="res://demos/Face/FaceDemo.gd" type="Script" id=2] [ext_resource path="res://demos/Face/Player.gd" type="Script" id=3] -[ext_resource path="res://assets/sprites/large_circle.png" type="Texture" id=4] -[ext_resource path="res://assets/sprites/small_circle.png" type="Texture" id=5] [ext_resource path="res://assets/theme/gdquest.theme" type="Theme" id=6] +[ext_resource path="res://assets/sprites/background.png" type="Texture" id=7] +[ext_resource path="res://demos/Utils/CircleDraw.gd" type="Script" id=8] [sub_resource type="CircleShape2D" id=1] radius = 16.0 @@ -19,16 +19,23 @@ __meta__ = { "_editor_description_": "A demo showing the usage of the Face steering behavior." } +[node name="BackgroudLayer" type="CanvasLayer" parent="."] +layer = -1 + +[node name="Background" type="Sprite" parent="BackgroudLayer"] +texture = ExtResource( 7 ) +centered = false + [node name="Player" type="KinematicBody2D" parent="."] position = Vector2( 512, 450 ) script = ExtResource( 3 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="Player"] shape = SubResource( 1 ) - -[node name="Sprite" type="Sprite" parent="Player"] -modulate = Color( 0.945098, 0.215686, 0.0705882, 1 ) -texture = ExtResource( 5 ) +script = ExtResource( 8 ) +inner_color = Color( 0.235294, 0.639216, 0.439216, 1 ) +outer_color = Color( 0.560784, 0.870588, 0.364706, 1 ) +stroke = 4.0 [node name="Turret" type="KinematicBody2D" parent="."] position = Vector2( 512, 286.288 ) @@ -36,10 +43,10 @@ script = ExtResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="Turret"] shape = SubResource( 2 ) - -[node name="Sprite" type="Sprite" parent="Turret"] -modulate = Color( 0.137255, 0.866667, 0.647059, 1 ) -texture = ExtResource( 4 ) +script = ExtResource( 8 ) +inner_color = Color( 0.890196, 0.411765, 0.337255, 1 ) +outer_color = Color( 1, 0.709804, 0.439216, 1 ) +stroke = 8.0 [node name="GUI" type="PanelContainer" parent="."] margin_right = 1024.0 @@ -53,10 +60,14 @@ __meta__ = { margin_right = 1024.0 margin_bottom = 87.0 -[node name="Label" type="Label" parent="GUI/MarginContainer"] +[node name="RichTextLabel" type="RichTextLabel" parent="GUI/MarginContainer"] margin_left = 16.0 margin_top = 16.0 margin_right = 1008.0 margin_bottom = 71.0 +rect_min_size = Vector2( 0, 55 ) +bbcode_enabled = true +bbcode_text = "Face Demo +Move the [color=lime]green player[/color] around with WASD and notice the [color=#ffb570]orange turret[/color] orient itself" text = "Face Demo -Move the player around with WASD and notice the turret orient itself" +Move the green player around with WASD and notice the orange turret orient itself" diff --git a/project/demos/Face/Turret.gd b/project/demos/Face/Turret.gd index d1d03eb..468bf54 100644 --- a/project/demos/Face/Turret.gd +++ b/project/demos/Face/Turret.gd @@ -7,6 +7,7 @@ var agent := GSTSteeringAgent.new() var _accel := GSTTargetAcceleration.new() var _angular_drag := 0.1 var _cannon: Rect2 +var _color: Color onready var collision_shape := $CollisionShape2D @@ -14,6 +15,7 @@ onready var collision_shape := $CollisionShape2D func _ready() -> void: var radius = collision_shape.shape.radius _cannon = Rect2(Vector2(-5, 0), Vector2(10, -radius*2)) + _color = collision_shape.outer_color func _physics_process(delta: float) -> void: @@ -29,7 +31,7 @@ func _physics_process(delta: float) -> void: func _draw() -> void: - draw_rect(_cannon, Color.cadetblue) + draw_rect(_cannon, _color) func setup( diff --git a/project/demos/FollowPath/FollowPathDemo.tscn b/project/demos/FollowPath/FollowPathDemo.tscn index 05b440b..500cd75 100644 --- a/project/demos/FollowPath/FollowPathDemo.tscn +++ b/project/demos/FollowPath/FollowPathDemo.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://demos/FollowPath/Drawer.gd" type="Script" id=1] -[ext_resource path="res://assets/sprites/small_circle.png" type="Texture" id=2] [ext_resource path="res://demos/FollowPath/PathFollower.gd" type="Script" id=3] [ext_resource path="res://demos/FollowPath/FollowPathDemo.gd" type="Script" id=4] [ext_resource path="res://assets/theme/gdquest.theme" type="Theme" id=5] +[ext_resource path="res://demos/Utils/CircleDraw.gd" type="Script" id=6] +[ext_resource path="res://assets/sprites/background.png" type="Texture" id=7] [sub_resource type="CircleShape2D" id=1] radius = 16.0 @@ -12,6 +13,13 @@ radius = 16.0 [node name="FollowPathDemo" type="Node2D"] script = ExtResource( 4 ) +[node name="BackgroudLayer" type="CanvasLayer" parent="."] +layer = -1 + +[node name="Background" type="Sprite" parent="BackgroudLayer"] +texture = ExtResource( 7 ) +centered = false + [node name="Drawer" type="Node2D" parent="."] script = ExtResource( 1 ) @@ -21,10 +29,10 @@ script = ExtResource( 3 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="PathFollower"] shape = SubResource( 1 ) - -[node name="Sprite" type="Sprite" parent="PathFollower"] -modulate = Color( 0.960784, 0.231373, 0.0392157, 1 ) -texture = ExtResource( 2 ) +script = ExtResource( 6 ) +inner_color = Color( 0.235294, 0.639216, 0.439216, 1 ) +outer_color = Color( 0.560784, 0.870588, 0.364706, 1 ) +stroke = 4.0 [node name="GUI" type="PanelContainer" parent="."] margin_right = 1024.0 @@ -46,7 +54,7 @@ margin_bottom = 100.0 rect_min_size = Vector2( 0, 84 ) bbcode_enabled = true bbcode_text = "Follow Path Demo -Use the mouse to draw a path on screen and watch the [color=red]red \"Agent\"[/color] follow it to the end." +Use the mouse to draw a path on screen and watch the [color=lime]green \"Agent\"[/color] follow it to the end." text = "Follow Path Demo -Use the mouse to draw a path on screen and watch the red \"Agent\" follow it to the end." +Use the mouse to draw a path on screen and watch the green \"Agent\" follow it to the end." scroll_active = false diff --git a/project/demos/GroupBehaviors/GroupBehaviorsDemo.tscn b/project/demos/GroupBehaviors/GroupBehaviorsDemo.tscn index fe8461c..9e7cd2d 100644 --- a/project/demos/GroupBehaviors/GroupBehaviorsDemo.tscn +++ b/project/demos/GroupBehaviors/GroupBehaviorsDemo.tscn @@ -1,15 +1,23 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://demos/GroupBehaviors/Member.tscn" type="PackedScene" id=1] [ext_resource path="res://demos/GroupBehaviors/Spawner.gd" type="Script" id=2] [ext_resource path="res://demos/GroupBehaviors/GroupBehaviorsDemo.gd" type="Script" id=3] [ext_resource path="res://assets/theme/gdquest.theme" type="Theme" id=4] +[ext_resource path="res://assets/sprites/background.png" type="Texture" id=5] [node name="GroupBehaviorsDemo" type="Node2D"] script = ExtResource( 3 ) cohesion_strength = 0.2 separation_strength = 4.5 +[node name="BackgroudLayer" type="CanvasLayer" parent="."] +layer = -1 + +[node name="Background" type="Sprite" parent="BackgroudLayer"] +texture = ExtResource( 5 ) +centered = false + [node name="Spawner" type="Node2D" parent="."] position = Vector2( 512, 300 ) script = ExtResource( 2 ) diff --git a/project/demos/GroupBehaviors/Member.gd b/project/demos/GroupBehaviors/Member.gd index 92ebf53..43eca39 100644 --- a/project/demos/GroupBehaviors/Member.gd +++ b/project/demos/GroupBehaviors/Member.gd @@ -12,6 +12,8 @@ var draw_proximity := false var _color := Color.red var _velocity := Vector2() +onready var collision_shape := $CollisionShape2D + func setup( linear_speed_max: float, @@ -22,7 +24,7 @@ func setup( separation_strength: float ) -> void: _color = Color(rand_range(0.5, 1), rand_range(0.25, 1), rand_range(0, 1)) - $Sprite.modulate = _color + collision_shape.inner_color = _color agent.linear_acceleration_max = linear_accel_max agent.linear_speed_max = linear_speed_max @@ -37,7 +39,7 @@ func setup( func _draw() -> void: if draw_proximity: - draw_circle(Vector2.ZERO, proximity.radius, Color(0, 1, 0, 0.1)) + draw_circle(Vector2.ZERO, proximity.radius, Color(0.4, 1.0, 0.89, 0.3)) func _physics_process(delta: float) -> void: diff --git a/project/demos/GroupBehaviors/Member.tscn b/project/demos/GroupBehaviors/Member.tscn index fbd24df..0baef77 100644 --- a/project/demos/GroupBehaviors/Member.tscn +++ b/project/demos/GroupBehaviors/Member.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=2] [ext_resource path="res://demos/GroupBehaviors/Member.gd" type="Script" id=1] -[ext_resource path="res://assets/sprites/small_circle.png" type="Texture" id=2] +[ext_resource path="res://demos/Utils/CircleDraw.gd" type="Script" id=3] [sub_resource type="CircleShape2D" id=1] radius = 16.0 @@ -11,6 +11,6 @@ script = ExtResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource( 1 ) - -[node name="Sprite" type="Sprite" parent="."] -texture = ExtResource( 2 ) +script = ExtResource( 3 ) +outer_color = Color( 0.301961, 0.65098, 1, 1 ) +stroke = 4.0 diff --git a/project/demos/PursueSeek/PursueVSSeekDemo.tscn b/project/demos/PursueSeek/PursueVSSeekDemo.tscn index 8f6c051..3086e09 100644 --- a/project/demos/PursueSeek/PursueVSSeekDemo.tscn +++ b/project/demos/PursueSeek/PursueVSSeekDemo.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://demos/PursueSeek/Pursuer.gd" type="Script" id=1] [ext_resource path="res://demos/PursueSeek/Player.gd" type="Script" id=2] @@ -6,6 +6,7 @@ [ext_resource path="res://demos/PursueSeek/PursueVSSeekDemo.gd" type="Script" id=4] [ext_resource path="res://assets/theme/gdquest.theme" type="Theme" id=5] [ext_resource path="res://assets/sprites/triangle.png" type="Texture" id=6] +[ext_resource path="res://assets/sprites/background.png" type="Texture" id=7] [node name="PursueVSSeekDemo" type="Node2D"] script = ExtResource( 4 ) @@ -16,6 +17,13 @@ linear_speed_max = 240.0 linear_accel_max = 40.0 predict_time = 1.1 +[node name="BackgroudLayer" type="CanvasLayer" parent="."] +layer = -1 + +[node name="Background" type="Sprite" parent="BackgroudLayer"] +texture = ExtResource( 7 ) +centered = false + [node name="BoundaryManager" type="Node2D" parent="."] script = ExtResource( 3 ) @@ -43,7 +51,7 @@ script = ExtResource( 1 ) polygon = PoolVector2Array( 0, -32, -24, 32, 24, 32 ) [node name="Sprite" type="Sprite" parent="BoundaryManager/Pursuer"] -modulate = Color( 0.756863, 0.952941, 0.054902, 1 ) +modulate = Color( 1, 0.937255, 0.0235294, 1 ) texture = ExtResource( 6 ) [node name="Seeker" type="KinematicBody2D" parent="BoundaryManager"] @@ -80,7 +88,7 @@ margin_bottom = 100.0 rect_min_size = Vector2( 0, 84 ) bbcode_enabled = true bbcode_text = "Pursue vs. Seek Demo -Move the player around with WASD and notice the [color=yellow]yellow Pursuer[/color] and the [color=green]green Seeker[/color] follow +Move the player around with WASD and notice the [color=yellow]yellow Pursuer[/color] and the [color=lime]green Seeker[/color] follow the [color=red]red \"Ship\"[/color] around" text = "Pursue vs. Seek Demo Move the player around with WASD and notice the yellow Pursuer and the green Seeker follow diff --git a/project/demos/SeekFlee/Boundary.gd b/project/demos/SeekFlee/Boundary.gd index 37ac21e..c986800 100644 --- a/project/demos/SeekFlee/Boundary.gd +++ b/project/demos/SeekFlee/Boundary.gd @@ -2,6 +2,8 @@ extends StaticBody2D # Draws the bounding box of the static body wall. +const COLOR := Color("8fde5d") + var rect: Rect2 @@ -11,4 +13,4 @@ func _ready() -> void: func _draw() -> void: - draw_rect(rect, Color.yellowgreen) + draw_rect(rect, COLOR) diff --git a/project/demos/SeekFlee/Player.gd b/project/demos/SeekFlee/Player.gd index 85eaa6b..f0de8b7 100644 --- a/project/demos/SeekFlee/Player.gd +++ b/project/demos/SeekFlee/Player.gd @@ -16,5 +16,6 @@ func _physics_process(delta: float) -> void: func _get_movement() -> Vector2: - return Vector2( Input.get_action_strength("sf_right") - Input.get_action_strength("sf_left"), - Input.get_action_strength("sf_down") - Input.get_action_strength("sf_up")) + return Vector2( + Input.get_action_strength("sf_right") - Input.get_action_strength("sf_left"), + Input.get_action_strength("sf_down") - Input.get_action_strength("sf_up")) diff --git a/project/demos/SeekFlee/SeekFleeDemo.tscn b/project/demos/SeekFlee/SeekFleeDemo.tscn index 7e9dab0..0195541 100644 --- a/project/demos/SeekFlee/SeekFleeDemo.tscn +++ b/project/demos/SeekFlee/SeekFleeDemo.tscn @@ -6,7 +6,7 @@ [ext_resource path="res://demos/SeekFlee/Spawner.gd" type="Script" id=4] [ext_resource path="res://assets/theme/gdquest.theme" type="Theme" id=5] [ext_resource path="res://demos/SeekFlee/Seeker.tscn" type="PackedScene" id=6] -[ext_resource path="res://assets/sprites/large_circle.png" type="Texture" id=7] +[ext_resource path="res://demos/Utils/CircleDraw.gd" type="Script" id=7] [sub_resource type="CircleShape2D" id=1] radius = 32.0 @@ -22,6 +22,7 @@ script = ExtResource( 3 ) __meta__ = { "_editor_description_": "A toy demo to demonstrate the usage for the Seek and Flee steering behaviors." } +behavior_mode = 0 [node name="Camera2D" type="Camera2D" parent="."] current = true @@ -32,10 +33,10 @@ script = ExtResource( 2 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="Player"] shape = SubResource( 1 ) - -[node name="Sprite" type="Sprite" parent="Player"] -modulate = Color( 0.952941, 0.290196, 0.0588235, 1 ) -texture = ExtResource( 7 ) +script = ExtResource( 7 ) +inner_color = Color( 0.235294, 0.639216, 0.439216, 1 ) +outer_color = Color( 0.560784, 0.870588, 0.364706, 1 ) +stroke = 4.0 [node name="LeftBoundary" type="StaticBody2D" parent="."] position = Vector2( -512, 0 ) @@ -99,6 +100,6 @@ margin_bottom = 100.0 rect_min_size = Vector2( 0, 84 ) bbcode_enabled = true bbcode_text = "Seek & Flee Demo -Move the [color=red]red \"Player\"[/color] around with WASD and notice the [color=blue]blue \"Enemies\"[/color] try to seek to or flee from the player." +Move the [color=lime]green \"Player\"[/color] around with WASD and notice the [color=#ffb570]orange \"Enemies\"[/color] try to seek to or flee from the player." text = "Seek & Flee Demo -Move the red \"Player\" around with WASD and notice the blue \"Enemies\" try to seek to or flee from the player." +Move the green \"Player\" around with WASD and notice the orange \"Enemies\" try to seek to or flee from the player." diff --git a/project/demos/SeekFlee/Seeker.tscn b/project/demos/SeekFlee/Seeker.tscn index 3ffce34..9452469 100644 --- a/project/demos/SeekFlee/Seeker.tscn +++ b/project/demos/SeekFlee/Seeker.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=2] [ext_resource path="res://demos/SeekFlee/Seeker.gd" type="Script" id=1] -[ext_resource path="res://assets/sprites/small_circle.png" type="Texture" id=2] +[ext_resource path="res://demos/Utils/CircleDraw.gd" type="Script" id=2] [sub_resource type="CircleShape2D" id=1] radius = 16.0 @@ -13,7 +13,7 @@ script = ExtResource( 1 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource( 1 ) - -[node name="Sprite" type="Sprite" parent="."] -modulate = Color( 0.113725, 0.635294, 0.94902, 1 ) -texture = ExtResource( 2 ) +script = ExtResource( 2 ) +inner_color = Color( 0.890196, 0.411765, 0.337255, 1 ) +outer_color = Color( 1, 0.709804, 0.439216, 1 ) +stroke = 4.0 diff --git a/project/demos/Utils/CircleDraw.gd b/project/demos/Utils/CircleDraw.gd new file mode 100644 index 0000000..47b51b1 --- /dev/null +++ b/project/demos/Utils/CircleDraw.gd @@ -0,0 +1,26 @@ +tool +extends CollisionShape2D + +export(Color) var inner_color := Color() setget set_inner_color +export(Color) var outer_color := Color() setget set_outer_color +export(float) var stroke := 0.0 setget set_stroke + + +func _draw() -> void: + draw_circle(Vector2.ZERO, shape.radius + stroke, outer_color) + draw_circle(Vector2.ZERO, shape.radius, inner_color) + + +func set_inner_color(val: Color) -> void: + inner_color = val + update() + + +func set_outer_color(val: Color) -> void: + outer_color = val + update() + + +func set_stroke(val: float) -> void: + stroke = val + update()