Add GDQuest theme to improved seek demo

Replaced the text boxes with sliders to improve usability.
This commit is contained in:
Francois Belair 2020-01-13 12:38:46 -05:00
parent b0442982d0
commit 82d92016a4
31 changed files with 270 additions and 65 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,11 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://assets/theme/fonts/montserrat/Montserrat-Medium.ttf" type="DynamicFontData" id=1]
[resource]
size = 20
use_filter = true
font_data = ExtResource( 1 )

View File

@ -0,0 +1,11 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://assets/theme/fonts/montserrat/Montserrat-Bold.ttf" type="DynamicFontData" id=1]
[resource]
size = 20
use_filter = true
font_data = ExtResource( 1 )

View File

@ -0,0 +1,11 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://assets/theme/fonts/source_code_pro/SourceCodePro-Medium.otf" type="DynamicFontData" id=1]
[resource]
size = 20
use_filter = true
font_data = ExtResource( 1 )

View File

@ -0,0 +1,11 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[ext_resource path="res://assets/theme/fonts/montserrat/Montserrat-Black.ttf" type="DynamicFontData" id=1]
[resource]
size = 28
use_filter = true
font_data = ExtResource( 1 )

Binary file not shown.

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right"><polyline points="9 18 15 12 9 6"></polyline></svg>

After

Width:  |  Height:  |  Size: 270 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/chevron-right.svg-f77dee7a088177a2ac1d467f4c7cd3e1.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/theme/icons/chevron-right.svg"
dest_files=[ "res://.import/chevron-right.svg-f77dee7a088177a2ac1d467f4c7cd3e1.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

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-up"><polyline points="18 15 12 9 6 15"></polyline></svg>

After

Width:  |  Height:  |  Size: 268 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/chevron-up.svg-48b5b69265734774d0a7516dcc6f0863.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/theme/icons/chevron-up.svg"
dest_files=[ "res://.import/chevron-up.svg-48b5b69265734774d0a7516dcc6f0863.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

Binary file not shown.

View File

@ -0,0 +1,7 @@
[gd_resource type="StyleBoxLine" format=2]
[resource]
color = Color( 1, 1, 1, 0.196078 )
thickness = 2

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
[gd_scene format=2]
[node name="FollowPathDemo" type="Node2D"]

View File

@ -1,17 +1,27 @@
extends MarginContainer extends PanelContainer
enum BehaviorMode { SEEK, FLEE } enum BehaviorMode { SEEK, FLEE }
signal mode_changed(behavior_mode) signal mode_changed(behavior_mode)
signal acc_changed(value)
signal speed_changed(value)
onready var seek: CheckBox = $BehaviorControls/Seek onready var seek: = $MarginContainer/BehaviorControls/Seek
onready var flee: CheckBox = $BehaviorControls/Flee onready var flee: = $MarginContainer/BehaviorControls/Flee
onready var max_acc: = $MarginContainer/BehaviorControls/MaxAccValue
onready var max_speed: = $MarginContainer/BehaviorControls/MaxSpeedValue
onready var max_acc_label: = $MarginContainer/BehaviorControls/MaxAcc
onready var max_speed_label: = $MarginContainer/BehaviorControls/MaxSpeed
func _ready() -> void: func _ready() -> void:
seek.connect("pressed", self, "_on_Seek_pressed") seek.connect("pressed", self, "_on_Seek_pressed")
flee.connect("pressed", self, "_on_Flee_pressed") flee.connect("pressed", self, "_on_Flee_pressed")
max_acc.connect("value_changed", self, "_on_Acc_changed")
max_speed.connect("value_changed", self, "_on_Speed_changed")
max_acc_label.text = "Max accel (" + str(max_acc.value) + ")"
max_speed_label.text = "Max speed (" + str(max_speed.value) + ")"
func _on_Seek_pressed() -> void: func _on_Seek_pressed() -> void:
@ -26,3 +36,13 @@ func _on_Flee_pressed() -> void:
seek.button_mask = BUTTON_MASK_LEFT seek.button_mask = BUTTON_MASK_LEFT
flee.button_mask = 0 flee.button_mask = 0
emit_signal("mode_changed", BehaviorMode.FLEE) emit_signal("mode_changed", BehaviorMode.FLEE)
func _on_Acc_changed(value: float) -> void:
max_acc_label.text = "Max accel (" + str(value) + ")"
emit_signal("acc_changed", value)
func _on_Speed_changed(value: float) -> void:
max_speed_label.text = "Max speed (" + str(value) + ")"
emit_signal("speed_changed", value)

View File

@ -1,98 +1,143 @@
[gd_scene load_steps=2 format=2] [gd_scene load_steps=3 format=2]
[ext_resource path="res://assets/theme/gdquest.theme" type="Theme" id=1]
[ext_resource path="res://demos/seek_and_flee/GUI.gd" type="Script" id=3] [ext_resource path="res://demos/seek_and_flee/GUI.gd" type="Script" id=3]
[node name="GUI" type="MarginContainer"] [node name="GUI" type="PanelContainer"]
anchor_bottom = 1.0 anchor_bottom = 1.0
margin_right = 116.0 margin_right = 118.0
custom_constants/margin_right = 20 theme = ExtResource( 1 )
custom_constants/margin_top = 20
custom_constants/margin_left = 20
custom_constants/margin_bottom = 20
script = ExtResource( 3 ) script = ExtResource( 3 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="BehaviorControls" type="VBoxContainer" parent="."] [node name="MarginContainer" type="MarginContainer" parent="."]
margin_right = 218.0
margin_bottom = 600.0
custom_constants/margin_right = 20
custom_constants/margin_top = 20
custom_constants/margin_left = 20
custom_constants/margin_bottom = 20
__meta__ = {
"_edit_use_anchors_": false
}
[node name="BehaviorControls" type="VBoxContainer" parent="MarginContainer"]
margin_left = 20.0 margin_left = 20.0
margin_top = 20.0 margin_top = 20.0
margin_right = 96.0 margin_right = 198.0
margin_bottom = 580.0 margin_bottom = 580.0
[node name="Seek" type="CheckBox" parent="BehaviorControls"] [node name="Seek" type="CheckBox" parent="MarginContainer/BehaviorControls"]
margin_right = 76.0 margin_right = 178.0
margin_bottom = 24.0 margin_bottom = 26.0
focus_mode = 0 focus_mode = 0
pressed = true pressed = true
enabled_focus_mode = 0 enabled_focus_mode = 0
text = "Seek" text = "Seek"
[node name="Flee" type="CheckBox" parent="BehaviorControls"] [node name="Flee" type="CheckBox" parent="MarginContainer/BehaviorControls"]
margin_top = 28.0 margin_top = 34.0
margin_right = 76.0 margin_right = 178.0
margin_bottom = 52.0 margin_bottom = 60.0
focus_mode = 0 focus_mode = 0
enabled_focus_mode = 0 enabled_focus_mode = 0
text = "Flee" text = "Flee"
[node name="Help" type="VBoxContainer" parent="BehaviorControls"] [node name="MaxAcc" type="Label" parent="MarginContainer/BehaviorControls"]
margin_top = 56.0 margin_top = 68.0
margin_right = 76.0 margin_right = 178.0
margin_bottom = 108.0 margin_bottom = 94.0
text = "Max accel (2000)"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Controls" type="Label" parent="BehaviorControls/Help"] [node name="MaxAccValue" type="HSlider" parent="MarginContainer/BehaviorControls"]
margin_right = 76.0 margin_top = 102.0
margin_bottom = 14.0 margin_right = 178.0
margin_bottom = 118.0
max_value = 250.0
step = 0.5
value = 20.0
[node name="MaxSpeed" type="Label" parent="MarginContainer/BehaviorControls"]
margin_top = 126.0
margin_right = 178.0
margin_bottom = 152.0
text = "Max speed (2000)"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MaxSpeedValue" type="HSlider" parent="MarginContainer/BehaviorControls"]
margin_top = 160.0
margin_right = 178.0
margin_bottom = 176.0
max_value = 450.0
step = 1.0
value = 100.0
[node name="Help" type="VBoxContainer" parent="MarginContainer/BehaviorControls"]
margin_top = 184.0
margin_right = 178.0
margin_bottom = 274.0
[node name="Controls" type="Label" parent="MarginContainer/BehaviorControls/Help"]
margin_right = 178.0
margin_bottom = 26.0
text = "Controls" text = "Controls"
[node name="GridContainer" type="GridContainer" parent="BehaviorControls/Help"] [node name="GridContainer" type="GridContainer" parent="MarginContainer/BehaviorControls/Help"]
margin_top = 18.0 margin_left = 57.0
margin_right = 76.0 margin_top = 34.0
margin_bottom = 52.0 margin_right = 120.0
margin_bottom = 90.0
size_flags_horizontal = 4
columns = 3 columns = 3
[node name="Sep" type="Control" parent="BehaviorControls/Help/GridContainer"] [node name="Sep" type="Control" parent="MarginContainer/BehaviorControls/Help/GridContainer"]
margin_right = 15.0 margin_right = 15.0
margin_bottom = 15.0 margin_bottom = 26.0
rect_min_size = Vector2( 15, 15 ) rect_min_size = Vector2( 15, 15 )
[node name="W" type="Label" parent="BehaviorControls/Help/GridContainer"] [node name="W" type="Label" parent="MarginContainer/BehaviorControls/Help/GridContainer"]
margin_left = 19.0 margin_left = 19.0
margin_right = 34.0 margin_right = 42.0
margin_bottom = 15.0 margin_bottom = 26.0
rect_min_size = Vector2( 15, 15 ) rect_min_size = Vector2( 15, 15 )
text = "W" text = "W"
align = 1 align = 1
[node name="Sep2" type="Control" parent="BehaviorControls/Help/GridContainer"] [node name="Sep2" type="Control" parent="MarginContainer/BehaviorControls/Help/GridContainer"]
margin_left = 38.0 margin_left = 46.0
margin_right = 53.0 margin_right = 63.0
margin_bottom = 15.0 margin_bottom = 26.0
rect_min_size = Vector2( 15, 15 ) rect_min_size = Vector2( 15, 15 )
[node name="A" type="Label" parent="BehaviorControls/Help/GridContainer"] [node name="A" type="Label" parent="MarginContainer/BehaviorControls/Help/GridContainer"]
margin_top = 19.0 margin_top = 30.0
margin_right = 15.0 margin_right = 15.0
margin_bottom = 34.0 margin_bottom = 56.0
rect_min_size = Vector2( 15, 15 ) rect_min_size = Vector2( 15, 15 )
text = "A" text = "A"
align = 1 align = 1
[node name="S" type="Label" parent="BehaviorControls/Help/GridContainer"] [node name="S" type="Label" parent="MarginContainer/BehaviorControls/Help/GridContainer"]
margin_left = 19.0 margin_left = 19.0
margin_top = 19.0 margin_top = 30.0
margin_right = 34.0 margin_right = 42.0
margin_bottom = 34.0 margin_bottom = 56.0
rect_min_size = Vector2( 15, 15 ) rect_min_size = Vector2( 15, 15 )
text = "S" text = "S"
align = 1 align = 1
[node name="D" type="Label" parent="BehaviorControls/Help/GridContainer"] [node name="D" type="Label" parent="MarginContainer/BehaviorControls/Help/GridContainer"]
margin_left = 38.0 margin_left = 46.0
margin_top = 19.0 margin_top = 30.0
margin_right = 53.0 margin_right = 63.0
margin_bottom = 34.0 margin_bottom = 56.0
rect_min_size = Vector2( 15, 15 ) rect_min_size = Vector2( 15, 15 )
text = "D" text = "D"
align = 1 align = 1

View File

@ -23,6 +23,9 @@ func _ready() -> void:
var rng: = RandomNumberGenerator.new() var rng: = RandomNumberGenerator.new()
rng.randomize() rng.randomize()
gui.max_acc.value = spawner.max_accel
gui.max_speed.value = spawner.max_speed
for i in range(spawner.entity_count): for i in range(spawner.entity_count):
var new_pos: = Vector2( var new_pos: = Vector2(
rng.randf_range(-camera_boundaries.size.x/2, camera_boundaries.size.x/2), rng.randf_range(-camera_boundaries.size.x/2, camera_boundaries.size.x/2),
@ -31,7 +34,10 @@ func _ready() -> void:
var entity: KinematicBody2D = spawner.Entity.instance() var entity: KinematicBody2D = spawner.Entity.instance()
entity.global_position = new_pos entity.global_position = new_pos
entity.player_agent = player.agent entity.player_agent = player.agent
entity.speed = rng.randf_range(spawner.min_speed, spawner.max_speed) entity.start_speed = spawner.max_speed
entity.start_accel = spawner.max_accel
entity.color = spawner.entity_color entity.color = spawner.entity_color
gui.connect("mode_changed", entity, "_on_GUI_mode_changed") gui.connect("mode_changed", entity, "_on_GUI_mode_changed")
gui.connect("acc_changed", entity, "_on_GUI_acc_changed")
gui.connect("speed_changed", entity, "_on_GUI_speed_changed")
spawner.add_child(entity) spawner.add_child(entity)

View File

@ -71,9 +71,11 @@ shape = SubResource( 3 )
[node name="Spawner" type="Node2D" parent="."] [node name="Spawner" type="Node2D" parent="."]
script = ExtResource( 4 ) script = ExtResource( 4 )
Entity = ExtResource( 6 ) Entity = ExtResource( 6 )
max_speed = 150.0
[node name="GUI" parent="." instance=ExtResource( 5 )] [node name="GUI" parent="." instance=ExtResource( 5 )]
margin_left = -512.0 margin_left = -512.0
margin_top = -300.0 margin_top = -300.0
margin_right = -414.0 margin_right = -386.0
margin_bottom = -152.0 margin_bottom = -102.0
rect_min_size = Vector2( 0, 600 )

View File

@ -12,14 +12,15 @@ onready var _active_behavior: = seek
var player_agent: GSTAgentLocation var player_agent: GSTAgentLocation
var velocity: = Vector2.ZERO var velocity: = Vector2.ZERO
var speed: float var start_speed: float
var start_accel: float
var color: Color var color: Color
var radius: = 0.0 var radius: = 0.0
func _ready() -> void: func _ready() -> void:
agent.max_linear_acceleration = speed/10 agent.max_linear_acceleration = start_accel
agent.max_linear_speed = speed agent.max_linear_speed = start_speed
radius = collision_shape.shape.radius radius = collision_shape.shape.radius
@ -36,12 +37,13 @@ func _physics_process(delta: float) -> void:
velocity = (velocity + Vector2(accel.linear.x, accel.linear.y)).clamped(agent.max_linear_speed) velocity = (velocity + Vector2(accel.linear.x, accel.linear.y)).clamped(agent.max_linear_speed)
velocity = move_and_slide(velocity) velocity = move_and_slide(velocity)
if velocity.length_squared() > 0:
update()
func _update_agent() -> void: func _update_agent() -> void:
agent.position = Vector3(global_position.x, global_position.y, 0) agent.position.x = global_position.x
agent.position.y = global_position.y
agent.linear_velocity.x = velocity.x
agent.linear_velocity.y = velocity.y
func _on_GUI_mode_changed(mode: int) -> void: func _on_GUI_mode_changed(mode: int) -> void:
@ -49,3 +51,11 @@ func _on_GUI_mode_changed(mode: int) -> void:
_active_behavior = seek _active_behavior = seek
else: else:
_active_behavior = flee _active_behavior = flee
func _on_GUI_acc_changed(value: float) -> void:
agent.max_linear_acceleration = value
func _on_GUI_speed_changed(value: float) -> void:
agent.max_linear_speed = value

View File

@ -2,13 +2,11 @@
[ext_resource path="res://demos/seek_and_flee/Seeker.gd" type="Script" id=1] [ext_resource path="res://demos/seek_and_flee/Seeker.gd" type="Script" id=1]
[sub_resource type="CircleShape2D" id=1] [sub_resource type="CircleShape2D" id=1]
[node name="Seeker" type="KinematicBody2D"] [node name="Seeker" type="KinematicBody2D"]
collision_layer = 4 collision_layer = 4
collision_mask = 6 collision_mask = 2
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]

View File

@ -5,5 +5,5 @@ extends Node2D
export(PackedScene) var Entity: PackedScene export(PackedScene) var Entity: PackedScene
export var entity_count: = 10 export var entity_count: = 10
export var entity_color: = Color.blue export var entity_color: = Color.blue
export var min_speed: = 50.0 export var max_speed: = 100.0
export var max_speed: = 125.0 export var max_accel: = 20.0