mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2025-12-16 13:30:07 +01:00
General proofreading (#1262)
* General proofreading for grammar and spelling * General formatting * Addition of appropriate literals where appropriate, i.e. `&"foo"` for `StringName` cases and `^"foo/bar"` for `NodePath` cases
This commit is contained in:
@@ -17,7 +17,7 @@ var shape := RID()
|
|||||||
class Bullet:
|
class Bullet:
|
||||||
var position := Vector2()
|
var position := Vector2()
|
||||||
var speed := 1.0
|
var speed := 1.0
|
||||||
# The body is stored as a RID, which is an "opaque" way to access resources.
|
# The body is stored as an RID, which is an "opaque" way to access resources.
|
||||||
# With large amounts of objects (thousands or more), it can be significantly
|
# With large amounts of objects (thousands or more), it can be significantly
|
||||||
# faster to use RIDs compared to a high-level approach.
|
# faster to use RIDs compared to a high-level approach.
|
||||||
var body := RID()
|
var body := RID()
|
||||||
@@ -42,9 +42,9 @@ func _ready() -> void:
|
|||||||
# Place bullets randomly on the viewport and move bullets outside the
|
# Place bullets randomly on the viewport and move bullets outside the
|
||||||
# play area so that they fade in nicely.
|
# play area so that they fade in nicely.
|
||||||
bullet.position = Vector2(
|
bullet.position = Vector2(
|
||||||
randf_range(0, get_viewport_rect().size.x) + get_viewport_rect().size.x,
|
randf_range(0, get_viewport_rect().size.x) + get_viewport_rect().size.x,
|
||||||
randf_range(0, get_viewport_rect().size.y)
|
randf_range(0, get_viewport_rect().size.y)
|
||||||
)
|
)
|
||||||
var transform2d := Transform2D()
|
var transform2d := Transform2D()
|
||||||
transform2d.origin = bullet.position
|
transform2d.origin = bullet.position
|
||||||
PhysicsServer2D.body_set_state(bullet.body, PhysicsServer2D.BODY_STATE_TRANSFORM, transform2d)
|
PhysicsServer2D.body_set_state(bullet.body, PhysicsServer2D.BODY_STATE_TRANSFORM, transform2d)
|
||||||
|
|||||||
@@ -40,4 +40,4 @@ func _draw() -> void:
|
|||||||
Color.MEDIUM_AQUAMARINE,
|
Color.MEDIUM_AQUAMARINE,
|
||||||
line_width_thin,
|
line_width_thin,
|
||||||
use_antialiasing
|
use_antialiasing
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ func _draw() -> void:
|
|||||||
draw_animation_slice(ANIMATION_LENGTH, slice_begin, slice_end)
|
draw_animation_slice(ANIMATION_LENGTH, slice_begin, slice_end)
|
||||||
draw_set_transform(margin + offset, deg_to_rad(randf_range(-5.0, 5.0)))
|
draw_set_transform(margin + offset, deg_to_rad(randf_range(-5.0, 5.0)))
|
||||||
draw_rect(
|
draw_rect(
|
||||||
Rect2(Vector2(), Vector2(100, 50)),
|
Rect2(Vector2(), Vector2(100, 50)),
|
||||||
Color.from_hsv(randf(), 0.4, 1.0),
|
Color.from_hsv(randf(), 0.4, 1.0),
|
||||||
true,
|
true,
|
||||||
-1.0,
|
-1.0,
|
||||||
use_antialiasing
|
use_antialiasing
|
||||||
)
|
)
|
||||||
|
|
||||||
draw_end_animation()
|
draw_end_animation()
|
||||||
|
|||||||
@@ -50,11 +50,11 @@ func _draw() -> void:
|
|||||||
draw_circle(margin + offset, 40 - antialiasing_width_offset * 0.5, Color.ORANGE, true, -1.0, use_antialiasing)
|
draw_circle(margin + offset, 40 - antialiasing_width_offset * 0.5, Color.ORANGE, true, -1.0, use_antialiasing)
|
||||||
|
|
||||||
# `draw_set_transform()` is a stateful command: it affects *all* `draw_` methods within this
|
# `draw_set_transform()` is a stateful command: it affects *all* `draw_` methods within this
|
||||||
# `_draw()` function after it. This can be used to translate, rotate or scale `draw_` methods
|
# `_draw()` function after it. This can be used to translate, rotate, or scale `draw_` methods
|
||||||
# that don't offer dedicated parameters for this (such as `draw_primitive()` not having a position parameter).
|
# that don't offer dedicated parameters for this (such as `draw_primitive()` not having a position parameter).
|
||||||
# To reset back to the initial transform, call `draw_set_transform(Vector2())`.
|
# To reset back to the initial transform, call `draw_set_transform(Vector2())`.
|
||||||
#
|
#
|
||||||
# Draw an horizontally stretched circle.
|
# Draw a horizontally stretched circle.
|
||||||
offset += Vector2(200, 0)
|
offset += Vector2(200, 0)
|
||||||
draw_set_transform(margin + offset, 0.0, Vector2(3.0, 1.0))
|
draw_set_transform(margin + offset, 0.0, Vector2(3.0, 1.0))
|
||||||
draw_circle(Vector2(), 40, Color.ORANGE, false, line_width_thin, use_antialiasing)
|
draw_circle(Vector2(), 40, Color.ORANGE, false, line_width_thin, use_antialiasing)
|
||||||
@@ -82,7 +82,7 @@ func _draw() -> void:
|
|||||||
offset += Vector2(100, 0)
|
offset += Vector2(100, 0)
|
||||||
draw_arc(margin + offset, 40, -0.25 * TAU, 0.5 * TAU, POINT_COUNT_LOW, Color.YELLOW, 6.0 - antialiasing_width_offset, use_antialiasing)
|
draw_arc(margin + offset, 40, -0.25 * TAU, 0.5 * TAU, POINT_COUNT_LOW, Color.YELLOW, 6.0 - antialiasing_width_offset, use_antialiasing)
|
||||||
|
|
||||||
# Draw an horizontally stretched arc.
|
# Draw a horizontally stretched arc.
|
||||||
offset += Vector2(200, 0)
|
offset += Vector2(200, 0)
|
||||||
draw_set_transform(margin + offset, 0.0, Vector2(3.0, 1.0))
|
draw_set_transform(margin + offset, 0.0, Vector2(3.0, 1.0))
|
||||||
draw_arc(Vector2(), 40, -0.25 * TAU, 0.5 * TAU, POINT_COUNT_LOW, Color.YELLOW, line_width_thin, use_antialiasing)
|
draw_arc(Vector2(), 40, -0.25 * TAU, 0.5 * TAU, POINT_COUNT_LOW, Color.YELLOW, line_width_thin, use_antialiasing)
|
||||||
|
|||||||
@@ -40,12 +40,13 @@ func _ready() -> void:
|
|||||||
multi_mesh.set_instance_color(4, Color(0.7, 1, 1))
|
multi_mesh.set_instance_color(4, Color(0.7, 1, 1))
|
||||||
multi_mesh.mesh = sphere_mesh
|
multi_mesh.mesh = sphere_mesh
|
||||||
|
|
||||||
|
|
||||||
func _draw() -> void:
|
func _draw() -> void:
|
||||||
const margin := Vector2(300, 70)
|
const margin := Vector2(300, 70)
|
||||||
var offset := Vector2()
|
var offset := Vector2()
|
||||||
|
|
||||||
# `draw_set_transform()` is a stateful command: it affects *all* `draw_` methods within this
|
# `draw_set_transform()` is a stateful command: it affects *all* `draw_` methods within this
|
||||||
# `_draw()` function after it. This can be used to translate, rotate or scale `draw_` methods
|
# `_draw()` function after it. This can be used to translate, rotate, or scale `draw_` methods
|
||||||
# that don't offer dedicated parameters for this (such as `draw_primitive()` not having a position parameter).
|
# that don't offer dedicated parameters for this (such as `draw_primitive()` not having a position parameter).
|
||||||
# To reset back to the initial transform, call `draw_set_transform(Vector2())`.
|
# To reset back to the initial transform, call `draw_set_transform(Vector2())`.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -20,25 +20,25 @@ func _draw() -> void:
|
|||||||
var antialiasing_width_offset := 1.0 if use_antialiasing else 0.0
|
var antialiasing_width_offset := 1.0 if use_antialiasing else 0.0
|
||||||
|
|
||||||
var points := PackedVector2Array([
|
var points := PackedVector2Array([
|
||||||
Vector2(0, 0),
|
Vector2(0, 0),
|
||||||
Vector2(0, 60),
|
Vector2(0, 60),
|
||||||
Vector2(60, 90),
|
Vector2(60, 90),
|
||||||
Vector2(60, 0),
|
Vector2(60, 0),
|
||||||
Vector2(40, 25),
|
Vector2(40, 25),
|
||||||
Vector2(10, 40),
|
Vector2(10, 40),
|
||||||
])
|
])
|
||||||
var colors := PackedColorArray([
|
var colors := PackedColorArray([
|
||||||
Color.WHITE,
|
Color.WHITE,
|
||||||
Color.RED,
|
Color.RED,
|
||||||
Color.GREEN,
|
Color.GREEN,
|
||||||
Color.BLUE,
|
Color.BLUE,
|
||||||
Color.MAGENTA,
|
Color.MAGENTA,
|
||||||
Color.MAGENTA,
|
Color.MAGENTA,
|
||||||
])
|
])
|
||||||
|
|
||||||
var offset := Vector2()
|
var offset := Vector2()
|
||||||
# `draw_set_transform()` is a stateful command: it affects *all* `draw_` methods within this
|
# `draw_set_transform()` is a stateful command: it affects *all* `draw_` methods within this
|
||||||
# `_draw()` function after it. This can be used to translate, rotate or scale `draw_` methods
|
# `_draw()` function after it. This can be used to translate, rotate, or scale `draw_` methods
|
||||||
# that don't offer dedicated parameters for this (such as `draw_primitive()` not having a position parameter).
|
# that don't offer dedicated parameters for this (such as `draw_primitive()` not having a position parameter).
|
||||||
# To reset back to the initial transform, call `draw_set_transform(Vector2())`.
|
# To reset back to the initial transform, call `draw_set_transform(Vector2())`.
|
||||||
draw_set_transform(margin + offset)
|
draw_set_transform(margin + offset)
|
||||||
@@ -57,7 +57,7 @@ func _draw() -> void:
|
|||||||
draw_primitive(points.slice(0, 4), colors.slice(0, 4), PackedVector2Array())
|
draw_primitive(points.slice(0, 4), colors.slice(0, 4), PackedVector2Array())
|
||||||
|
|
||||||
# Draw a polygon with multiple colors that are interpolated between each point.
|
# Draw a polygon with multiple colors that are interpolated between each point.
|
||||||
# Colors are specified in the same order as points' positions, but in a different array.
|
# Colors are specified in the same order as the points' positions, but in a different array.
|
||||||
offset = Vector2(0, 120)
|
offset = Vector2(0, 120)
|
||||||
draw_set_transform(margin + offset)
|
draw_set_transform(margin + offset)
|
||||||
draw_polygon(points, colors)
|
draw_polygon(points, colors)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func _draw() -> void:
|
|||||||
false,
|
false,
|
||||||
line_width_thin,
|
line_width_thin,
|
||||||
use_antialiasing
|
use_antialiasing
|
||||||
)
|
)
|
||||||
|
|
||||||
offset += Vector2(120, 0)
|
offset += Vector2(120, 0)
|
||||||
draw_rect(
|
draw_rect(
|
||||||
@@ -35,7 +35,7 @@ func _draw() -> void:
|
|||||||
false,
|
false,
|
||||||
2.0 - antialiasing_width_offset,
|
2.0 - antialiasing_width_offset,
|
||||||
use_antialiasing
|
use_antialiasing
|
||||||
)
|
)
|
||||||
|
|
||||||
offset += Vector2(120, 0)
|
offset += Vector2(120, 0)
|
||||||
draw_rect(
|
draw_rect(
|
||||||
@@ -44,7 +44,7 @@ func _draw() -> void:
|
|||||||
false,
|
false,
|
||||||
6.0 - antialiasing_width_offset,
|
6.0 - antialiasing_width_offset,
|
||||||
use_antialiasing
|
use_antialiasing
|
||||||
)
|
)
|
||||||
|
|
||||||
# Draw a filled rectangle. The width parameter is ignored for filled rectangles (it's set to `-1.0` to avoid warnings).
|
# Draw a filled rectangle. The width parameter is ignored for filled rectangles (it's set to `-1.0` to avoid warnings).
|
||||||
# We also reduce the rectangle's size by half the antialiasing width offset.
|
# We also reduce the rectangle's size by half the antialiasing width offset.
|
||||||
@@ -56,10 +56,10 @@ func _draw() -> void:
|
|||||||
true,
|
true,
|
||||||
-1.0,
|
-1.0,
|
||||||
use_antialiasing
|
use_antialiasing
|
||||||
)
|
)
|
||||||
|
|
||||||
# `draw_set_transform()` is a stateful command: it affects *all* `draw_` methods within this
|
# `draw_set_transform()` is a stateful command: it affects *all* `draw_` methods within this
|
||||||
# `_draw()` function after it. This can be used to translate, rotate or scale `draw_` methods
|
# `_draw()` function after it. This can be used to translate, rotate, or scale `draw_` methods
|
||||||
# that don't offer dedicated parameters for this (such as `draw_rect()` not having a rotation parameter).
|
# that don't offer dedicated parameters for this (such as `draw_rect()` not having a rotation parameter).
|
||||||
# To reset back to the initial transform, call `draw_set_transform(Vector2())`.
|
# To reset back to the initial transform, call `draw_set_transform(Vector2())`.
|
||||||
offset += Vector2(170, 0)
|
offset += Vector2(170, 0)
|
||||||
@@ -70,7 +70,7 @@ func _draw() -> void:
|
|||||||
false,
|
false,
|
||||||
line_width_thin,
|
line_width_thin,
|
||||||
use_antialiasing
|
use_antialiasing
|
||||||
)
|
)
|
||||||
offset += Vector2(120, 0)
|
offset += Vector2(120, 0)
|
||||||
draw_set_transform(margin + offset, deg_to_rad(22.5))
|
draw_set_transform(margin + offset, deg_to_rad(22.5))
|
||||||
draw_rect(
|
draw_rect(
|
||||||
@@ -79,7 +79,7 @@ func _draw() -> void:
|
|||||||
false,
|
false,
|
||||||
2.0 - antialiasing_width_offset,
|
2.0 - antialiasing_width_offset,
|
||||||
use_antialiasing
|
use_antialiasing
|
||||||
)
|
)
|
||||||
offset += Vector2(120, 0)
|
offset += Vector2(120, 0)
|
||||||
draw_set_transform(margin + offset, deg_to_rad(22.5))
|
draw_set_transform(margin + offset, deg_to_rad(22.5))
|
||||||
draw_rect(
|
draw_rect(
|
||||||
@@ -88,7 +88,7 @@ func _draw() -> void:
|
|||||||
false,
|
false,
|
||||||
6.0 - antialiasing_width_offset,
|
6.0 - antialiasing_width_offset,
|
||||||
use_antialiasing
|
use_antialiasing
|
||||||
)
|
)
|
||||||
|
|
||||||
# `draw_set_transform_matrix()` is a more advanced counterpart of `draw_set_transform()`.
|
# `draw_set_transform_matrix()` is a more advanced counterpart of `draw_set_transform()`.
|
||||||
# It can be used to apply transforms that are not supported by `draw_set_transform()`, such as
|
# It can be used to apply transforms that are not supported by `draw_set_transform()`, such as
|
||||||
@@ -99,12 +99,12 @@ func _draw() -> void:
|
|||||||
custom_transform.y.x -= 0.5
|
custom_transform.y.x -= 0.5
|
||||||
draw_set_transform_matrix(custom_transform)
|
draw_set_transform_matrix(custom_transform)
|
||||||
draw_rect(
|
draw_rect(
|
||||||
Rect2(Vector2(), Vector2(100, 50)),
|
Rect2(Vector2(), Vector2(100, 50)),
|
||||||
Color.PURPLE,
|
Color.PURPLE,
|
||||||
false,
|
false,
|
||||||
6.0 - antialiasing_width_offset,
|
6.0 - antialiasing_width_offset,
|
||||||
use_antialiasing
|
use_antialiasing
|
||||||
)
|
)
|
||||||
draw_set_transform(Vector2())
|
draw_set_transform(Vector2())
|
||||||
|
|
||||||
offset = Vector2(0, 250)
|
offset = Vector2(0, 250)
|
||||||
|
|||||||
@@ -21,16 +21,16 @@ func _draw() -> void:
|
|||||||
# Get the glyph index of the character we've just drawn, so we can retrieve the glyph advance.
|
# Get the glyph index of the character we've just drawn, so we can retrieve the glyph advance.
|
||||||
# This determines the spacing between glyphs so the next character is positioned correctly.
|
# This determines the spacing between glyphs so the next character is positioned correctly.
|
||||||
var glyph_idx := TextServerManager.get_primary_interface().font_get_glyph_index(
|
var glyph_idx := TextServerManager.get_primary_interface().font_get_glyph_index(
|
||||||
get_theme_default_font().get_rids()[0],
|
get_theme_default_font().get_rids()[0],
|
||||||
FONT_SIZE,
|
FONT_SIZE,
|
||||||
character.unicode_at(0),
|
character.unicode_at(0),
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
advance.x += TextServerManager.get_primary_interface().font_get_glyph_advance(
|
advance.x += TextServerManager.get_primary_interface().font_get_glyph_advance(
|
||||||
get_theme_default_font().get_rids()[0],
|
get_theme_default_font().get_rids()[0],
|
||||||
FONT_SIZE,
|
FONT_SIZE,
|
||||||
glyph_idx
|
glyph_idx
|
||||||
).x
|
).x
|
||||||
|
|
||||||
offset += Vector2(0, 32)
|
offset += Vector2(0, 32)
|
||||||
# When drawing a font outline, it must be drawn *before* the main text.
|
# When drawing a font outline, it must be drawn *before* the main text.
|
||||||
@@ -44,7 +44,7 @@ func _draw() -> void:
|
|||||||
FONT_SIZE,
|
FONT_SIZE,
|
||||||
12,
|
12,
|
||||||
Color.ORANGE.darkened(0.6)
|
Color.ORANGE.darkened(0.6)
|
||||||
)
|
)
|
||||||
# NOTE: Use `draw_multiline_string()` to draw strings that contain line breaks (`\n`) or with
|
# NOTE: Use `draw_multiline_string()` to draw strings that contain line breaks (`\n`) or with
|
||||||
# automatic line wrapping based on the specified width.
|
# automatic line wrapping based on the specified width.
|
||||||
# A width of `-1` is used here, which means "no limit". If width is limited, the end of the string
|
# A width of `-1` is used here, which means "no limit". If width is limited, the end of the string
|
||||||
@@ -57,4 +57,4 @@ func _draw() -> void:
|
|||||||
-1,
|
-1,
|
||||||
FONT_SIZE,
|
FONT_SIZE,
|
||||||
Color.YELLOW
|
Color.YELLOW
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ func _draw() -> void:
|
|||||||
draw_texture(ICON, margin + offset, Color.WHITE)
|
draw_texture(ICON, margin + offset, Color.WHITE)
|
||||||
|
|
||||||
# `draw_set_transform()` is a stateful command: it affects *all* `draw_` methods within this
|
# `draw_set_transform()` is a stateful command: it affects *all* `draw_` methods within this
|
||||||
# `_draw()` function after it. This can be used to translate, rotate or scale `draw_` methods
|
# `_draw()` function after it. This can be used to translate, rotate, or scale `draw_` methods
|
||||||
# that don't offer dedicated parameters for this (such as `draw_rect()` not having a rotation parameter).
|
# that don't offer dedicated parameters for this (such as `draw_rect()` not having a rotation parameter).
|
||||||
# To reset back to the initial transform, call `draw_set_transform(Vector2())`.
|
# To reset back to the initial transform, call `draw_set_transform(Vector2())`.
|
||||||
#
|
#
|
||||||
@@ -30,7 +30,7 @@ func _draw() -> void:
|
|||||||
Rect2(margin + offset, Vector2(256, 256)),
|
Rect2(margin + offset, Vector2(256, 256)),
|
||||||
false,
|
false,
|
||||||
Color.GREEN
|
Color.GREEN
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Draw a tiled texture. In this example, the icon is 128×128 so it will be drawn twice on each axis.
|
# Draw a tiled texture. In this example, the icon is 128×128 so it will be drawn twice on each axis.
|
||||||
@@ -40,7 +40,7 @@ func _draw() -> void:
|
|||||||
Rect2(margin + offset, Vector2(256, 256)),
|
Rect2(margin + offset, Vector2(256, 256)),
|
||||||
true,
|
true,
|
||||||
Color.GREEN
|
Color.GREEN
|
||||||
)
|
)
|
||||||
|
|
||||||
offset = Vector2(0, 300)
|
offset = Vector2(0, 300)
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ func _draw() -> void:
|
|||||||
Rect2(margin + offset, Vector2(128, 128)),
|
Rect2(margin + offset, Vector2(128, 128)),
|
||||||
Rect2(Vector2(32, 32), Vector2(64, 64)),
|
Rect2(Vector2(32, 32), Vector2(64, 64)),
|
||||||
Color.VIOLET
|
Color.VIOLET
|
||||||
)
|
)
|
||||||
|
|
||||||
# Draw a tiled texture from a region that is larger than the original texture size (128×128).
|
# Draw a tiled texture from a region that is larger than the original texture size (128×128).
|
||||||
# Transposing is enabled, which will rotate the image by 90 degrees counter-clockwise.
|
# Transposing is enabled, which will rotate the image by 90 degrees counter-clockwise.
|
||||||
@@ -64,4 +64,4 @@ func _draw() -> void:
|
|||||||
Rect2(Vector2(), Vector2(512, 512)),
|
Rect2(Vector2(), Vector2(512, 512)),
|
||||||
Color.VIOLET,
|
Color.VIOLET,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func _on_MobTimer_timeout():
|
|||||||
# Spawn the mob by adding it to the Main scene.
|
# Spawn the mob by adding it to the Main scene.
|
||||||
add_child(mob)
|
add_child(mob)
|
||||||
|
|
||||||
|
|
||||||
func _on_ScoreTimer_timeout():
|
func _on_ScoreTimer_timeout():
|
||||||
score += 1
|
score += 1
|
||||||
$HUD.update_score(score)
|
$HUD.update_score(score)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ extends Node2D
|
|||||||
var bullet := preload("Bullet.tscn")
|
var bullet := preload("Bullet.tscn")
|
||||||
|
|
||||||
func _unhandled_input(input_event: InputEvent) -> void:
|
func _unhandled_input(input_event: InputEvent) -> void:
|
||||||
if input_event.is_action_pressed("fire"):
|
if input_event.is_action_pressed(&"fire"):
|
||||||
fire()
|
fire()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ var look_direction := Vector2.RIGHT:
|
|||||||
look_direction = value
|
look_direction = value
|
||||||
set_look_direction(value)
|
set_look_direction(value)
|
||||||
|
|
||||||
|
|
||||||
func take_damage(attacker: Node, amount: float, effect: Node = null) -> void:
|
func take_damage(attacker: Node, amount: float, effect: Node = null) -> void:
|
||||||
if is_ancestor_of(attacker):
|
if is_ancestor_of(attacker):
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ func _unhandled_input(input_event: InputEvent) -> void:
|
|||||||
if input_event.is_action_pressed(PLAYER_STATE.attack):
|
if input_event.is_action_pressed(PLAYER_STATE.attack):
|
||||||
if current_state in [attack, stagger]:
|
if current_state in [attack, stagger]:
|
||||||
return
|
return
|
||||||
|
|
||||||
_change_state(PLAYER_STATE.attack)
|
_change_state(PLAYER_STATE.attack)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ extends "res://player/player_state.gd"
|
|||||||
# Collection of important methods to handle direction and animation.
|
# Collection of important methods to handle direction and animation.
|
||||||
|
|
||||||
func handle_input(input_event: InputEvent) -> void:
|
func handle_input(input_event: InputEvent) -> void:
|
||||||
if input_event.is_action_pressed("simulate_damage"):
|
if input_event.is_action_pressed(&"simulate_damage"):
|
||||||
finished.emit(PLAYER_STATE.stagger)
|
finished.emit(PLAYER_STATE.stagger)
|
||||||
|
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ func get_input_direction() -> Vector2:
|
|||||||
return Vector2(
|
return Vector2(
|
||||||
Input.get_axis(&"move_left", &"move_right"),
|
Input.get_axis(&"move_left", &"move_right"),
|
||||||
Input.get_axis(&"move_up", &"move_down")
|
Input.get_axis(&"move_up", &"move_down")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func update_look_direction(direction: Vector2) -> void:
|
func update_look_direction(direction: Vector2) -> void:
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ func update(_delta: float) -> void:
|
|||||||
finished.emit(PLAYER_STATE.idle)
|
finished.emit(PLAYER_STATE.idle)
|
||||||
update_look_direction(input_direction)
|
update_look_direction(input_direction)
|
||||||
|
|
||||||
if Input.is_action_pressed("run"):
|
if Input.is_action_pressed(&"run"):
|
||||||
speed = max_run_speed
|
speed = max_run_speed
|
||||||
else:
|
else:
|
||||||
speed = max_walk_speed
|
speed = max_walk_speed
|
||||||
@@ -30,7 +30,7 @@ func update(_delta: float) -> void:
|
|||||||
var collision_info := move(speed, input_direction)
|
var collision_info := move(speed, input_direction)
|
||||||
if not collision_info:
|
if not collision_info:
|
||||||
return
|
return
|
||||||
if speed == max_run_speed and collision_info.collider.is_in_group("environment"):
|
if speed == max_run_speed and collision_info.collider.is_in_group(&"environment"):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ var speed := 0.0
|
|||||||
var velocity := Vector2()
|
var velocity := Vector2()
|
||||||
|
|
||||||
func handle_input(input_event: InputEvent) -> void:
|
func handle_input(input_event: InputEvent) -> void:
|
||||||
if input_event.is_action_pressed("jump"):
|
if input_event.is_action_pressed(&"jump"):
|
||||||
finished.emit(PLAYER_STATE.jump)
|
finished.emit(PLAYER_STATE.jump)
|
||||||
|
|
||||||
return super.handle_input(input_event)
|
return super.handle_input(input_event)
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ var combo := [{
|
|||||||
|
|
||||||
var hit_objects := []
|
var hit_objects := []
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
$AnimationPlayer.animation_finished.connect(_on_animation_finished)
|
$AnimationPlayer.animation_finished.connect(_on_animation_finished)
|
||||||
body_entered.connect(_on_body_entered)
|
body_entered.connect(_on_body_entered)
|
||||||
@@ -63,6 +64,7 @@ func _change_state(new_state: States) -> void:
|
|||||||
$AnimationPlayer.play(attack_current["animation"])
|
$AnimationPlayer.play(attack_current["animation"])
|
||||||
visible = true
|
visible = true
|
||||||
monitoring = true
|
monitoring = true
|
||||||
|
|
||||||
state = new_state
|
state = new_state
|
||||||
|
|
||||||
|
|
||||||
@@ -71,7 +73,7 @@ func _unhandled_input(input_event: InputEvent) -> void:
|
|||||||
return
|
return
|
||||||
if attack_input_state != AttackInputStates.LISTENING:
|
if attack_input_state != AttackInputStates.LISTENING:
|
||||||
return
|
return
|
||||||
if input_event.is_action_pressed("attack"):
|
if input_event.is_action_pressed(&"attack"):
|
||||||
attack_input_state = AttackInputStates.REGISTERED
|
attack_input_state = AttackInputStates.REGISTERED
|
||||||
|
|
||||||
|
|
||||||
@@ -96,7 +98,7 @@ func set_ready_for_next_attack() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_body_entered(body: Node2D) -> void:
|
func _on_body_entered(body: Node2D) -> void:
|
||||||
if not body.has_node("Health"):
|
if not body.has_node(^"Health"):
|
||||||
return
|
return
|
||||||
if body.get_rid().get_id() in hit_objects:
|
if body.get_rid().get_id() in hit_objects:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ var _active := false:
|
|||||||
_active = value
|
_active = value
|
||||||
set_active(value)
|
set_active(value)
|
||||||
|
|
||||||
|
|
||||||
func _enter_tree() -> void:
|
func _enter_tree() -> void:
|
||||||
if start_state.is_empty():
|
if start_state.is_empty():
|
||||||
start_state = get_child(0).get_path()
|
start_state = get_child(0).get_path()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
if event is InputEventMouseMotion and event.button_mask > 0:
|
if event is InputEventMouseMotion and event.button_mask > 0:
|
||||||
cave.position.x = clampf(cave.position.x + event.screen_relative.x, -CAVE_LIMIT, 0)
|
cave.position.x = clampf(cave.position.x + event.screen_relative.x, -CAVE_LIMIT, 0)
|
||||||
|
|
||||||
if event.is_action_pressed("toggle_glow_map"):
|
if event.is_action_pressed(&"toggle_glow_map"):
|
||||||
if $WorldEnvironment.environment.glow_map:
|
if $WorldEnvironment.environment.glow_map:
|
||||||
$WorldEnvironment.environment.glow_map = null
|
$WorldEnvironment.environment.glow_map = null
|
||||||
# Restore glow intensity to its default value
|
# Restore glow intensity to its default value
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ var anim_directions = {
|
|||||||
|
|
||||||
func _physics_process(_delta):
|
func _physics_process(_delta):
|
||||||
var motion = Vector2()
|
var motion = Vector2()
|
||||||
motion.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
|
motion.x = Input.get_action_strength(&"move_right") - Input.get_action_strength(&"move_left")
|
||||||
motion.y = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
|
motion.y = Input.get_action_strength(&"move_down") - Input.get_action_strength(&"move_up")
|
||||||
motion.y /= 2
|
motion.y /= 2
|
||||||
motion = motion.normalized() * MOTION_SPEED
|
motion = motion.normalized() * MOTION_SPEED
|
||||||
set_velocity(motion)
|
set_velocity(motion)
|
||||||
|
|||||||
@@ -2,16 +2,16 @@ extends Node2D
|
|||||||
|
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed("toggle_directional_light"):
|
if event.is_action_pressed(&"toggle_directional_light"):
|
||||||
$DirectionalLight2D.visible = not $DirectionalLight2D.visible
|
$DirectionalLight2D.visible = not $DirectionalLight2D.visible
|
||||||
|
|
||||||
if event.is_action_pressed("toggle_point_lights"):
|
if event.is_action_pressed(&"toggle_point_lights"):
|
||||||
for point_light in get_tree().get_nodes_in_group("point_light"):
|
for point_light in get_tree().get_nodes_in_group(&"point_light"):
|
||||||
point_light.visible = not point_light.visible
|
point_light.visible = not point_light.visible
|
||||||
|
|
||||||
if event.is_action_pressed("cycle_directional_light_shadows_quality"):
|
if event.is_action_pressed(&"cycle_directional_light_shadows_quality"):
|
||||||
$DirectionalLight2D.shadow_filter = wrapi($DirectionalLight2D.shadow_filter + 1, 0, 3)
|
$DirectionalLight2D.shadow_filter = wrapi($DirectionalLight2D.shadow_filter + 1, 0, 3)
|
||||||
|
|
||||||
if event.is_action_pressed("cycle_point_light_shadows_quality"):
|
if event.is_action_pressed(&"cycle_point_light_shadows_quality"):
|
||||||
for point_light in get_tree().get_nodes_in_group("point_light"):
|
for point_light in get_tree().get_nodes_in_group(&"point_light"):
|
||||||
point_light.shadow_filter = wrapi(point_light.shadow_filter + 1, 0, 3)
|
point_light.shadow_filter = wrapi(point_light.shadow_filter + 1, 0, 3)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func _ready() -> void:
|
|||||||
# The "click" event is a custom input action defined in
|
# The "click" event is a custom input action defined in
|
||||||
# Project > Project Settings > Input Map tab.
|
# Project > Project Settings > Input Map tab.
|
||||||
func _unhandled_input(event: InputEvent) -> void:
|
func _unhandled_input(event: InputEvent) -> void:
|
||||||
if not event.is_action_pressed("click"):
|
if not event.is_action_pressed(&"click"):
|
||||||
return
|
return
|
||||||
|
|
||||||
set_movement_target(get_global_mouse_position())
|
set_movement_target(get_global_mouse_position())
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ var _path := PackedVector2Array()
|
|||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
# Region should match the size of the playable area plus one (in tiles).
|
# Region should match the size of the playable area plus one (in tiles).
|
||||||
# In this demo, the playable area is 17×9 tiles, so the rect size is 18×10.
|
# In this demo, the playable area is 17×9 tiles, so the rect size is 18×10.
|
||||||
# Depending on the setup TileMapLayer's get_used_rect() can also be used.
|
# Depending on the setup, TileMapLayer's get_used_rect() can also be used.
|
||||||
_astar.region = Rect2i(0, 0, 18, 10)
|
_astar.region = Rect2i(0, 0, 18, 10)
|
||||||
_astar.cell_size = CELL_SIZE
|
_astar.cell_size = CELL_SIZE
|
||||||
_astar.offset = CELL_SIZE * 0.5
|
_astar.offset = CELL_SIZE * 0.5
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ func _ready() -> void:
|
|||||||
|
|
||||||
# Add an outline to define the traversable surface that the parsed collision shapes can "cut" into.
|
# Add an outline to define the traversable surface that the parsed collision shapes can "cut" into.
|
||||||
var traversable_outline: PackedVector2Array = PackedVector2Array([
|
var traversable_outline: PackedVector2Array = PackedVector2Array([
|
||||||
Vector2(0.0, 0.0),
|
Vector2(0.0, 0.0),
|
||||||
Vector2(1920.0, 0.0),
|
Vector2(1920.0, 0.0),
|
||||||
Vector2(1920.0, 1080.0),
|
Vector2(1920.0, 1080.0),
|
||||||
Vector2(0.0, 1080.0),
|
Vector2(0.0, 1080.0),
|
||||||
])
|
])
|
||||||
source_geometry.add_traversable_outline(traversable_outline)
|
source_geometry.add_traversable_outline(traversable_outline)
|
||||||
|
|
||||||
create_region_chunks(%ChunksContainer, source_geometry, chunk_size * cell_size, agent_radius)
|
create_region_chunks(%ChunksContainer, source_geometry, chunk_size * cell_size, agent_radius)
|
||||||
@@ -49,21 +49,21 @@ static func create_region_chunks(chunks_root_node: Node, p_source_geometry: Navi
|
|||||||
|
|
||||||
# Rasterize bounding box into chunk grid to know range of required chunks.
|
# Rasterize bounding box into chunk grid to know range of required chunks.
|
||||||
var start_chunk: Vector2 = floor(
|
var start_chunk: Vector2 = floor(
|
||||||
input_geometry_bounds.position / p_chunk_size
|
input_geometry_bounds.position / p_chunk_size
|
||||||
)
|
)
|
||||||
var end_chunk: Vector2 = floor(
|
var end_chunk: Vector2 = floor(
|
||||||
(input_geometry_bounds.position + input_geometry_bounds.size)
|
(input_geometry_bounds.position + input_geometry_bounds.size)
|
||||||
/ p_chunk_size
|
/ p_chunk_size
|
||||||
)
|
)
|
||||||
|
|
||||||
for chunk_y in range(start_chunk.y, end_chunk.y + 1):
|
for chunk_y in range(start_chunk.y, end_chunk.y + 1):
|
||||||
for chunk_x in range(start_chunk.x, end_chunk.x + 1):
|
for chunk_x in range(start_chunk.x, end_chunk.x + 1):
|
||||||
var chunk_id: Vector2i = Vector2i(chunk_x, chunk_y)
|
var chunk_id: Vector2i = Vector2i(chunk_x, chunk_y)
|
||||||
|
|
||||||
var chunk_bounding_box: Rect2 = Rect2(
|
var chunk_bounding_box: Rect2 = Rect2(
|
||||||
Vector2(chunk_x, chunk_y) * p_chunk_size,
|
Vector2(chunk_x, chunk_y) * p_chunk_size,
|
||||||
Vector2(p_chunk_size, p_chunk_size),
|
Vector2(p_chunk_size, p_chunk_size),
|
||||||
)
|
)
|
||||||
# We grow the chunk bounding box to include geometry
|
# We grow the chunk bounding box to include geometry
|
||||||
# from all the neighbor chunks so edges can align.
|
# from all the neighbor chunks so edges can align.
|
||||||
# The border size is the same value as our grow amount so
|
# The border size is the same value as our grow amount so
|
||||||
@@ -103,9 +103,9 @@ func _process(_delta: float) -> void:
|
|||||||
return
|
return
|
||||||
|
|
||||||
var closest_point_on_navmesh: Vector2 = NavigationServer2D.map_get_closest_point(
|
var closest_point_on_navmesh: Vector2 = NavigationServer2D.map_get_closest_point(
|
||||||
map,
|
map,
|
||||||
mouse_cursor_position
|
mouse_cursor_position
|
||||||
)
|
)
|
||||||
|
|
||||||
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
|
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
|
||||||
path_start_position = closest_point_on_navmesh
|
path_start_position = closest_point_on_navmesh
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[gd_scene load_steps=2 format=3 uid="uid://b3lu6ldhoxd3w"]
|
[gd_scene load_steps=2 format=3 uid="uid://b3lu6ldhoxd3w"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://ch8mb4cgm22pr" path="res://navmesh_chhunks_demo_2d.gd" id="1_d68tl"]
|
[ext_resource type="Script" uid="uid://ch8mb4cgm22pr" path="res://navmesh_chunks_demo_2d.gd" id="1_d68tl"]
|
||||||
|
|
||||||
[node name="NavMeshChunksDemo2D" type="Node2D"]
|
[node name="NavMeshChunksDemo2D" type="Node2D"]
|
||||||
script = ExtResource("1_d68tl")
|
script = ExtResource("1_d68tl")
|
||||||
@@ -73,7 +73,7 @@ layout_mode = 2
|
|||||||
|
|
||||||
[node name="Label" type="Label" parent="CanvasLayer/PanelContainer/MarginContainer/VBoxContainer"]
|
[node name="Label" type="Label" parent="CanvasLayer/PanelContainer/MarginContainer/VBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Use cursor button to set path start position"
|
text = "Use mouse cursor to set path start position"
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/PanelContainer/MarginContainer/VBoxContainer"]
|
[node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/PanelContainer/MarginContainer/VBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
@@ -87,7 +87,7 @@ color = Color(1, 0, 1, 1)
|
|||||||
|
|
||||||
[node name="Label" type="Label" parent="CanvasLayer/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer"]
|
[node name="Label" type="Label" parent="CanvasLayer/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "Path corridor-funnel"
|
text = "Path corridor-funnel"
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
vertical_alignment = 1
|
vertical_alignment = 1
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ config_version=5
|
|||||||
|
|
||||||
config/name="Navigation Mesh Chunks 2D"
|
config/name="Navigation Mesh Chunks 2D"
|
||||||
config/tags=PackedStringArray("2d", "ai", "demo", "official")
|
config/tags=PackedStringArray("2d", "ai", "demo", "official")
|
||||||
run/main_scene="res://navmesh_chhunks_demo_2d.tscn"
|
run/main_scene="res://navmesh_chunks_demo_2d.tscn"
|
||||||
config/features=PackedStringArray("4.5", "GL Compatibility")
|
config/features=PackedStringArray("4.5", "GL Compatibility")
|
||||||
config/icon="res://icon.webp"
|
config/icon="res://icon.webp"
|
||||||
|
|
||||||
|
|||||||
@@ -7,32 +7,32 @@ func _ready() -> void:
|
|||||||
if RenderingServer.get_current_rendering_method() == "gl_compatibility":
|
if RenderingServer.get_current_rendering_method() == "gl_compatibility":
|
||||||
is_compatibility = true
|
is_compatibility = true
|
||||||
text = "Space: Pause/Resume\nG: Toggle glow\n\n\n"
|
text = "Space: Pause/Resume\nG: Toggle glow\n\n\n"
|
||||||
get_parent().get_node("UnsupportedLabel").visible = true
|
get_parent().get_node(^"UnsupportedLabel").visible = true
|
||||||
# Increase glow intensity to compensate for lower dynamic range.
|
# Increase glow intensity to compensate for lower dynamic range.
|
||||||
get_node("../..").environment.glow_intensity = 4.0
|
get_node(^"../..").environment.glow_intensity = 4.0
|
||||||
|
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed("toggle_pause"):
|
if event.is_action_pressed(&"toggle_pause"):
|
||||||
get_tree().paused = not get_tree().paused
|
get_tree().paused = not get_tree().paused
|
||||||
|
|
||||||
if not is_compatibility and event.is_action_pressed("toggle_trails"):
|
if not is_compatibility and event.is_action_pressed(&"toggle_trails"):
|
||||||
# Particles disappear if trail type is changed while paused.
|
# Particles disappear if trail type is changed while paused.
|
||||||
# Prevent changing particle type while paused to avoid confusion.
|
# Prevent changing particle type while paused to avoid confusion.
|
||||||
for particles in get_tree().get_nodes_in_group("trailable_particles"):
|
for particles in get_tree().get_nodes_in_group(&"trailable_particles"):
|
||||||
particles.trail_enabled = not particles.trail_enabled
|
particles.trail_enabled = not particles.trail_enabled
|
||||||
|
|
||||||
if not is_compatibility and event.is_action_pressed("increase_trail_length"):
|
if not is_compatibility and event.is_action_pressed(&"increase_trail_length"):
|
||||||
# Particles disappear if trail type is changed while paused.
|
# Particles disappear if trail type is changed while paused.
|
||||||
# Prevent changing particle type while paused to avoid confusion.
|
# Prevent changing particle type while paused to avoid confusion.
|
||||||
for particles in get_tree().get_nodes_in_group("trailable_particles"):
|
for particles in get_tree().get_nodes_in_group(&"trailable_particles"):
|
||||||
particles.trail_lifetime = clampf(particles.trail_lifetime + 0.05, 0.1, 1.0)
|
particles.trail_lifetime = clampf(particles.trail_lifetime + 0.05, 0.1, 1.0)
|
||||||
|
|
||||||
if not is_compatibility and event.is_action_pressed("decrease_trail_length"):
|
if not is_compatibility and event.is_action_pressed(&"decrease_trail_length"):
|
||||||
# Particles disappear if trail type is changed while paused.
|
# Particles disappear if trail type is changed while paused.
|
||||||
# Prevent changing particle type while paused to avoid confusion.
|
# Prevent changing particle type while paused to avoid confusion.
|
||||||
for particles in get_tree().get_nodes_in_group("trailable_particles"):
|
for particles in get_tree().get_nodes_in_group(&"trailable_particles"):
|
||||||
particles.trail_lifetime = clampf(particles.trail_lifetime - 0.05, 0.1, 1.0)
|
particles.trail_lifetime = clampf(particles.trail_lifetime - 0.05, 0.1, 1.0)
|
||||||
|
|
||||||
if event.is_action_pressed("toggle_glow"):
|
if event.is_action_pressed(&"toggle_glow"):
|
||||||
get_node("../..").environment.glow_enabled = not get_node("../..").environment.glow_enabled
|
get_node(^"../..").environment.glow_enabled = not get_node(^"../..").environment.glow_enabled
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ var taken := false
|
|||||||
|
|
||||||
func _on_body_enter(body: Node2D) -> void:
|
func _on_body_enter(body: Node2D) -> void:
|
||||||
if not taken and body is Player:
|
if not taken and body is Player:
|
||||||
($AnimationPlayer as AnimationPlayer).play("taken")
|
($AnimationPlayer as AnimationPlayer).play(&"taken")
|
||||||
|
|||||||
@@ -11,5 +11,5 @@ func disable() -> void:
|
|||||||
if disabled:
|
if disabled:
|
||||||
return
|
return
|
||||||
|
|
||||||
($AnimationPlayer as AnimationPlayer).play("shutdown")
|
($AnimationPlayer as AnimationPlayer).play(&"shutdown")
|
||||||
disabled = true
|
disabled = true
|
||||||
|
|||||||
@@ -19,8 +19,10 @@ class Circle2D:
|
|||||||
func _draw() -> void:
|
func _draw() -> void:
|
||||||
draw_circle(center, radius, color)
|
draw_circle(center, radius, color)
|
||||||
|
|
||||||
|
|
||||||
var _drawn_nodes := []
|
var _drawn_nodes := []
|
||||||
|
|
||||||
|
|
||||||
func _enter_tree() -> void:
|
func _enter_tree() -> void:
|
||||||
if not _enable_debug_collision:
|
if not _enable_debug_collision:
|
||||||
get_tree().debug_collisions_hint = false
|
get_tree().debug_collisions_hint = false
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ func _ready() -> void:
|
|||||||
|
|
||||||
var floor_slider: Control = find_child("FloorMaxAngle")
|
var floor_slider: Control = find_child("FloorMaxAngle")
|
||||||
if floor_slider:
|
if floor_slider:
|
||||||
floor_slider.get_node("HSlider").value = _floor_max_angle
|
floor_slider.get_node(^"HSlider").value = _floor_max_angle
|
||||||
|
|
||||||
_start_test()
|
_start_test()
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ func _remove_objects() -> void:
|
|||||||
Log.print_log("* Removing objects...")
|
Log.print_log("* Removing objects...")
|
||||||
var timer := Time.get_ticks_usec()
|
var timer := Time.get_ticks_usec()
|
||||||
|
|
||||||
# Remove objects in reversed order to avoid the overhead of changing children index in parent.
|
# Remove objects in reversed order to avoid the overhead of changing child index in parent.
|
||||||
var object_count := _objects.size()
|
var object_count := _objects.size()
|
||||||
for object_index in object_count:
|
for object_index in object_count:
|
||||||
root_node.remove_child(_objects[object_count - object_index - 1])
|
root_node.remove_child(_objects[object_count - object_index - 1])
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ func _despawn_objects() -> void:
|
|||||||
if object_count == 0:
|
if object_count == 0:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Remove objects in reversed order to avoid the overhead of changing children index in parent.
|
# Remove objects in reversed order to avoid the overhead of changing child index in parent.
|
||||||
for object_index in range(object_count):
|
for object_index in range(object_count):
|
||||||
var node: Node2D = spawn_parent.get_child(object_count - object_index - 1)
|
var node: Node2D = spawn_parent.get_child(object_count - object_index - 1)
|
||||||
spawn_parent.remove_child(node)
|
spawn_parent.remove_child(node)
|
||||||
|
|||||||
@@ -69,5 +69,6 @@ func _integrate_forces(state: PhysicsDirectBodyState2D) -> void:
|
|||||||
_jumping = false
|
_jumping = false
|
||||||
_velocity.y = 0.0
|
_velocity.y = 0.0
|
||||||
|
|
||||||
|
|
||||||
func is_on_floor() -> bool:
|
func is_on_floor() -> bool:
|
||||||
return _on_floor
|
return _on_floor
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const WALK_SPEED = 22.0
|
|||||||
|
|
||||||
var _state := State.WALKING
|
var _state := State.WALKING
|
||||||
|
|
||||||
@onready var gravity: int = ProjectSettings.get("physics/2d/default_gravity")
|
@onready var gravity: int = ProjectSettings.get(&"physics/2d/default_gravity")
|
||||||
@onready var platform_detector := $PlatformDetector as RayCast2D
|
@onready var platform_detector := $PlatformDetector as RayCast2D
|
||||||
@onready var floor_detector_left := $FloorDetectorLeft as RayCast2D
|
@onready var floor_detector_left := $FloorDetectorLeft as RayCast2D
|
||||||
@onready var floor_detector_right := $FloorDetectorRight as RayCast2D
|
@onready var floor_detector_right := $FloorDetectorRight as RayCast2D
|
||||||
|
|||||||
@@ -18,17 +18,17 @@ func close() -> void:
|
|||||||
var tween := create_tween()
|
var tween := create_tween()
|
||||||
get_tree().paused = false
|
get_tree().paused = false
|
||||||
tween.tween_property(
|
tween.tween_property(
|
||||||
self,
|
self,
|
||||||
^"modulate:a",
|
^"modulate:a",
|
||||||
0.0,
|
0.0,
|
||||||
fade_out_duration
|
fade_out_duration
|
||||||
).set_trans(Tween.TRANS_LINEAR).set_ease(Tween.EASE_OUT)
|
).set_trans(Tween.TRANS_LINEAR).set_ease(Tween.EASE_OUT)
|
||||||
tween.parallel().tween_property(
|
tween.parallel().tween_property(
|
||||||
center_cont,
|
center_cont,
|
||||||
^"anchor_bottom",
|
^"anchor_bottom",
|
||||||
0.5,
|
0.5,
|
||||||
fade_out_duration
|
fade_out_duration
|
||||||
).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)
|
).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)
|
||||||
tween.tween_callback(hide)
|
tween.tween_callback(hide)
|
||||||
|
|
||||||
|
|
||||||
@@ -40,17 +40,17 @@ func open() -> void:
|
|||||||
center_cont.anchor_bottom = 0.5
|
center_cont.anchor_bottom = 0.5
|
||||||
var tween := create_tween()
|
var tween := create_tween()
|
||||||
tween.tween_property(
|
tween.tween_property(
|
||||||
self,
|
self,
|
||||||
^"modulate:a",
|
^"modulate:a",
|
||||||
1.0,
|
1.0,
|
||||||
fade_in_duration
|
fade_in_duration
|
||||||
).set_trans(Tween.TRANS_LINEAR).set_ease(Tween.EASE_IN)
|
).set_trans(Tween.TRANS_LINEAR).set_ease(Tween.EASE_IN)
|
||||||
tween.parallel().tween_property(
|
tween.parallel().tween_property(
|
||||||
center_cont,
|
center_cont,
|
||||||
^"anchor_bottom",
|
^"anchor_bottom",
|
||||||
1.0,
|
1.0,
|
||||||
fade_out_duration
|
fade_out_duration
|
||||||
).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)
|
).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)
|
||||||
|
|
||||||
|
|
||||||
func _on_coin_collected() -> void:
|
func _on_coin_collected() -> void:
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const LIMIT_BOTTOM = 690
|
|||||||
func _ready():
|
func _ready():
|
||||||
for child in get_children():
|
for child in get_children():
|
||||||
if child is Player:
|
if child is Player:
|
||||||
var camera = child.get_node("Camera")
|
var camera = child.get_node(^"Camera")
|
||||||
camera.limit_left = LIMIT_LEFT
|
camera.limit_left = LIMIT_LEFT
|
||||||
camera.limit_top = LIMIT_TOP
|
camera.limit_top = LIMIT_TOP
|
||||||
camera.limit_right = LIMIT_RIGHT
|
camera.limit_right = LIMIT_RIGHT
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const TERMINAL_VELOCITY = 700
|
|||||||
## Used to separate controls for multiple players in splitscreen.
|
## Used to separate controls for multiple players in splitscreen.
|
||||||
@export var action_suffix := ""
|
@export var action_suffix := ""
|
||||||
|
|
||||||
var gravity: int = ProjectSettings.get("physics/2d/default_gravity")
|
var gravity: int = ProjectSettings.get(&"physics/2d/default_gravity")
|
||||||
@onready var platform_detector := $PlatformDetector as RayCast2D
|
@onready var platform_detector := $PlatformDetector as RayCast2D
|
||||||
@onready var animation_player := $AnimationPlayer as AnimationPlayer
|
@onready var animation_player := $AnimationPlayer as AnimationPlayer
|
||||||
@onready var shoot_timer := $ShootAnimation as Timer
|
@onready var shoot_timer := $ShootAnimation as Timer
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ func initialize(combat_combatants: Array[PackedScene]) -> void:
|
|||||||
var combatant := combatant_scene.instantiate()
|
var combatant := combatant_scene.instantiate()
|
||||||
if combatant is Combatant:
|
if combatant is Combatant:
|
||||||
$Combatants.add_combatant(combatant)
|
$Combatants.add_combatant(combatant)
|
||||||
combatant.get_node("Health").dead.connect(_on_combatant_death.bind(combatant))
|
combatant.get_node(^"Health").dead.connect(_on_combatant_death.bind(combatant))
|
||||||
else:
|
else:
|
||||||
combatant.queue_free()
|
combatant.queue_free()
|
||||||
ui.initialize()
|
ui.initialize()
|
||||||
@@ -30,7 +30,7 @@ func clear_combat() -> void:
|
|||||||
for n in $Combatants.get_children():
|
for n in $Combatants.get_children():
|
||||||
# Player characters.
|
# Player characters.
|
||||||
n.queue_free()
|
n.queue_free()
|
||||||
for n in ui.get_node("Combatants").get_children():
|
for n in ui.get_node(^"Combatants").get_children():
|
||||||
# Health bars.
|
# Health bars.
|
||||||
n.queue_free()
|
n.queue_free()
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ signal turn_finished
|
|||||||
|
|
||||||
var active := false: set = set_active
|
var active := false: set = set_active
|
||||||
|
|
||||||
@onready var animation_playback: AnimationNodeStateMachinePlayback = $Sprite2D/AnimationTree.get("parameters/playback")
|
@onready var animation_playback: AnimationNodeStateMachinePlayback = $Sprite2D/AnimationTree.get(&"parameters/playback")
|
||||||
|
|
||||||
func set_active(value: bool) -> void:
|
func set_active(value: bool) -> void:
|
||||||
active = value
|
active = value
|
||||||
@@ -37,4 +37,4 @@ func flee() -> void:
|
|||||||
|
|
||||||
func take_damage(damage_to_take: float) -> void:
|
func take_damage(damage_to_take: float) -> void:
|
||||||
$Health.take_damage(damage_to_take)
|
$Health.take_damage(damage_to_take)
|
||||||
animation_playback.start("take_damage")
|
animation_playback.start(&"take_damage")
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ signal flee(winner: Combatant, loser: Combatant)
|
|||||||
|
|
||||||
func initialize() -> void:
|
func initialize() -> void:
|
||||||
for combatant in combatants_node.get_children():
|
for combatant in combatants_node.get_children():
|
||||||
var health := combatant.get_node("Health")
|
var health := combatant.get_node(^"Health")
|
||||||
var info := info_scene.instantiate()
|
var info := info_scene.instantiate()
|
||||||
var health_info := info.get_node("VBoxContainer/HealthContainer/Health")
|
var health_info := info.get_node(^"VBoxContainer/HealthContainer/Health")
|
||||||
health_info.value = health.life
|
health_info.value = health.life
|
||||||
health_info.max_value = health.max_life
|
health_info.max_value = health.max_life
|
||||||
info.get_node("VBoxContainer/NameContainer/Name").text = combatant.name
|
info.get_node(^"VBoxContainer/NameContainer/Name").text = combatant.name
|
||||||
health.health_changed.connect(health_info.set_value)
|
health.health_changed.connect(health_info.set_value)
|
||||||
$Combatants.add_child(info)
|
$Combatants.add_child(info)
|
||||||
|
|
||||||
@@ -22,25 +22,25 @@ func initialize() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_Attack_button_up() -> void:
|
func _on_Attack_button_up() -> void:
|
||||||
if not combatants_node.get_node("Player").active:
|
if not combatants_node.get_node(^"Player").active:
|
||||||
return
|
return
|
||||||
|
|
||||||
combatants_node.get_node("Player").attack(combatants_node.get_node("Opponent"))
|
combatants_node.get_node(^"Player").attack(combatants_node.get_node(^"Opponent"))
|
||||||
|
|
||||||
|
|
||||||
func _on_Defend_button_up() -> void:
|
func _on_Defend_button_up() -> void:
|
||||||
if not combatants_node.get_node("Player").active:
|
if not combatants_node.get_node(^"Player").active:
|
||||||
return
|
return
|
||||||
|
|
||||||
combatants_node.get_node("Player").defend()
|
combatants_node.get_node(^"Player").defend()
|
||||||
|
|
||||||
|
|
||||||
func _on_Flee_button_up() -> void:
|
func _on_Flee_button_up() -> void:
|
||||||
if not combatants_node.get_node("Player").active:
|
if not combatants_node.get_node(^"Player").active:
|
||||||
return
|
return
|
||||||
|
|
||||||
combatants_node.get_node("Player").flee()
|
combatants_node.get_node(^"Player").flee()
|
||||||
|
|
||||||
var loser: Combatant = combatants_node.get_node("Player")
|
var loser: Combatant = combatants_node.get_node(^"Player")
|
||||||
var winner: Combatant = combatants_node.get_node("Opponent")
|
var winner: Combatant = combatants_node.get_node(^"Opponent")
|
||||||
flee.emit(winner, loser)
|
flee.emit(winner, loser)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ func show_dialogue(player: Pawn, dialogue: Node) -> void:
|
|||||||
$Button.grab_focus()
|
$Button.grab_focus()
|
||||||
dialogue_node = dialogue
|
dialogue_node = dialogue
|
||||||
|
|
||||||
for c in dialogue.get_signal_connection_list("dialogue_started"):
|
for c in dialogue.get_signal_connection_list(&"dialogue_started"):
|
||||||
if player == c.callable.get_object():
|
if player == c.callable.get_object():
|
||||||
dialogue_node.start_dialogue()
|
dialogue_node.start_dialogue()
|
||||||
$Name.text = "[center]" + dialogue_node.dialogue_name + "[/center]"
|
$Name.text = "[center]" + dialogue_node.dialogue_name + "[/center]"
|
||||||
|
|||||||
@@ -13,21 +13,21 @@ func _ready() -> void:
|
|||||||
for n in $Exploration/Grid.get_children():
|
for n in $Exploration/Grid.get_children():
|
||||||
if not n.type == n.CellType.ACTOR:
|
if not n.type == n.CellType.ACTOR:
|
||||||
continue
|
continue
|
||||||
if not n.has_node("DialoguePlayer"):
|
if not n.has_node(^"DialoguePlayer"):
|
||||||
continue
|
continue
|
||||||
n.get_node("DialoguePlayer").dialogue_finished.connect(_on_opponent_dialogue_finished.bind(n))
|
n.get_node(^"DialoguePlayer").dialogue_finished.connect(_on_opponent_dialogue_finished.bind(n))
|
||||||
|
|
||||||
remove_child(combat_screen)
|
remove_child(combat_screen)
|
||||||
|
|
||||||
|
|
||||||
func start_combat(combat_actors: Array[PackedScene]) -> void:
|
func start_combat(combat_actors: Array[PackedScene]) -> void:
|
||||||
$AnimationPlayer.play("fade_to_black")
|
$AnimationPlayer.play(&"fade_to_black")
|
||||||
await $AnimationPlayer.animation_finished
|
await $AnimationPlayer.animation_finished
|
||||||
remove_child($Exploration)
|
remove_child($Exploration)
|
||||||
add_child(combat_screen)
|
add_child(combat_screen)
|
||||||
combat_screen.show()
|
combat_screen.show()
|
||||||
combat_screen.initialize(combat_actors)
|
combat_screen.initialize(combat_actors)
|
||||||
$AnimationPlayer.play_backwards("fade_to_black")
|
$AnimationPlayer.play_backwards(&"fade_to_black")
|
||||||
|
|
||||||
|
|
||||||
func _on_opponent_dialogue_finished(opponent: Pawn) -> void:
|
func _on_opponent_dialogue_finished(opponent: Pawn) -> void:
|
||||||
@@ -40,7 +40,7 @@ func _on_opponent_dialogue_finished(opponent: Pawn) -> void:
|
|||||||
|
|
||||||
func _on_combat_finished(winner: Combatant, _loser: Combatant) -> void:
|
func _on_combat_finished(winner: Combatant, _loser: Combatant) -> void:
|
||||||
remove_child(combat_screen)
|
remove_child(combat_screen)
|
||||||
$AnimationPlayer.play_backwards("fade_to_black")
|
$AnimationPlayer.play_backwards(&"fade_to_black")
|
||||||
add_child(exploration_screen)
|
add_child(exploration_screen)
|
||||||
var dialogue: Node = load("res://dialogue/dialogue_player/dialogue_player.tscn").instantiate()
|
var dialogue: Node = load("res://dialogue/dialogue_player/dialogue_player.tscn").instantiate()
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ func _on_combat_finished(winner: Combatant, _loser: Combatant) -> void:
|
|||||||
|
|
||||||
await $AnimationPlayer.animation_finished
|
await $AnimationPlayer.animation_finished
|
||||||
var player: Pawn = $Exploration/Grid/Player
|
var player: Pawn = $Exploration/Grid/Player
|
||||||
exploration_screen.get_node("DialogueCanvas/DialogueUI").show_dialogue(player, dialogue)
|
exploration_screen.get_node(^"DialogueCanvas/DialogueUI").show_dialogue(player, dialogue)
|
||||||
combat_screen.clear_combat()
|
combat_screen.clear_combat()
|
||||||
await dialogue.dialogue_finished
|
await dialogue.dialogue_finished
|
||||||
dialogue.queue_free()
|
dialogue.queue_free()
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ func request_move(pawn: Pawn, direction: Vector2i) -> Vector2i:
|
|||||||
var target_pawn := get_cell_pawn(cell_target, cell_tile_id)
|
var target_pawn := get_cell_pawn(cell_target, cell_tile_id)
|
||||||
#print("Cell %s contains %s" % [cell_target, target_pawn.name])
|
#print("Cell %s contains %s" % [cell_target, target_pawn.name])
|
||||||
|
|
||||||
if not target_pawn.has_node("DialoguePlayer"):
|
if not target_pawn.has_node(^"DialoguePlayer"):
|
||||||
return Vector2i.ZERO
|
return Vector2i.ZERO
|
||||||
|
|
||||||
dialogue_ui.show_dialogue(pawn, target_pawn.get_node("DialoguePlayer"))
|
dialogue_ui.show_dialogue(pawn, target_pawn.get_node(^"DialoguePlayer"))
|
||||||
|
|
||||||
return Vector2i.ZERO
|
return Vector2i.ZERO
|
||||||
|
|||||||
@@ -18,4 +18,4 @@ func _process(_delta: float) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func get_input_direction() -> Vector2:
|
func get_input_direction() -> Vector2:
|
||||||
return Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
return Input.get_vector(&"move_left", &"move_right", &"move_up", &"move_down")
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ var lost := false
|
|||||||
var grid_size: float
|
var grid_size: float
|
||||||
|
|
||||||
@onready var grid : Grid = get_parent()
|
@onready var grid : Grid = get_parent()
|
||||||
@onready var animation_playback: AnimationNodeStateMachinePlayback = $AnimationTree.get("parameters/playback")
|
@onready var animation_playback: AnimationNodeStateMachinePlayback = $AnimationTree.get(&"parameters/playback")
|
||||||
@onready var walk_animation_time: float = $AnimationPlayer.get_animation("walk").length
|
@onready var walk_animation_time: float = $AnimationPlayer.get_animation(&"walk").length
|
||||||
@onready var pose := $Pivot/Slime
|
@onready var pose := $Pivot/Slime
|
||||||
|
|
||||||
|
|
||||||
@@ -27,28 +27,28 @@ func update_look_direction(direction: Vector2) -> void:
|
|||||||
func move_to(target_position: Vector2) -> void:
|
func move_to(target_position: Vector2) -> void:
|
||||||
set_process(false)
|
set_process(false)
|
||||||
var move_direction := (target_position - position).normalized()
|
var move_direction := (target_position - position).normalized()
|
||||||
pose.play("idle")
|
pose.play(&"idle")
|
||||||
animation_playback.start("walk")
|
animation_playback.start(&"walk")
|
||||||
|
|
||||||
var tween := create_tween()
|
var tween := create_tween()
|
||||||
tween.set_ease(Tween.EASE_IN)
|
tween.set_ease(Tween.EASE_IN)
|
||||||
var end: Vector2 = $Pivot.position + move_direction * grid_size
|
var end: Vector2 = $Pivot.position + move_direction * grid_size
|
||||||
tween.tween_property($Pivot, "position", end, walk_animation_time)
|
tween.tween_property($Pivot, ^"position", end, walk_animation_time)
|
||||||
|
|
||||||
await tween.finished
|
await tween.finished
|
||||||
$Pivot.position = Vector2.ZERO
|
$Pivot.position = Vector2.ZERO
|
||||||
position = target_position
|
position = target_position
|
||||||
animation_playback.start("idle")
|
animation_playback.start(&"idle")
|
||||||
pose.play("idle")
|
pose.play(&"idle")
|
||||||
|
|
||||||
set_process(true)
|
set_process(true)
|
||||||
|
|
||||||
|
|
||||||
func bump() -> void:
|
func bump() -> void:
|
||||||
set_process(false)
|
set_process(false)
|
||||||
pose.play("bump")
|
pose.play(&"bump")
|
||||||
animation_playback.start("bump")
|
animation_playback.start(&"bump")
|
||||||
await $AnimationTree.animation_finished
|
await $AnimationTree.animation_finished
|
||||||
animation_playback.start("idle")
|
animation_playback.start(&"idle")
|
||||||
pose.play("idle")
|
pose.play(&"idle")
|
||||||
set_process(true)
|
set_process(true)
|
||||||
|
|||||||
@@ -31,15 +31,15 @@ func _ready() -> void:
|
|||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
var is_jumping := false
|
var is_jumping := false
|
||||||
if Input.is_action_just_pressed("jump"):
|
if Input.is_action_just_pressed(&"jump"):
|
||||||
is_jumping = try_jump()
|
is_jumping = try_jump()
|
||||||
elif Input.is_action_just_released("jump") and velocity.y < 0.0:
|
elif Input.is_action_just_released(&"jump") and velocity.y < 0.0:
|
||||||
# The player let go of jump early, reduce vertical momentum.
|
# The player let go of jump early, reduce vertical momentum.
|
||||||
velocity.y *= 0.6
|
velocity.y *= 0.6
|
||||||
# Fall.
|
# Fall.
|
||||||
velocity.y = minf(TERMINAL_VELOCITY, velocity.y + gravity * delta)
|
velocity.y = minf(TERMINAL_VELOCITY, velocity.y + gravity * delta)
|
||||||
|
|
||||||
var direction := Input.get_axis("move_left", "move_right") * WALK_SPEED
|
var direction := Input.get_axis(&"move_left", &"move_right") * WALK_SPEED
|
||||||
velocity.x = move_toward(velocity.x, direction, ACCELERATION_SPEED * delta)
|
velocity.x = move_toward(velocity.x, direction, ACCELERATION_SPEED * delta)
|
||||||
|
|
||||||
if no_move_horizontal_time > 0.0:
|
if no_move_horizontal_time > 0.0:
|
||||||
|
|||||||
@@ -68,13 +68,13 @@ func start_animation() -> void:
|
|||||||
# Here we are calling a lambda method that creates a sub-Tween.
|
# Here we are calling a lambda method that creates a sub-Tween.
|
||||||
# Any number of Tweens can animate a single object in the same time.
|
# Any number of Tweens can animate a single object in the same time.
|
||||||
tween.parallel().tween_callback(func():
|
tween.parallel().tween_callback(func():
|
||||||
# Note that transition is set on Tween, but ease is set on Tweener.
|
# Note that transition is set on Tween, but ease is set on Tweener.
|
||||||
# Values set on Tween will affect all Tweeners (as defaults) and values
|
# Values set on Tween will affect all Tweeners (as defaults) and values
|
||||||
# on Tweeners can override them.
|
# on Tweeners can override them.
|
||||||
sub_tween = create_tween().set_speed_scale(%SpeedSlider.value).set_trans(Tween.TRANS_SINE)
|
sub_tween = create_tween().set_speed_scale(%SpeedSlider.value).set_trans(Tween.TRANS_SINE)
|
||||||
sub_tween.tween_property(icon, ^"position:y", -150.0, 0.5).as_relative().set_ease(Tween.EASE_OUT)
|
sub_tween.tween_property(icon, ^"position:y", -150.0, 0.5).as_relative().set_ease(Tween.EASE_OUT)
|
||||||
sub_tween.tween_property(icon, ^"position:y", 150.0, 0.5).as_relative().set_ease(Tween.EASE_IN)
|
sub_tween.tween_property(icon, ^"position:y", 150.0, 0.5).as_relative().set_ease(Tween.EASE_IN)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Step 5
|
# Step 5
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ func start_animation() -> void:
|
|||||||
var tweener := tween.tween_method(
|
var tweener := tween.tween_method(
|
||||||
func(v: float) -> void:
|
func(v: float) -> void:
|
||||||
icon.position = path.position + path.curve.sample_baked(v), 0.0, path.curve.get_baked_length(), 3.0
|
icon.position = path.position + path.curve.sample_baked(v), 0.0, path.curve.get_baked_length(), 3.0
|
||||||
).set_delay(0.5)
|
).set_delay(0.5)
|
||||||
tweener.set_ease(%Ease7.selected)
|
tweener.set_ease(%Ease7.selected)
|
||||||
tweener.set_trans(%Trans7.selected)
|
tweener.set_trans(%Trans7.selected)
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ func _process(delta: float) -> void:
|
|||||||
fps_label.text = "%d FPS (%.2f mspf)" % [Engine.get_frames_per_second(), 1000.0 / Engine.get_frames_per_second()]
|
fps_label.text = "%d FPS (%.2f mspf)" % [Engine.get_frames_per_second(), 1000.0 / Engine.get_frames_per_second()]
|
||||||
# Color FPS counter depending on framerate.
|
# Color FPS counter depending on framerate.
|
||||||
# The Gradient resource is stored as metadata within the FPSLabel node (accessible in the inspector).
|
# The Gradient resource is stored as metadata within the FPSLabel node (accessible in the inspector).
|
||||||
fps_label.modulate = fps_label.get_meta("gradient").sample(remap(Engine.get_frames_per_second(), 0, 180, 0.0, 1.0))
|
fps_label.modulate = fps_label.get_meta(&"gradient").sample(remap(Engine.get_frames_per_second(), 0, 180, 0.0, 1.0))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -144,9 +144,9 @@ func _on_fsr_sharpness_item_selected(index: int) -> void:
|
|||||||
|
|
||||||
func _on_viewport_size_changed() -> void:
|
func _on_viewport_size_changed() -> void:
|
||||||
$ViewportResolution.text = "Viewport resolution: %d×%d" % [
|
$ViewportResolution.text = "Viewport resolution: %d×%d" % [
|
||||||
get_viewport().size.x * get_viewport().scaling_3d_scale,
|
get_viewport().size.x * get_viewport().scaling_3d_scale,
|
||||||
get_viewport().size.y * get_viewport().scaling_3d_scale,
|
get_viewport().size.y * get_viewport().scaling_3d_scale,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
func _on_v_sync_item_selected(index: int) -> void:
|
func _on_v_sync_item_selected(index: int) -> void:
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
if not result.is_empty():
|
if not result.is_empty():
|
||||||
var decal := preload("res://decal.tscn").instantiate()
|
var decal := preload("res://decal.tscn").instantiate()
|
||||||
add_child(decal)
|
add_child(decal)
|
||||||
decal.get_node("Decal").modulate = Color(1.0,0.0,0)
|
decal.get_node(^"Decal").modulate = Color(1.0,0.0,0)
|
||||||
decal.position = result["position"]
|
decal.position = result["position"]
|
||||||
decal.transform.basis = camera.global_transform.basis
|
decal.transform.basis = camera.global_transform.basis
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Global Illumination
|
# Global Illumination
|
||||||
|
|
||||||
This demo showcases Godot's global illumination systems:
|
This demo showcases Godot's global illumination systems:
|
||||||
LightmapGI, VoxelGI, SDFGI, ReflectionProbe and screen-space effects like SSAO and SSIL.
|
LightmapGI, VoxelGI, SDFGI, ReflectionProbe, and screen-space effects like SSAO and SSIL.
|
||||||
|
|
||||||
Use the mouse to look around, <kbd>W</kbd>/<kbd>A</kbd>/<kbd>S</kbd>/<kbd>D</kbd>
|
Use the mouse to look around, <kbd>W</kbd>/<kbd>A</kbd>/<kbd>S</kbd>/<kbd>D</kbd>
|
||||||
or arrow keys to move.
|
or arrow keys to move.
|
||||||
@@ -17,7 +17,7 @@ Check out this demo on the asset library: https://godotengine.org/asset-library/
|
|||||||
A sphere and box are parented to the camera to showcase dynamic object lighting.
|
A sphere and box are parented to the camera to showcase dynamic object lighting.
|
||||||
A ReflectionProbe is parented to the sphere to showcase real-time reflections.
|
A ReflectionProbe is parented to the sphere to showcase real-time reflections.
|
||||||
When the ReflectionProbe is hidden, it is disabled. In this case,
|
When the ReflectionProbe is hidden, it is disabled. In this case,
|
||||||
VoxelGI, SDFGI or environment lighting will be used to provide fallback reflections.
|
VoxelGI, SDFGI, or environment lighting will be used to provide fallback reflections.
|
||||||
|
|
||||||
A Decal node is parented to the moving sphere and cube to provide simple shadows for them.
|
A Decal node is parented to the moving sphere and cube to provide simple shadows for them.
|
||||||
This is especially effective when using the LightmapGI (All) global illumination mode,
|
This is especially effective when using the LightmapGI (All) global illumination mode,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ func _input(event: InputEvent) -> void:
|
|||||||
rot.x = clamp(rot.x - event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
rot.x = clamp(rot.x - event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
||||||
transform.basis = Basis.from_euler(rot)
|
transform.basis = Basis.from_euler(rot)
|
||||||
|
|
||||||
if event.is_action_pressed("toggle_mouse_capture"):
|
if event.is_action_pressed(&"toggle_mouse_capture"):
|
||||||
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||||
else:
|
else:
|
||||||
@@ -31,7 +31,7 @@ func _process(delta: float) -> void:
|
|||||||
Input.get_axis(&"move_left", &"move_right"),
|
Input.get_axis(&"move_left", &"move_right"),
|
||||||
0,
|
0,
|
||||||
Input.get_axis(&"move_forward", &"move_back")
|
Input.get_axis(&"move_forward", &"move_back")
|
||||||
)
|
)
|
||||||
|
|
||||||
# Normalize motion to prevent diagonal movement from being
|
# Normalize motion to prevent diagonal movement from being
|
||||||
# `sqrt(2)` times faster than straight movement.
|
# `sqrt(2)` times faster than straight movement.
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ func _ready() -> void:
|
|||||||
# Remove unsupported VoxelGI/SDFGI references from the label.
|
# Remove unsupported VoxelGI/SDFGI references from the label.
|
||||||
reflection_probe_mode_texts[0] = "Disabled - Using environment reflections (Fast)"
|
reflection_probe_mode_texts[0] = "Disabled - Using environment reflections (Fast)"
|
||||||
set_gi_mode(GIMode.NONE)
|
set_gi_mode(GIMode.NONE)
|
||||||
# Darken lights's energy to compensate for sRGB blending (without affecting sky rendering).
|
# Darken lights' energy to compensate for sRGB blending (without affecting sky rendering).
|
||||||
# This only applies to lights with shadows enabled.
|
# This only applies to lights with shadows enabled.
|
||||||
$GrateOmniLight.light_energy = 0.25
|
$GrateOmniLight.light_energy = 0.25
|
||||||
$GarageOmniLight.light_energy = 0.5
|
$GarageOmniLight.light_energy = 0.5
|
||||||
@@ -94,7 +94,7 @@ Escape or F10: Toggle mouse capture"""
|
|||||||
|
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed("cycle_gi_mode"):
|
if event.is_action_pressed(&"cycle_gi_mode"):
|
||||||
if is_compatibility:
|
if is_compatibility:
|
||||||
# Only LightmapGI is supported in Compatibility.
|
# Only LightmapGI is supported in Compatibility.
|
||||||
# Note that the actual GI mode is the opposite of what's being set here, due to a bug
|
# Note that the actual GI mode is the opposite of what's being set here, due to a bug
|
||||||
@@ -103,10 +103,10 @@ func _input(event: InputEvent) -> void:
|
|||||||
else:
|
else:
|
||||||
set_gi_mode(wrapi(gi_mode + 1, 0, GIMode.MAX))
|
set_gi_mode(wrapi(gi_mode + 1, 0, GIMode.MAX))
|
||||||
|
|
||||||
if event.is_action_pressed("cycle_reflection_probe_mode"):
|
if event.is_action_pressed(&"cycle_reflection_probe_mode"):
|
||||||
set_reflection_probe_mode(wrapi(reflection_probe_mode + 1, 0, ReflectionProbeMode.MAX))
|
set_reflection_probe_mode(wrapi(reflection_probe_mode + 1, 0, ReflectionProbeMode.MAX))
|
||||||
|
|
||||||
if event.is_action_pressed("cycle_ssil_mode"):
|
if event.is_action_pressed(&"cycle_ssil_mode"):
|
||||||
set_ssil_mode(wrapi(ssil_mode + 1, 0, SSILMode.MAX))
|
set_ssil_mode(wrapi(ssil_mode + 1, 0, SSILMode.MAX))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ func _ready() -> void:
|
|||||||
mark_as_unsupported(%SSReflectionsOptionButton)
|
mark_as_unsupported(%SSReflectionsOptionButton)
|
||||||
mark_as_unsupported(%SSILOptionButton)
|
mark_as_unsupported(%SSILOptionButton)
|
||||||
mark_as_unsupported(%VolumetricFogOptionButton)
|
mark_as_unsupported(%VolumetricFogOptionButton)
|
||||||
# Darken lights's energy to compensate for sRGB blending (without affecting sky rendering).
|
# Darken lights' energy to compensate for sRGB blending (without affecting sky rendering).
|
||||||
$Node3D/OmniLight3D.light_energy = 0.5
|
$Node3D/OmniLight3D.light_energy = 0.5
|
||||||
$Node3D/SpotLight3D.light_energy = 0.5
|
$Node3D/SpotLight3D.light_energy = 0.5
|
||||||
$Node3D/DirectionalLight3D.sky_mode = DirectionalLight3D.SKY_MODE_SKY_ONLY
|
$Node3D/DirectionalLight3D.sky_mode = DirectionalLight3D.SKY_MODE_SKY_ONLY
|
||||||
@@ -59,7 +59,7 @@ func _process(delta: float) -> void:
|
|||||||
fps_label.text = "%d FPS (%.2f mspf)" % [Engine.get_frames_per_second(), 1000.0 / Engine.get_frames_per_second()]
|
fps_label.text = "%d FPS (%.2f mspf)" % [Engine.get_frames_per_second(), 1000.0 / Engine.get_frames_per_second()]
|
||||||
# Color FPS counter depending on framerate.
|
# Color FPS counter depending on framerate.
|
||||||
# The Gradient resource is stored as metadata within the FPSLabel node (accessible in the inspector).
|
# The Gradient resource is stored as metadata within the FPSLabel node (accessible in the inspector).
|
||||||
fps_label.modulate = fps_label.get_meta("gradient").sample(remap(Engine.get_frames_per_second(), 0, 180, 0.0, 1.0))
|
fps_label.modulate = fps_label.get_meta(&"gradient").sample(remap(Engine.get_frames_per_second(), 0, 180, 0.0, 1.0))
|
||||||
|
|
||||||
|
|
||||||
func update_resolution_label() -> void:
|
func update_resolution_label() -> void:
|
||||||
@@ -174,7 +174,7 @@ func _on_fxaa_option_button_item_selected(index: int) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_fullscreen_option_button_item_selected(index: int) -> void:
|
func _on_fullscreen_option_button_item_selected(index: int) -> void:
|
||||||
# To change between window, fullscreen and other window modes,
|
# To change between window, fullscreen, and other window modes,
|
||||||
# set the root mode to one of the options of Window.MODE_*.
|
# set the root mode to one of the options of Window.MODE_*.
|
||||||
# Other modes are maximized and minimized.
|
# Other modes are maximized and minimized.
|
||||||
if index == 0: # Disabled (default)
|
if index == 0: # Disabled (default)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const CHAIN_MAX_ITER = 10
|
|||||||
var temp = get_node(skeleton_path)
|
var temp = get_node(skeleton_path)
|
||||||
if temp != null:
|
if temp != null:
|
||||||
# If it has the method "get_bone_global_pose" it is likely a Skeleton3D
|
# If it has the method "get_bone_global_pose" it is likely a Skeleton3D
|
||||||
if temp.has_method("get_bone_global_pose"):
|
if temp.has_method(&"get_bone_global_pose"):
|
||||||
skeleton = temp
|
skeleton = temp
|
||||||
bone_IDs = {}
|
bone_IDs = {}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ func _ready():
|
|||||||
if target == null:
|
if target == null:
|
||||||
# NOTE: You MUST have a node called Target as a child of this node!
|
# NOTE: You MUST have a node called Target as a child of this node!
|
||||||
# So we create one if one doesn't already exist.
|
# So we create one if one doesn't already exist.
|
||||||
if not has_node("Target"):
|
if not has_node(^"Target"):
|
||||||
target = Node3D.new()
|
target = Node3D.new()
|
||||||
add_child(target)
|
add_child(target)
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ func _ready():
|
|||||||
_make_editor_sphere_at_node(target, Color.MAGENTA)
|
_make_editor_sphere_at_node(target, Color.MAGENTA)
|
||||||
|
|
||||||
if middle_joint_target == null:
|
if middle_joint_target == null:
|
||||||
if not has_node("MiddleJoint"):
|
if not has_node(^"MiddleJoint"):
|
||||||
middle_joint_target = Node3D.new()
|
middle_joint_target = Node3D.new()
|
||||||
add_child(middle_joint_target)
|
add_child(middle_joint_target)
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ func solve_chain():
|
|||||||
else:
|
else:
|
||||||
dir = -target.global_transform.basis.z.normalized()
|
dir = -target.global_transform.basis.z.normalized()
|
||||||
|
|
||||||
# Get the target position (accounting for the final bone and it's length)
|
# Get the target position (accounting for the final bone and its length)
|
||||||
var target_pos = target.global_transform.origin + (dir * bones_in_chain_lengths[bone_nodes.size()-1])
|
var target_pos = target.global_transform.origin + (dir * bones_in_chain_lengths[bone_nodes.size()-1])
|
||||||
|
|
||||||
# If we are using middle joint target (and have more than 2 bones), move our middle joint towards it!
|
# If we are using middle joint target (and have more than 2 bones), move our middle joint towards it!
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ extends Node3D
|
|||||||
# Assign skeleton_path to whatever value is passed.
|
# Assign skeleton_path to whatever value is passed.
|
||||||
skeleton_path = value
|
skeleton_path = value
|
||||||
# Because get_node doesn't work in the first call, we just want to assign instead.
|
# Because get_node doesn't work in the first call, we just want to assign instead.
|
||||||
# This is to get around a issue with NodePaths exposed to the editor.
|
# This is to get around an issue with NodePaths exposed to the editor.
|
||||||
if first_call:
|
if first_call:
|
||||||
return
|
return
|
||||||
_setup_skeleton_path()
|
_setup_skeleton_path()
|
||||||
@@ -158,9 +158,9 @@ func update_skeleton():
|
|||||||
var additional_bone_id = skeleton_to_use.find_bone(additional_bone_name)
|
var additional_bone_id = skeleton_to_use.find_bone(additional_bone_name)
|
||||||
var additional_bone_pos = skeleton_to_use.get_bone_global_pose(additional_bone_id)
|
var additional_bone_pos = skeleton_to_use.get_bone_global_pose(additional_bone_id)
|
||||||
rest.origin = (
|
rest.origin = (
|
||||||
additional_bone_pos.origin
|
additional_bone_pos.origin
|
||||||
- additional_bone_pos.basis.z.normalized() * additional_bone_length
|
- additional_bone_pos.basis.z.normalized() * additional_bone_length
|
||||||
)
|
)
|
||||||
|
|
||||||
# Finally, apply the new rotation to the bone in the skeleton.
|
# Finally, apply the new rotation to the bone in the skeleton.
|
||||||
skeleton_to_use.set_bone_global_pose_override(bone, rest, interpolation, true)
|
skeleton_to_use.set_bone_global_pose_override(bone, rest, interpolation, true)
|
||||||
|
|||||||
@@ -96,10 +96,10 @@ func process_input(delta):
|
|||||||
|
|
||||||
if anim_done:
|
if anim_done:
|
||||||
if current_anim != "Aiming":
|
if current_anim != "Aiming":
|
||||||
anim_player.play("Aiming")
|
anim_player.play(&"Aiming")
|
||||||
current_anim = "Aiming"
|
current_anim = "Aiming"
|
||||||
else:
|
else:
|
||||||
anim_player.play("Idle")
|
anim_player.play(&"Idle")
|
||||||
current_anim = "Idle"
|
current_anim = "Idle"
|
||||||
|
|
||||||
anim_done = false
|
anim_done = false
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ extends Camera3D
|
|||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
var mouse_to_world = (
|
var mouse_to_world = (
|
||||||
project_local_ray_normal(get_viewport().get_mouse_position()) * MOVEMENT_SPEED
|
project_local_ray_normal(get_viewport().get_mouse_position()) * MOVEMENT_SPEED
|
||||||
)
|
)
|
||||||
|
|
||||||
if flip_axis:
|
if flip_axis:
|
||||||
mouse_to_world = -mouse_to_world
|
mouse_to_world = -mouse_to_world
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ func set_health(p_health: int) -> void:
|
|||||||
$HealthBarBackground.outline_modulate = Color(0.15, 0.2, 0.15)
|
$HealthBarBackground.outline_modulate = Color(0.15, 0.2, 0.15)
|
||||||
$HealthBarBackground.modulate = Color(0.15, 0.2, 0.15)
|
$HealthBarBackground.modulate = Color(0.15, 0.2, 0.15)
|
||||||
|
|
||||||
# Construct an health bar with `|` symbols brought very close to each other using
|
# Construct a health bar with `|` symbols brought very close to each other using
|
||||||
# a custom FontVariation on the HealthBarForeground and HealthBarBackground nodes.
|
# a custom FontVariation on the HealthBarForeground and HealthBarBackground nodes.
|
||||||
var bar_text := ""
|
var bar_text := ""
|
||||||
var bar_text_bg := ""
|
var bar_text_bg := ""
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ func _on_enable_sun_toggled(button_pressed: bool) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_animate_lights_toggled(button_pressed: bool) -> void:
|
func _on_animate_lights_toggled(button_pressed: bool) -> void:
|
||||||
for animatable_node in get_tree().get_nodes_in_group("animatable"):
|
for animatable_node in get_tree().get_nodes_in_group(&"animatable"):
|
||||||
animatable_node.set_process(button_pressed)
|
animatable_node.set_process(button_pressed)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,5 +40,5 @@ func set_target_position(target_position: Vector3) -> void:
|
|||||||
start_position,
|
start_position,
|
||||||
target_position,
|
target_position,
|
||||||
optimize
|
optimize
|
||||||
)
|
)
|
||||||
_nav_path_line.draw_path(path)
|
_nav_path_line.draw_path(path)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
get_world_3d().navigation_map,
|
get_world_3d().navigation_map,
|
||||||
camera_ray_start,
|
camera_ray_start,
|
||||||
camera_ray_end
|
camera_ray_end
|
||||||
)
|
)
|
||||||
_robot.set_target_position(closest_point_on_navmesh)
|
_robot.set_target_position(closest_point_on_navmesh)
|
||||||
|
|
||||||
elif event is InputEventMouseMotion:
|
elif event is InputEventMouseMotion:
|
||||||
|
|||||||
@@ -40,12 +40,12 @@ static func create_region_chunks(chunks_root_node: Node, p_source_geometry: Navi
|
|||||||
|
|
||||||
# Rasterize bounding box into chunk grid to know range of required chunks.
|
# Rasterize bounding box into chunk grid to know range of required chunks.
|
||||||
var start_chunk: Vector3 = floor(
|
var start_chunk: Vector3 = floor(
|
||||||
input_geometry_bounds.position / p_chunk_size
|
input_geometry_bounds.position / p_chunk_size
|
||||||
)
|
)
|
||||||
var end_chunk: Vector3 = floor(
|
var end_chunk: Vector3 = floor(
|
||||||
(input_geometry_bounds.position + input_geometry_bounds.size)
|
(input_geometry_bounds.position + input_geometry_bounds.size)
|
||||||
/ p_chunk_size
|
/ p_chunk_size
|
||||||
)
|
)
|
||||||
|
|
||||||
# NavigationMesh.border_size is limited to the xz-axis.
|
# NavigationMesh.border_size is limited to the xz-axis.
|
||||||
# So we can only bake one chunk for the y-axis and also
|
# So we can only bake one chunk for the y-axis and also
|
||||||
@@ -61,9 +61,9 @@ static func create_region_chunks(chunks_root_node: Node, p_source_geometry: Navi
|
|||||||
var chunk_id: Vector3i = Vector3i(chunk_x, chunk_y, chunk_z)
|
var chunk_id: Vector3i = Vector3i(chunk_x, chunk_y, chunk_z)
|
||||||
|
|
||||||
var chunk_bounding_box: AABB = AABB(
|
var chunk_bounding_box: AABB = AABB(
|
||||||
Vector3(chunk_x, bounds_min_height, chunk_z) * p_chunk_size,
|
Vector3(chunk_x, bounds_min_height, chunk_z) * p_chunk_size,
|
||||||
Vector3(p_chunk_size, bounds_max_height, p_chunk_size),
|
Vector3(p_chunk_size, bounds_max_height, p_chunk_size),
|
||||||
)
|
)
|
||||||
# We grow the chunk bounding box to include geometry
|
# We grow the chunk bounding box to include geometry
|
||||||
# from all the neighbor chunks so edges can align.
|
# from all the neighbor chunks so edges can align.
|
||||||
# The border size is the same value as our grow amount so
|
# The border size is the same value as our grow amount so
|
||||||
@@ -109,10 +109,10 @@ func _process(_delta: float) -> void:
|
|||||||
var camera_ray_start: Vector3 = camera.project_ray_origin(mouse_cursor_position)
|
var camera_ray_start: Vector3 = camera.project_ray_origin(mouse_cursor_position)
|
||||||
var camera_ray_end: Vector3 = camera_ray_start + camera.project_ray_normal(mouse_cursor_position) * camera_ray_length
|
var camera_ray_end: Vector3 = camera_ray_start + camera.project_ray_normal(mouse_cursor_position) * camera_ray_length
|
||||||
var closest_point_on_navmesh: Vector3 = NavigationServer3D.map_get_closest_point_to_segment(
|
var closest_point_on_navmesh: Vector3 = NavigationServer3D.map_get_closest_point_to_segment(
|
||||||
map,
|
map,
|
||||||
camera_ray_start,
|
camera_ray_start,
|
||||||
camera_ray_end
|
camera_ray_end
|
||||||
)
|
)
|
||||||
|
|
||||||
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
|
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
|
||||||
path_start_position = closest_point_on_navmesh
|
path_start_position = closest_point_on_navmesh
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ will vary depending on your CPU and GPU model.
|
|||||||
|
|
||||||
> **Warning**
|
> **Warning**
|
||||||
>
|
>
|
||||||
> If you are using a engine build that is not fully optimized, you may notice
|
> If you are using an engine build that is not fully optimized, you may notice
|
||||||
> that enabling occlusion culling decreases performance. This is because
|
> that enabling occlusion culling decreases performance. This is because
|
||||||
> occlusion culling is a demanding process on the CPU, which needs all the
|
> occlusion culling is a demanding process on the CPU, which needs all the
|
||||||
> build-time optimization it can get.
|
> build-time optimization it can get.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ func _input(event: InputEvent) -> void:
|
|||||||
rot.x = clamp(rot.x - event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
rot.x = clamp(rot.x - event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
||||||
transform.basis = Basis.from_euler(rot)
|
transform.basis = Basis.from_euler(rot)
|
||||||
|
|
||||||
if event.is_action_pressed("toggle_mouse_capture"):
|
if event.is_action_pressed(&"toggle_mouse_capture"):
|
||||||
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||||
else:
|
else:
|
||||||
@@ -31,7 +31,7 @@ func _process(delta: float) -> void:
|
|||||||
Input.get_axis(&"move_left", &"move_right"),
|
Input.get_axis(&"move_left", &"move_right"),
|
||||||
0,
|
0,
|
||||||
Input.get_axis(&"move_forward", &"move_back")
|
Input.get_axis(&"move_forward", &"move_back")
|
||||||
)
|
)
|
||||||
|
|
||||||
# Normalize motion to prevent diagonal movement from being
|
# Normalize motion to prevent diagonal movement from being
|
||||||
# `sqrt(2)` times faster than straight movement.
|
# `sqrt(2)` times faster than straight movement.
|
||||||
|
|||||||
@@ -3,16 +3,16 @@ extends Node3D
|
|||||||
var open := false
|
var open := false
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed("toggle_doors"):
|
if event.is_action_pressed(&"toggle_doors"):
|
||||||
if open:
|
if open:
|
||||||
# Close the door.
|
# Close the door.
|
||||||
# The occluder will be re-enabled when the animation ends
|
# The occluder will be re-enabled when the animation ends
|
||||||
# using `_on_animation_player_animation_finished()`.
|
# using `_on_animation_player_animation_finished()`.
|
||||||
$AnimationPlayer.play_backwards("open")
|
$AnimationPlayer.play_backwards(&"open")
|
||||||
open = false
|
open = false
|
||||||
else:
|
else:
|
||||||
# Open the door.
|
# Open the door.
|
||||||
$AnimationPlayer.play("open")
|
$AnimationPlayer.play(&"open")
|
||||||
open = true
|
open = true
|
||||||
# Disable the occluder as soon as the door starts opening.
|
# Disable the occluder as soon as the door starts opening.
|
||||||
# The occluder is not part of the pivot to prevent it from having its
|
# The occluder is not part of the pivot to prevent it from having its
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
extends Node3D
|
extends Node3D
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed("toggle_occlusion_culling"):
|
if event.is_action_pressed(&"toggle_occlusion_culling"):
|
||||||
get_viewport().use_occlusion_culling = not get_viewport().use_occlusion_culling
|
get_viewport().use_occlusion_culling = not get_viewport().use_occlusion_culling
|
||||||
update_labels()
|
update_labels()
|
||||||
if event.is_action_pressed("toggle_mesh_lod"):
|
if event.is_action_pressed(&"toggle_mesh_lod"):
|
||||||
get_viewport().mesh_lod_threshold = 1.0 if is_zero_approx(get_viewport().mesh_lod_threshold) else 0.0
|
get_viewport().mesh_lod_threshold = 1.0 if is_zero_approx(get_viewport().mesh_lod_threshold) else 0.0
|
||||||
update_labels()
|
update_labels()
|
||||||
if event.is_action_pressed("cycle_draw_mode"):
|
if event.is_action_pressed(&"cycle_draw_mode"):
|
||||||
get_viewport().debug_draw = wrapi(get_viewport().debug_draw + 1, 0, 5) as Viewport.DebugDraw
|
get_viewport().debug_draw = wrapi(get_viewport().debug_draw + 1, 0, 5) as Viewport.DebugDraw
|
||||||
update_labels()
|
update_labels()
|
||||||
if event.is_action_pressed("toggle_vsync"):
|
if event.is_action_pressed(&"toggle_vsync"):
|
||||||
if DisplayServer.window_get_vsync_mode() == DisplayServer.VSYNC_DISABLED:
|
if DisplayServer.window_get_vsync_mode() == DisplayServer.VSYNC_DISABLED:
|
||||||
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED)
|
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# 3D Particles
|
# 3D Particles
|
||||||
|
|
||||||
This project showcases various 3D particle features supported by Godot, for both GPU-based and CPU-based particles.
|
This project showcases various 3D particle features supported by Godot, for both GPU-based and CPU-based particles.
|
||||||
This includes particle collision, attractors, trails and subemitters.
|
This includes particle collision, attractors, trails, and subemitters.
|
||||||
|
|
||||||
Language: GDScript
|
Language: GDScript
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ func get_color_from_temperature(p_temperature: float) -> Color:
|
|||||||
var u := (
|
var u := (
|
||||||
(0.860117757 + 1.54118254e-4 * p_temperature + 1.28641212e-7 * t2) /
|
(0.860117757 + 1.54118254e-4 * p_temperature + 1.28641212e-7 * t2) /
|
||||||
(1.0 + 8.42420235e-4 * p_temperature + 7.08145163e-7 * t2)
|
(1.0 + 8.42420235e-4 * p_temperature + 7.08145163e-7 * t2)
|
||||||
)
|
)
|
||||||
var v := (
|
var v := (
|
||||||
(0.317398726 + 4.22806245e-5 * p_temperature + 4.20481691e-8 * t2) /
|
(0.317398726 + 4.22806245e-5 * p_temperature + 4.20481691e-8 * t2) /
|
||||||
(1.0 - 2.89741816e-5 * p_temperature + 1.61456053e-7 * t2)
|
(1.0 - 2.89741816e-5 * p_temperature + 1.61456053e-7 * t2)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Convert to xyY space.
|
# Convert to xyY space.
|
||||||
var d := 1.0 / (2.0 * u - 8.0 * v + 4.0)
|
var d := 1.0 / (2.0 * u - 8.0 * v + 4.0)
|
||||||
@@ -37,7 +37,7 @@ func get_color_from_temperature(p_temperature: float) -> Color:
|
|||||||
3.2404542 * xyz.x - 1.5371385 * xyz.y - 0.4985314 * xyz.z,
|
3.2404542 * xyz.x - 1.5371385 * xyz.y - 0.4985314 * xyz.z,
|
||||||
-0.9692660 * xyz.x + 1.8760108 * xyz.y + 0.0415560 * xyz.z,
|
-0.9692660 * xyz.x + 1.8760108 * xyz.y + 0.0415560 * xyz.z,
|
||||||
0.0556434 * xyz.x - 0.2040259 * xyz.y + 1.0572252 * xyz.z
|
0.0556434 * xyz.x - 0.2040259 * xyz.y + 1.0572252 * xyz.z
|
||||||
)
|
)
|
||||||
linear /= maxf(1e-5, linear[linear.max_axis_index()])
|
linear /= maxf(1e-5, linear[linear.max_axis_index()])
|
||||||
# Normalize, clamp, and convert to sRGB.
|
# Normalize, clamp, and convert to sRGB.
|
||||||
return Color(linear.x, linear.y, linear.z).clamp().linear_to_srgb()
|
return Color(linear.x, linear.y, linear.z).clamp().linear_to_srgb()
|
||||||
@@ -67,7 +67,7 @@ func _on_lightbulb1_intensity_value_changed(value: float) -> void:
|
|||||||
func _on_lightbulb1_temperature_value_changed(value: float) -> void:
|
func _on_lightbulb1_temperature_value_changed(value: float) -> void:
|
||||||
lightbulb_1.light_temperature = value
|
lightbulb_1.light_temperature = value
|
||||||
$Light/Lightbulb1Temperature/Value.text = "%d K" % value
|
$Light/Lightbulb1Temperature/Value.text = "%d K" % value
|
||||||
$Light/Lightbulb1Temperature/Value.add_theme_color_override("font_color", get_color_from_temperature(value))
|
$Light/Lightbulb1Temperature/Value.add_theme_color_override(&"font_color", get_color_from_temperature(value))
|
||||||
|
|
||||||
|
|
||||||
func _on_lightbulb2_intensity_value_changed(value: float) -> void:
|
func _on_lightbulb2_intensity_value_changed(value: float) -> void:
|
||||||
@@ -78,7 +78,7 @@ func _on_lightbulb2_intensity_value_changed(value: float) -> void:
|
|||||||
func _on_lightbulb2_temperature_value_changed(value: float) -> void:
|
func _on_lightbulb2_temperature_value_changed(value: float) -> void:
|
||||||
lightbulb_2.light_temperature = value
|
lightbulb_2.light_temperature = value
|
||||||
$Light/Lightbulb2Temperature/Value.text = "%d K" % value
|
$Light/Lightbulb2Temperature/Value.text = "%d K" % value
|
||||||
$Light/Lightbulb2Temperature/Value.add_theme_color_override("font_color", get_color_from_temperature(value))
|
$Light/Lightbulb2Temperature/Value.add_theme_color_override(&"font_color", get_color_from_temperature(value))
|
||||||
|
|
||||||
|
|
||||||
func _on_focus_distance_value_changed(value: float) -> void:
|
func _on_focus_distance_value_changed(value: float) -> void:
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ func cycle_camera_type() -> void:
|
|||||||
$Rig/Camera_TPS.make_current()
|
$Rig/Camera_TPS.make_current()
|
||||||
CameraType.CAM_TPS:
|
CameraType.CAM_TPS:
|
||||||
_cam_type = CameraType.CAM_FIXED
|
_cam_type = CameraType.CAM_FIXED
|
||||||
get_node("../Camera_Fixed").make_current()
|
get_node(^"../Camera_Fixed").make_current()
|
||||||
|
|
||||||
# Hide body in FPS view (but keep shadow casting to improve spatial awareness).
|
# Hide body in FPS view (but keep shadow casting to improve spatial awareness).
|
||||||
if _cam_type == CameraType.CAM_FPS:
|
if _cam_type == CameraType.CAM_FPS:
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ func start_test() -> void:
|
|||||||
animation_player.playback_process_mode = AnimationPlayer.ANIMATION_PROCESS_PHYSICS
|
animation_player.playback_process_mode = AnimationPlayer.ANIMATION_PROCESS_PHYSICS
|
||||||
else:
|
else:
|
||||||
animation_player.playback_process_mode = AnimationPlayer.ANIMATION_PROCESS_IDLE
|
animation_player.playback_process_mode = AnimationPlayer.ANIMATION_PROCESS_IDLE
|
||||||
animation_player.play("Move")
|
animation_player.play(&"Move")
|
||||||
|
|
||||||
$LabelBodyType.text = "Body Type: " + _body_type[_current_body_index] + " \nCollision Shape: " + _current_shape
|
$LabelBodyType.text = "Body Type: " + _body_type[_current_body_index] + " \nCollision Shape: " + _current_shape
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ func _remove_objects() -> void:
|
|||||||
Log.print_log("* Removing objects...")
|
Log.print_log("* Removing objects...")
|
||||||
var timer := Time.get_ticks_usec()
|
var timer := Time.get_ticks_usec()
|
||||||
|
|
||||||
# Remove objects in reversed order to avoid the overhead of changing children index in parent.
|
# Remove objects in reversed order to avoid the overhead of changing child index in parent.
|
||||||
var object_count := _objects.size()
|
var object_count := _objects.size()
|
||||||
for object_index in object_count:
|
for object_index in object_count:
|
||||||
root_node.remove_child(_objects[object_count - object_index - 1])
|
root_node.remove_child(_objects[object_count - object_index - 1])
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ func _despawn_objects() -> void:
|
|||||||
for spawn in spawns:
|
for spawn in spawns:
|
||||||
var spawn_parent := get_node(spawn)
|
var spawn_parent := get_node(spawn)
|
||||||
|
|
||||||
# Remove objects in reversed order to avoid the overhead of changing children index in parent.
|
# Remove objects in reversed order to avoid the overhead of changing child index in parent.
|
||||||
var object_count := spawn_parent.get_child_count()
|
var object_count := spawn_parent.get_child_count()
|
||||||
for object_index in object_count:
|
for object_index in object_count:
|
||||||
var node := spawn_parent.get_child(object_count - object_index - 1)
|
var node := spawn_parent.get_child(object_count - object_index - 1)
|
||||||
|
|||||||
@@ -52,19 +52,19 @@ func _physics_process(delta: float) -> void:
|
|||||||
target + Basis(Vector3.UP, deg_to_rad(autoturn_ray_aperture)) * (difference),
|
target + Basis(Vector3.UP, deg_to_rad(autoturn_ray_aperture)) * (difference),
|
||||||
0xffffffff,
|
0xffffffff,
|
||||||
collision_exception
|
collision_exception
|
||||||
))
|
))
|
||||||
var col := ds.intersect_ray(PhysicsRayQueryParameters3D.create(
|
var col := ds.intersect_ray(PhysicsRayQueryParameters3D.create(
|
||||||
target,
|
target,
|
||||||
target + difference,
|
target + difference,
|
||||||
0xffffffff,
|
0xffffffff,
|
||||||
collision_exception
|
collision_exception
|
||||||
))
|
))
|
||||||
var col_right := ds.intersect_ray(PhysicsRayQueryParameters3D.create(
|
var col_right := ds.intersect_ray(PhysicsRayQueryParameters3D.create(
|
||||||
target,
|
target,
|
||||||
target + Basis(Vector3.UP, deg_to_rad(-autoturn_ray_aperture)) * (difference),
|
target + Basis(Vector3.UP, deg_to_rad(-autoturn_ray_aperture)) * (difference),
|
||||||
0xffffffff,
|
0xffffffff,
|
||||||
collision_exception
|
collision_exception
|
||||||
))
|
))
|
||||||
|
|
||||||
if not col.is_empty():
|
if not col.is_empty():
|
||||||
# If main ray was occluded, get camera closer, this is the worst case scenario.
|
# If main ray was occluded, get camera closer, this is the worst case scenario.
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ var coins := 0
|
|||||||
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
if Input.is_action_pressed("reset_position") or global_position.y < -12:
|
if Input.is_action_pressed(&"reset_position") or global_position.y < -12:
|
||||||
# Player hit the reset button or fell off the map.
|
# Player hit the reset button or fell off the map.
|
||||||
position = initial_position
|
position = initial_position
|
||||||
velocity = Vector3.ZERO
|
velocity = Vector3.ZERO
|
||||||
@@ -48,10 +48,10 @@ func _physics_process(delta: float) -> void:
|
|||||||
# Update coin count and its "parallax" copies.
|
# Update coin count and its "parallax" copies.
|
||||||
# This gives text a pseudo-3D appearance while still using Label3D instead of the more limited TextMesh.
|
# This gives text a pseudo-3D appearance while still using Label3D instead of the more limited TextMesh.
|
||||||
%CoinCount.text = str(coins)
|
%CoinCount.text = str(coins)
|
||||||
%CoinCount.get_node("Parallax").text = str(coins)
|
%CoinCount.get_node(^"Parallax").text = str(coins)
|
||||||
%CoinCount.get_node("Parallax2").text = str(coins)
|
%CoinCount.get_node(^"Parallax2").text = str(coins)
|
||||||
%CoinCount.get_node("Parallax3").text = str(coins)
|
%CoinCount.get_node(^"Parallax3").text = str(coins)
|
||||||
%CoinCount.get_node("Parallax4").text = str(coins)
|
%CoinCount.get_node(^"Parallax4").text = str(coins)
|
||||||
|
|
||||||
velocity += gravity * delta
|
velocity += gravity * delta
|
||||||
|
|
||||||
@@ -79,12 +79,12 @@ func _physics_process(delta: float) -> void:
|
|||||||
if movement_direction.length() > 0.1 and not sharp_turn:
|
if movement_direction.length() > 0.1 and not sharp_turn:
|
||||||
if horizontal_speed > 0.001:
|
if horizontal_speed > 0.001:
|
||||||
horizontal_direction = adjust_facing(
|
horizontal_direction = adjust_facing(
|
||||||
horizontal_direction,
|
horizontal_direction,
|
||||||
movement_direction,
|
movement_direction,
|
||||||
delta,
|
delta,
|
||||||
1.0 / horizontal_speed * TURN_SPEED,
|
1.0 / horizontal_speed * TURN_SPEED,
|
||||||
Vector3.UP
|
Vector3.UP
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
horizontal_direction = movement_direction
|
horizontal_direction = movement_direction
|
||||||
|
|
||||||
@@ -103,17 +103,17 @@ func _physics_process(delta: float) -> void:
|
|||||||
|
|
||||||
if horizontal_speed > 0:
|
if horizontal_speed > 0:
|
||||||
facing_mesh = adjust_facing(
|
facing_mesh = adjust_facing(
|
||||||
facing_mesh,
|
facing_mesh,
|
||||||
movement_direction,
|
movement_direction,
|
||||||
delta,
|
delta,
|
||||||
1.0 / horizontal_speed * TURN_SPEED,
|
1.0 / horizontal_speed * TURN_SPEED,
|
||||||
Vector3.UP
|
Vector3.UP
|
||||||
)
|
)
|
||||||
var m3 := Basis(
|
var m3 := Basis(
|
||||||
-facing_mesh,
|
-facing_mesh,
|
||||||
Vector3.UP,
|
Vector3.UP,
|
||||||
-facing_mesh.cross(Vector3.UP).normalized()
|
-facing_mesh.cross(Vector3.UP).normalized()
|
||||||
).scaled(CHAR_SCALE)
|
).scaled(CHAR_SCALE)
|
||||||
|
|
||||||
$Player/Skeleton.set_transform(Transform3D(m3, mesh_xform.origin))
|
$Player/Skeleton.set_transform(Transform3D(m3, mesh_xform.origin))
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ func _physics_process(delta: float) -> void:
|
|||||||
horizontal_speed = 0
|
horizontal_speed = 0
|
||||||
horizontal_velocity = horizontal_direction * horizontal_speed
|
horizontal_velocity = horizontal_direction * horizontal_speed
|
||||||
|
|
||||||
if Input.is_action_just_released("jump") and velocity.y > 0.0:
|
if Input.is_action_just_released(&"jump") and velocity.y > 0.0:
|
||||||
# Reduce jump height if releasing the jump key before reaching the apex.
|
# Reduce jump height if releasing the jump key before reaching the apex.
|
||||||
vertical_velocity *= 0.7
|
vertical_velocity *= 0.7
|
||||||
|
|
||||||
@@ -160,8 +160,8 @@ func _physics_process(delta: float) -> void:
|
|||||||
bullet.set_transform($Player/Skeleton/Bullet.get_global_transform().orthonormalized())
|
bullet.set_transform($Player/Skeleton/Bullet.get_global_transform().orthonormalized())
|
||||||
get_parent().add_child(bullet)
|
get_parent().add_child(bullet)
|
||||||
bullet.set_linear_velocity(
|
bullet.set_linear_velocity(
|
||||||
$Player/Skeleton/Bullet.get_global_transform().basis[2].normalized() * BULLET_SPEED
|
$Player/Skeleton/Bullet.get_global_transform().basis[2].normalized() * BULLET_SPEED
|
||||||
)
|
)
|
||||||
bullet.add_collision_exception_with(self)
|
bullet.add_collision_exception_with(self)
|
||||||
$SoundShoot.play()
|
$SoundShoot.play()
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ resource dropdown.
|
|||||||
> **Warning**
|
> **Warning**
|
||||||
>
|
>
|
||||||
> Sky shaders are rendered every frame if they use the `TIME` variable or are
|
> Sky shaders are rendered every frame if they use the `TIME` variable or are
|
||||||
> otherwise updated every frame (e.g. if an uniform is updated in `_process()`
|
> otherwise updated every frame (e.g. if a uniform is updated in `_process()`
|
||||||
> or with an AnimationPlayer). This has a significant performance impact for
|
> or with an AnimationPlayer). This has a significant performance impact for
|
||||||
> complex sky shaders. The performance impact can be reduced by adjusting the
|
> complex sky shaders. The performance impact can be reduced by adjusting the
|
||||||
> radiance map properties in Environment, but it will remain significant.
|
> radiance map properties in Environment, but it will remain significant.
|
||||||
|
|||||||
@@ -13,21 +13,21 @@ func _ready() -> void:
|
|||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
# Make the slider follow the day/night cycle.
|
# Make the slider follow the day/night cycle.
|
||||||
$Panel/MarginContainer/VBoxContainer/TimeOfDay/HSlider.value = $AnimationPlayer.current_animation_position
|
$Panel/MarginContainer/VBoxContainer/TimeOfDay/HSlider.value = $AnimationPlayer.current_animation_position
|
||||||
$WorldEnvironment.environment.sky.sky_material.set_shader_parameter("cloud_time_offset", $AnimationPlayer.current_animation_position)
|
$WorldEnvironment.environment.sky.sky_material.set_shader_parameter(&"cloud_time_offset", $AnimationPlayer.current_animation_position)
|
||||||
|
|
||||||
$YawCamera/Camera3D.fov = lerpf($YawCamera/Camera3D.fov, desired_fov, 1.0 - exp(-delta * 10.0))
|
$YawCamera/Camera3D.fov = lerpf($YawCamera/Camera3D.fov, desired_fov, 1.0 - exp(-delta * 10.0))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed("toggle_gui"):
|
if event.is_action_pressed(&"toggle_gui"):
|
||||||
$Panel.visible = not $Panel.visible
|
$Panel.visible = not $Panel.visible
|
||||||
$Help.visible = not $Help.visible
|
$Help.visible = not $Help.visible
|
||||||
|
|
||||||
if event.is_action_pressed("toggle_spheres"):
|
if event.is_action_pressed(&"toggle_spheres"):
|
||||||
$Spheres.visible = not $Spheres.visible
|
$Spheres.visible = not $Spheres.visible
|
||||||
|
|
||||||
if event.is_action_pressed("toggle_mouse_capture"):
|
if event.is_action_pressed(&"toggle_mouse_capture"):
|
||||||
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||||
else:
|
else:
|
||||||
@@ -40,9 +40,9 @@ func _input(event: InputEvent) -> void:
|
|||||||
$YawCamera.rotation.y -= relative_motion.x * MOUSE_SENSITIVITY
|
$YawCamera.rotation.y -= relative_motion.x * MOUSE_SENSITIVITY
|
||||||
|
|
||||||
# Mouse wheel currently doesn't work in input actions. Hardcode mouse wheel as a workaround.
|
# Mouse wheel currently doesn't work in input actions. Hardcode mouse wheel as a workaround.
|
||||||
if event.is_action_pressed("increase_camera_fov") or Input.is_mouse_button_pressed(MOUSE_BUTTON_WHEEL_DOWN):
|
if event.is_action_pressed(&"increase_camera_fov") or Input.is_mouse_button_pressed(MOUSE_BUTTON_WHEEL_DOWN):
|
||||||
desired_fov = clampf(desired_fov + 5.0, 20.0, 120.0)
|
desired_fov = clampf(desired_fov + 5.0, 20.0, 120.0)
|
||||||
if event.is_action_pressed("decrease_camera_fov") or Input.is_mouse_button_pressed(MOUSE_BUTTON_WHEEL_UP):
|
if event.is_action_pressed(&"decrease_camera_fov") or Input.is_mouse_button_pressed(MOUSE_BUTTON_WHEEL_UP):
|
||||||
desired_fov = clampf(desired_fov - 5.0, 20.0, 120.0)
|
desired_fov = clampf(desired_fov - 5.0, 20.0, 120.0)
|
||||||
|
|
||||||
|
|
||||||
@@ -81,12 +81,12 @@ func update_speed_label() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_cloud_coverage_value_changed(value: float) -> void:
|
func _on_cloud_coverage_value_changed(value: float) -> void:
|
||||||
$WorldEnvironment.environment.sky.sky_material.set_shader_parameter("cloud_coverage", value)
|
$WorldEnvironment.environment.sky.sky_material.set_shader_parameter(&"cloud_coverage", value)
|
||||||
$Panel/MarginContainer/VBoxContainer/Clouds/CoverageValue.text = "%d%%" % (value * 100)
|
$Panel/MarginContainer/VBoxContainer/Clouds/CoverageValue.text = "%d%%" % (value * 100)
|
||||||
|
|
||||||
|
|
||||||
func _on_cloud_density_value_changed(value: float) -> void:
|
func _on_cloud_density_value_changed(value: float) -> void:
|
||||||
$WorldEnvironment.environment.sky.sky_material.set_shader_parameter("cloud_density", value)
|
$WorldEnvironment.environment.sky.sky_material.set_shader_parameter(&"cloud_density", value)
|
||||||
$Panel/MarginContainer/VBoxContainer/Clouds/DensityValue.text = "%d%%" % (value * 100)
|
$Panel/MarginContainer/VBoxContainer/Clouds/DensityValue.text = "%d%%" % (value * 100)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ var velocity: Vector3 = Vector3.ZERO
|
|||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
var input_vector: Vector2 = Vector2.ZERO
|
var input_vector: Vector2 = Vector2.ZERO
|
||||||
|
|
||||||
input_vector.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
|
input_vector.x = Input.get_action_strength(&"move_right") - Input.get_action_strength(&"move_left")
|
||||||
input_vector.y = Input.get_action_strength("move_back") - Input.get_action_strength("move_forward")
|
input_vector.y = Input.get_action_strength(&"move_back") - Input.get_action_strength(&"move_forward")
|
||||||
|
|
||||||
if input_vector.length() > 0:
|
if input_vector.length() > 0:
|
||||||
input_vector = input_vector.normalized()
|
input_vector = input_vector.normalized()
|
||||||
@@ -20,8 +20,8 @@ func _process(delta: float) -> void:
|
|||||||
|
|
||||||
# Play corresponding animation.
|
# Play corresponding animation.
|
||||||
if abs(input_vector.x) > abs(input_vector.y):
|
if abs(input_vector.x) > abs(input_vector.y):
|
||||||
sprite.play("walk_right" if input_vector.x > 0 else "walk_left")
|
sprite.play(&"walk_right" if input_vector.x > 0 else &"walk_left")
|
||||||
else:
|
else:
|
||||||
sprite.play("walk_down" if input_vector.y > 0 else "walk_up")
|
sprite.play(&"walk_down" if input_vector.y > 0 else &"walk_up")
|
||||||
else:
|
else:
|
||||||
sprite.stop()
|
sprite.stop()
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ func _ready():
|
|||||||
|
|
||||||
|
|
||||||
func _unhandled_input(event):
|
func _unhandled_input(event):
|
||||||
if event.is_action_pressed("ui_accept") and $UserInterface/Retry.visible:
|
if event.is_action_pressed(&"ui_accept") and $UserInterface/Retry.visible:
|
||||||
get_tree().reload_current_scene()
|
get_tree().reload_current_scene()
|
||||||
|
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ func _on_mob_timer_timeout():
|
|||||||
var mob = mob_scene.instantiate()
|
var mob = mob_scene.instantiate()
|
||||||
|
|
||||||
# Choose a random location on the SpawnPath.
|
# Choose a random location on the SpawnPath.
|
||||||
var mob_spawn_location = get_node("SpawnPath/SpawnLocation")
|
var mob_spawn_location = get_node(^"SpawnPath/SpawnLocation")
|
||||||
mob_spawn_location.progress_ratio = randf()
|
mob_spawn_location.progress_ratio = randf()
|
||||||
|
|
||||||
# Communicate the spawn location and the player's location to the mob.
|
# Communicate the spawn location and the player's location to the mob.
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ signal hit
|
|||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
var direction = Vector3.ZERO
|
var direction = Vector3.ZERO
|
||||||
if Input.is_action_pressed("move_right"):
|
if Input.is_action_pressed(&"move_right"):
|
||||||
direction.x += 1
|
direction.x += 1
|
||||||
if Input.is_action_pressed("move_left"):
|
if Input.is_action_pressed(&"move_left"):
|
||||||
direction.x -= 1
|
direction.x -= 1
|
||||||
if Input.is_action_pressed("move_back"):
|
if Input.is_action_pressed(&"move_back"):
|
||||||
direction.z += 1
|
direction.z += 1
|
||||||
if Input.is_action_pressed("move_forward"):
|
if Input.is_action_pressed(&"move_forward"):
|
||||||
direction.z -= 1
|
direction.z -= 1
|
||||||
|
|
||||||
if direction != Vector3.ZERO:
|
if direction != Vector3.ZERO:
|
||||||
@@ -36,7 +36,7 @@ func _physics_process(delta):
|
|||||||
velocity.z = direction.z * speed
|
velocity.z = direction.z * speed
|
||||||
|
|
||||||
# Jumping.
|
# Jumping.
|
||||||
if is_on_floor() and Input.is_action_just_pressed("jump"):
|
if is_on_floor() and Input.is_action_just_pressed(&"jump"):
|
||||||
velocity.y += jump_impulse
|
velocity.y += jump_impulse
|
||||||
|
|
||||||
# We apply gravity every frame so the character always collides with the ground when moving.
|
# We apply gravity every frame so the character always collides with the ground when moving.
|
||||||
@@ -52,7 +52,7 @@ func _physics_process(delta):
|
|||||||
# If there are no "slides" this frame, the loop below won't run.
|
# If there are no "slides" this frame, the loop below won't run.
|
||||||
for index in range(get_slide_collision_count()):
|
for index in range(get_slide_collision_count()):
|
||||||
var collision = get_slide_collision(index)
|
var collision = get_slide_collision(index)
|
||||||
if collision.get_collider().is_in_group("mob"):
|
if collision.get_collider().is_in_group(&"mob"):
|
||||||
var mob = collision.get_collider()
|
var mob = collision.get_collider()
|
||||||
if Vector3.UP.dot(collision.get_normal()) > 0.1:
|
if Vector3.UP.dot(collision.get_normal()) > 0.1:
|
||||||
mob.squash()
|
mob.squash()
|
||||||
|
|||||||
@@ -7,15 +7,15 @@ class_name GradientBars extends Node3D
|
|||||||
func set_num_steps(steps: int) -> void:
|
func set_num_steps(steps: int) -> void:
|
||||||
var shader_mat: ShaderMaterial = hdr_bar.material_override as ShaderMaterial
|
var shader_mat: ShaderMaterial = hdr_bar.material_override as ShaderMaterial
|
||||||
if shader_mat:
|
if shader_mat:
|
||||||
shader_mat.set_shader_parameter("steps", min(1, steps))
|
shader_mat.set_shader_parameter(&"steps", min(1, steps))
|
||||||
|
|
||||||
func set_color(color: Color) -> void:
|
func set_color(color: Color) -> void:
|
||||||
var shader_mat: ShaderMaterial = sdr_bar.material_override as ShaderMaterial
|
var shader_mat: ShaderMaterial = sdr_bar.material_override as ShaderMaterial
|
||||||
if shader_mat:
|
if shader_mat:
|
||||||
shader_mat.set_shader_parameter("my_color", color)
|
shader_mat.set_shader_parameter(&"my_color", color)
|
||||||
|
|
||||||
shader_mat = hdr_bar.material_override as ShaderMaterial
|
shader_mat = hdr_bar.material_override as ShaderMaterial
|
||||||
if shader_mat:
|
if shader_mat:
|
||||||
shader_mat.set_shader_parameter("my_color", color)
|
shader_mat.set_shader_parameter(&"my_color", color)
|
||||||
|
|
||||||
label.text = "#" + color.to_html(false)
|
label.text = "#" + color.to_html(false)
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ func _on_steps_value_changed(value):
|
|||||||
for bar_path in bars:
|
for bar_path in bars:
|
||||||
var bar = get_node(bar_path)
|
var bar = get_node(bar_path)
|
||||||
var shader_mat = bar.hdr_bar.material_override as ShaderMaterial
|
var shader_mat = bar.hdr_bar.material_override as ShaderMaterial
|
||||||
shader_mat.set_shader_parameter("steps", value)
|
shader_mat.set_shader_parameter(&"steps", value)
|
||||||
if hues:
|
if hues:
|
||||||
var shader_mat = hues.material_override as ShaderMaterial
|
var shader_mat = hues.material_override as ShaderMaterial
|
||||||
shader_mat.set_shader_parameter("steps", value)
|
shader_mat.set_shader_parameter(&"steps", value)
|
||||||
|
|
||||||
|
|
||||||
func _on_color_picker_button_color_changed(color):
|
func _on_color_picker_button_color_changed(color):
|
||||||
@@ -37,10 +37,10 @@ func _on_exponential_toggled(button_pressed):
|
|||||||
for bar_path in bars:
|
for bar_path in bars:
|
||||||
var bar = get_node(bar_path)
|
var bar = get_node(bar_path)
|
||||||
var shader_mat = bar.hdr_bar.material_override as ShaderMaterial
|
var shader_mat = bar.hdr_bar.material_override as ShaderMaterial
|
||||||
shader_mat.set_shader_parameter("exponential_view", button_pressed)
|
shader_mat.set_shader_parameter(&"exponential_view", button_pressed)
|
||||||
|
|
||||||
shader_mat = bar.sdr_bar.material_override as ShaderMaterial
|
shader_mat = bar.sdr_bar.material_override as ShaderMaterial
|
||||||
shader_mat.set_shader_parameter("exponential_view", button_pressed)
|
shader_mat.set_shader_parameter(&"exponential_view", button_pressed)
|
||||||
if hues:
|
if hues:
|
||||||
var shader_mat = hues.material_override as ShaderMaterial
|
var shader_mat = hues.material_override as ShaderMaterial
|
||||||
shader_mat.set_shader_parameter("exponential_view", button_pressed)
|
shader_mat.set_shader_parameter(&"exponential_view", button_pressed)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ func create_neutral_lut(name: String, size: int, vertical: bool):
|
|||||||
(size * size) if vertical else size,
|
(size * size) if vertical else size,
|
||||||
false,
|
false,
|
||||||
Image.FORMAT_RGB8
|
Image.FORMAT_RGB8
|
||||||
)
|
)
|
||||||
|
|
||||||
for z in size:
|
for z in size:
|
||||||
var x_offset := int(z * size) if not vertical else 0
|
var x_offset := int(z * size) if not vertical else 0
|
||||||
@@ -26,7 +26,7 @@ func create_neutral_lut(name: String, size: int, vertical: bool):
|
|||||||
roundi(((x + 0.2) / float(size - 1)) * 255),
|
roundi(((x + 0.2) / float(size - 1)) * 255),
|
||||||
roundi(((y + 0.2) / float(size - 1)) * 255),
|
roundi(((y + 0.2) / float(size - 1)) * 255),
|
||||||
roundi(((z + 0.2) / float(size - 1)) * 255)
|
roundi(((z + 0.2) / float(size - 1)) * 255)
|
||||||
))
|
))
|
||||||
|
|
||||||
image.save_png("user://" + name + ".png")
|
image.save_png("user://" + name + ".png")
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func _process(_delta: float) -> void:
|
|||||||
text = "Speed: " + ("%.0f" % speed) + " mph"
|
text = "Speed: " + ("%.0f" % speed) + " mph"
|
||||||
|
|
||||||
# Change speedometer color depending on speed in m/s (regardless of unit).
|
# Change speedometer color depending on speed in m/s (regardless of unit).
|
||||||
add_theme_color_override("font_color", gradient.sample(remap(car_body.linear_velocity.length(), 0.0, 30.0, 0.0, 1.0)))
|
add_theme_color_override(&"font_color", gradient.sample(remap(car_body.linear_velocity.length(), 0.0, 30.0, 0.0, 1.0)))
|
||||||
|
|
||||||
|
|
||||||
func _on_spedometer_pressed() -> void:
|
func _on_spedometer_pressed() -> void:
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ func _input(input_event: InputEvent) -> void:
|
|||||||
rot.x = clampf(rot.x - input_event.relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
rot.x = clampf(rot.x - input_event.relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
||||||
transform.basis = Basis.from_euler(rot)
|
transform.basis = Basis.from_euler(rot)
|
||||||
|
|
||||||
if input_event.is_action_pressed("toggle_mouse_capture"):
|
if input_event.is_action_pressed(&"toggle_mouse_capture"):
|
||||||
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||||
else:
|
else:
|
||||||
@@ -32,7 +32,7 @@ func _process(delta: float) -> void:
|
|||||||
Input.get_axis(&"move_left", &"move_right"),
|
Input.get_axis(&"move_left", &"move_right"),
|
||||||
0,
|
0,
|
||||||
Input.get_axis(&"move_forward", &"move_back")
|
Input.get_axis(&"move_forward", &"move_back")
|
||||||
)
|
)
|
||||||
|
|
||||||
# Normalize motion to prevent diagonal movement from being
|
# Normalize motion to prevent diagonal movement from being
|
||||||
# `sqrt(2)` times faster than straight movement.
|
# `sqrt(2)` times faster than straight movement.
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ func _ready() -> void:
|
|||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
var motion := Vector3(
|
var motion := Vector3(
|
||||||
Input.get_action_strength("move_right") - Input.get_action_strength("move_left"),
|
Input.get_action_strength(&"move_right") - Input.get_action_strength(&"move_left"),
|
||||||
0,
|
0,
|
||||||
Input.get_action_strength("move_back") - Input.get_action_strength("move_forward")
|
Input.get_action_strength(&"move_back") - Input.get_action_strength(&"move_forward")
|
||||||
)
|
)
|
||||||
|
|
||||||
# Normalize motion to prevent diagonal movement from being
|
# Normalize motion to prevent diagonal movement from being
|
||||||
# `sqrt(2)` times faster than straight movement.
|
# `sqrt(2)` times faster than straight movement.
|
||||||
@@ -41,33 +41,33 @@ func _input(event: InputEvent) -> void:
|
|||||||
rot.x = clamp(rot.x - event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
rot.x = clamp(rot.x - event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
||||||
transform.basis = Basis.from_euler(rot)
|
transform.basis = Basis.from_euler(rot)
|
||||||
|
|
||||||
if event.is_action_pressed("toggle_mouse_capture"):
|
if event.is_action_pressed(&"toggle_mouse_capture"):
|
||||||
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||||
else:
|
else:
|
||||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
|
|
||||||
if event.is_action_pressed("toggle_temporal_reprojection"):
|
if event.is_action_pressed(&"toggle_temporal_reprojection"):
|
||||||
get_world_3d().environment.volumetric_fog_temporal_reprojection_enabled = not get_world_3d().environment.volumetric_fog_temporal_reprojection_enabled
|
get_world_3d().environment.volumetric_fog_temporal_reprojection_enabled = not get_world_3d().environment.volumetric_fog_temporal_reprojection_enabled
|
||||||
update_label()
|
update_label()
|
||||||
elif event.is_action_pressed("increase_temporal_reprojection"):
|
elif event.is_action_pressed(&"increase_temporal_reprojection"):
|
||||||
get_world_3d().environment.volumetric_fog_temporal_reprojection_amount = clamp(get_world_3d().environment.volumetric_fog_temporal_reprojection_amount + 0.01, 0.5, 0.99)
|
get_world_3d().environment.volumetric_fog_temporal_reprojection_amount = clamp(get_world_3d().environment.volumetric_fog_temporal_reprojection_amount + 0.01, 0.5, 0.99)
|
||||||
update_label()
|
update_label()
|
||||||
elif event.is_action_pressed("decrease_temporal_reprojection"):
|
elif event.is_action_pressed(&"decrease_temporal_reprojection"):
|
||||||
get_world_3d().environment.volumetric_fog_temporal_reprojection_amount = clamp(get_world_3d().environment.volumetric_fog_temporal_reprojection_amount - 0.01, 0.5, 0.99)
|
get_world_3d().environment.volumetric_fog_temporal_reprojection_amount = clamp(get_world_3d().environment.volumetric_fog_temporal_reprojection_amount - 0.01, 0.5, 0.99)
|
||||||
update_label()
|
update_label()
|
||||||
elif event.is_action_pressed("increase_fog_density"):
|
elif event.is_action_pressed(&"increase_fog_density"):
|
||||||
get_world_3d().environment.volumetric_fog_density = clamp(get_world_3d().environment.volumetric_fog_density + 0.01, 0.0, 1.0)
|
get_world_3d().environment.volumetric_fog_density = clamp(get_world_3d().environment.volumetric_fog_density + 0.01, 0.0, 1.0)
|
||||||
update_label()
|
update_label()
|
||||||
elif event.is_action_pressed("decrease_fog_density"):
|
elif event.is_action_pressed(&"decrease_fog_density"):
|
||||||
get_world_3d().environment.volumetric_fog_density = clamp(get_world_3d().environment.volumetric_fog_density - 0.01, 0.0, 1.0)
|
get_world_3d().environment.volumetric_fog_density = clamp(get_world_3d().environment.volumetric_fog_density - 0.01, 0.0, 1.0)
|
||||||
update_label()
|
update_label()
|
||||||
elif event.is_action_pressed("increase_volumetric_fog_quality"):
|
elif event.is_action_pressed(&"increase_volumetric_fog_quality"):
|
||||||
volumetric_fog_volume_size = clamp(volumetric_fog_volume_size + 16, 16, 384)
|
volumetric_fog_volume_size = clamp(volumetric_fog_volume_size + 16, 16, 384)
|
||||||
volumetric_fog_volume_depth = clamp(volumetric_fog_volume_depth + 16, 16, 384)
|
volumetric_fog_volume_depth = clamp(volumetric_fog_volume_depth + 16, 16, 384)
|
||||||
RenderingServer.environment_set_volumetric_fog_volume_size(volumetric_fog_volume_size, volumetric_fog_volume_depth)
|
RenderingServer.environment_set_volumetric_fog_volume_size(volumetric_fog_volume_size, volumetric_fog_volume_depth)
|
||||||
update_label()
|
update_label()
|
||||||
elif event.is_action_pressed("decrease_volumetric_fog_quality"):
|
elif event.is_action_pressed(&"decrease_volumetric_fog_quality"):
|
||||||
volumetric_fog_volume_size = clamp(volumetric_fog_volume_size - 16, 16, 384)
|
volumetric_fog_volume_size = clamp(volumetric_fog_volume_size - 16, 16, 384)
|
||||||
volumetric_fog_volume_depth = clamp(volumetric_fog_volume_depth - 16, 16, 384)
|
volumetric_fog_volume_depth = clamp(volumetric_fog_volume_depth - 16, 16, 384)
|
||||||
RenderingServer.environment_set_volumetric_fog_volume_size(volumetric_fog_volume_size, volumetric_fog_volume_depth)
|
RenderingServer.environment_set_volumetric_fog_volume_size(volumetric_fog_volume_size, volumetric_fog_volume_depth)
|
||||||
@@ -77,16 +77,16 @@ func _input(event: InputEvent) -> void:
|
|||||||
func update_label() -> void:
|
func update_label() -> void:
|
||||||
if get_world_3d().environment.volumetric_fog_temporal_reprojection_enabled:
|
if get_world_3d().environment.volumetric_fog_temporal_reprojection_enabled:
|
||||||
label.text = "Fog density: %.2f\nTemporal reprojection: Enabled\nTemporal reprojection strength: %.2f\nVolumetric fog quality: %d×%d×%d" % [
|
label.text = "Fog density: %.2f\nTemporal reprojection: Enabled\nTemporal reprojection strength: %.2f\nVolumetric fog quality: %d×%d×%d" % [
|
||||||
get_world_3d().environment.volumetric_fog_density,
|
get_world_3d().environment.volumetric_fog_density,
|
||||||
get_world_3d().environment.volumetric_fog_temporal_reprojection_amount,
|
get_world_3d().environment.volumetric_fog_temporal_reprojection_amount,
|
||||||
volumetric_fog_volume_size,
|
volumetric_fog_volume_size,
|
||||||
volumetric_fog_volume_size,
|
volumetric_fog_volume_size,
|
||||||
volumetric_fog_volume_depth,
|
volumetric_fog_volume_depth,
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
label.text = "Fog density: %.2f\nTemporal reprojection: Disabled\nVolumetric fog quality: %d×%d×%d" % [
|
label.text = "Fog density: %.2f\nTemporal reprojection: Disabled\nVolumetric fog quality: %d×%d×%d" % [
|
||||||
get_world_3d().environment.volumetric_fog_density,
|
get_world_3d().environment.volumetric_fog_density,
|
||||||
volumetric_fog_volume_size,
|
volumetric_fog_volume_size,
|
||||||
volumetric_fog_volume_size,
|
volumetric_fog_volume_size,
|
||||||
volumetric_fog_volume_depth,
|
volumetric_fog_volume_depth,
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ func _process(_delta: float) -> void:
|
|||||||
aim_preview.global_position = Vector3(ray_current_block_position) + Vector3(0.5, 0.5, 0.5)
|
aim_preview.global_position = Vector3(ray_current_block_position) + Vector3(0.5, 0.5, 0.5)
|
||||||
var breaking := Input.is_action_just_pressed(&"break")
|
var breaking := Input.is_action_just_pressed(&"break")
|
||||||
var placing := Input.is_action_just_pressed(&"place")
|
var placing := Input.is_action_just_pressed(&"place")
|
||||||
# Either both buttons were pressed or neither are, so stop.
|
# Either both buttons were pressed or neither is, so stop.
|
||||||
if breaking == placing:
|
if breaking == placing:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ func _physics_process(delta: float) -> void:
|
|||||||
head.transform.origin.y = lerpf(head.transform.origin.y, EYE_HEIGHT_CROUCH if crouching else EYE_HEIGHT_STAND, 1.0 - exp(-delta * 16.0))
|
head.transform.origin.y = lerpf(head.transform.origin.y, EYE_HEIGHT_CROUCH if crouching else EYE_HEIGHT_STAND, 1.0 - exp(-delta * 16.0))
|
||||||
|
|
||||||
# Keyboard movement.
|
# Keyboard movement.
|
||||||
var movement_vec2: Vector2 = Input.get_vector("move_left", "move_right", "move_forward", "move_back")
|
var movement_vec2: Vector2 = Input.get_vector(&"move_left", &"move_right", &"move_forward", &"move_back")
|
||||||
var movement: Vector3 = transform.basis * (Vector3(movement_vec2.x, 0, movement_vec2.y))
|
var movement: Vector3 = transform.basis * (Vector3(movement_vec2.x, 0, movement_vec2.y))
|
||||||
|
|
||||||
if is_on_floor():
|
if is_on_floor():
|
||||||
|
|||||||
@@ -226,26 +226,26 @@ static func calculate_block_uvs(block_id: int) -> Array[Vector2]:
|
|||||||
var col := block_id % TEXTURE_SHEET_WIDTH
|
var col := block_id % TEXTURE_SHEET_WIDTH
|
||||||
|
|
||||||
return [
|
return [
|
||||||
# Godot 4 has a weird bug where there are seams at the edge
|
# Godot 4 has a weird bug where there are seams at the edge
|
||||||
# of the textures. Adding a margin of 0.01 "fixes" it.
|
# of the textures. Adding a margin of 0.01 "fixes" it.
|
||||||
TEXTURE_TILE_SIZE * Vector2(col + 0.01, row + 0.01),
|
TEXTURE_TILE_SIZE * Vector2(col + 0.01, row + 0.01),
|
||||||
TEXTURE_TILE_SIZE * Vector2(col + 0.01, row + 0.99),
|
TEXTURE_TILE_SIZE * Vector2(col + 0.01, row + 0.99),
|
||||||
TEXTURE_TILE_SIZE * Vector2(col + 0.99, row + 0.01),
|
TEXTURE_TILE_SIZE * Vector2(col + 0.99, row + 0.01),
|
||||||
TEXTURE_TILE_SIZE * Vector2(col + 0.99, row + 0.99),
|
TEXTURE_TILE_SIZE * Vector2(col + 0.99, row + 0.99),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
static func calculate_block_verts(block_position: Vector3) -> Array[Vector3]:
|
static func calculate_block_verts(block_position: Vector3) -> Array[Vector3]:
|
||||||
return [
|
return [
|
||||||
Vector3(block_position.x, block_position.y, block_position.z),
|
Vector3(block_position.x, block_position.y, block_position.z),
|
||||||
Vector3(block_position.x, block_position.y, block_position.z + 1),
|
Vector3(block_position.x, block_position.y, block_position.z + 1),
|
||||||
Vector3(block_position.x, block_position.y + 1, block_position.z),
|
Vector3(block_position.x, block_position.y + 1, block_position.z),
|
||||||
Vector3(block_position.x, block_position.y + 1, block_position.z + 1),
|
Vector3(block_position.x, block_position.y + 1, block_position.z + 1),
|
||||||
Vector3(block_position.x + 1, block_position.y, block_position.z),
|
Vector3(block_position.x + 1, block_position.y, block_position.z),
|
||||||
Vector3(block_position.x + 1, block_position.y, block_position.z + 1),
|
Vector3(block_position.x + 1, block_position.y, block_position.z + 1),
|
||||||
Vector3(block_position.x + 1, block_position.y + 1, block_position.z),
|
Vector3(block_position.x + 1, block_position.y + 1, block_position.z),
|
||||||
Vector3(block_position.x + 1, block_position.y + 1, block_position.z + 1),
|
Vector3(block_position.x + 1, block_position.y + 1, block_position.z + 1),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
static func is_block_transparent(block_id: int) -> int:
|
static func is_block_transparent(block_id: int) -> int:
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func _process(delta: float) -> void:
|
|||||||
Input.get_axis(&"move_left", &"move_right"),
|
Input.get_axis(&"move_left", &"move_right"),
|
||||||
0,
|
0,
|
||||||
Input.get_axis(&"move_forward", &"move_back")
|
Input.get_axis(&"move_forward", &"move_back")
|
||||||
)
|
)
|
||||||
|
|
||||||
# Normalize motion to prevent diagonal movement from being
|
# Normalize motion to prevent diagonal movement from being
|
||||||
# `sqrt(2)` times faster than straight movement.
|
# `sqrt(2)` times faster than straight movement.
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ func _process(_delta: float) -> void:
|
|||||||
var viewport_base_size: Vector2i = (
|
var viewport_base_size: Vector2i = (
|
||||||
get_viewport().content_scale_size if get_viewport().content_scale_size > Vector2i(0, 0)
|
get_viewport().content_scale_size if get_viewport().content_scale_size > Vector2i(0, 0)
|
||||||
else get_viewport().size
|
else get_viewport().size
|
||||||
)
|
)
|
||||||
|
|
||||||
if not sticky:
|
if not sticky:
|
||||||
# For non-sticky waypoints, we don't need to clamp and calculate
|
# For non-sticky waypoints, we don't need to clamp and calculate
|
||||||
@@ -80,7 +80,7 @@ func _process(_delta: float) -> void:
|
|||||||
position = Vector2(
|
position = Vector2(
|
||||||
clamp(unprojected_position.x, MARGIN, viewport_base_size.x - MARGIN),
|
clamp(unprojected_position.x, MARGIN, viewport_base_size.x - MARGIN),
|
||||||
clamp(unprojected_position.y, MARGIN, viewport_base_size.y - MARGIN)
|
clamp(unprojected_position.y, MARGIN, viewport_base_size.y - MARGIN)
|
||||||
)
|
)
|
||||||
|
|
||||||
label.visible = true
|
label.visible = true
|
||||||
rotation = 0
|
rotation = 0
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ var format := AudioStreamWAV.FORMAT_16_BITS # This is the default format on rec
|
|||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
var idx := AudioServer.get_bus_index("Record")
|
var idx := AudioServer.get_bus_index(&"Record")
|
||||||
effect = AudioServer.get_bus_effect(idx, 0)
|
effect = AudioServer.get_bus_effect(idx, 0)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -69,17 +69,17 @@ func _process(_delta: float) -> void:
|
|||||||
# First, calculate the song time using data from the audio thread. This
|
# First, calculate the song time using data from the audio thread. This
|
||||||
# value is very jittery, but will always match what the player is hearing.
|
# value is very jittery, but will always match what the player is hearing.
|
||||||
_song_time_audio = (
|
_song_time_audio = (
|
||||||
player.get_playback_position()
|
player.get_playback_position()
|
||||||
# The 1st beat may not start at second 0 of the audio track. Compensate
|
# The 1st beat may not start at second 0 of the audio track. Compensate
|
||||||
# with an offset setting.
|
# with an offset setting.
|
||||||
- first_beat_offset_ms / 1000.0
|
- first_beat_offset_ms / 1000.0
|
||||||
# For most platforms, the playback position value updates in chunks,
|
# For most platforms, the playback position value updates in chunks,
|
||||||
# with each chunk being one "mix". Smooth this out by adding in the time
|
# with each chunk being one "mix". Smooth this out by adding in the time
|
||||||
# since the last chunk was processed.
|
# since the last chunk was processed.
|
||||||
+ last_mix
|
+ last_mix
|
||||||
# Current processed audio is heard later.
|
# Current processed audio is heard later.
|
||||||
- _cached_output_latency
|
- _cached_output_latency
|
||||||
)
|
)
|
||||||
|
|
||||||
# Next, calculate the song time using the system clock at render rate. This
|
# Next, calculate the song time using the system clock at render rate. This
|
||||||
# value is very stable, but can drift from the playing audio due to pausing,
|
# value is very stable, but can drift from the playing audio due to pausing,
|
||||||
@@ -126,17 +126,17 @@ func play() -> void:
|
|||||||
|
|
||||||
# Capture the start of the song using the system clock.
|
# Capture the start of the song using the system clock.
|
||||||
_song_time_begin = (
|
_song_time_begin = (
|
||||||
Time.get_ticks_usec() / 1000000.0
|
Time.get_ticks_usec() / 1000000.0
|
||||||
# The 1st beat may not start at second 0 of the audio track. Compensate
|
# The 1st beat may not start at second 0 of the audio track. Compensate
|
||||||
# with an offset setting.
|
# with an offset setting.
|
||||||
+ first_beat_offset_ms / 1000.0
|
+ first_beat_offset_ms / 1000.0
|
||||||
# Playback does not start immediately, but only when the next audio
|
# Playback does not start immediately, but only when the next audio
|
||||||
# chunk is processed (the "mix" step). Add in the time until that
|
# chunk is processed (the "mix" step). Add in the time until that
|
||||||
# happens.
|
# happens.
|
||||||
+ AudioServer.get_time_to_next_mix()
|
+ AudioServer.get_time_to_next_mix()
|
||||||
# Add in additional output latency.
|
# Add in additional output latency.
|
||||||
+ _cached_output_latency
|
+ _cached_output_latency
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func stop() -> void:
|
func stop() -> void:
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ var _hit_count: int = 0
|
|||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
_play_stats = PlayStats.new()
|
_play_stats = PlayStats.new()
|
||||||
_play_stats.changed.connect(
|
_play_stats.changed.connect(
|
||||||
func() -> void:
|
func() -> void:
|
||||||
play_stats_updated.emit(_play_stats)
|
play_stats_updated.emit(_play_stats)
|
||||||
)
|
)
|
||||||
|
|
||||||
var chart_data := ChartData.get_chart_data(chart)
|
var chart_data := ChartData.get_chart_data(chart)
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ func _process(_delta: float) -> void:
|
|||||||
|
|
||||||
_miss_old_notes()
|
_miss_old_notes()
|
||||||
|
|
||||||
if Input.is_action_just_pressed("main_key"):
|
if Input.is_action_just_pressed(&"main_key"):
|
||||||
_handle_keypress()
|
_handle_keypress()
|
||||||
|
|
||||||
if _notes.is_empty():
|
if _notes.is_empty():
|
||||||
|
|||||||
@@ -6,16 +6,19 @@ extends Resource
|
|||||||
if mean_hit_error != value:
|
if mean_hit_error != value:
|
||||||
mean_hit_error = value
|
mean_hit_error = value
|
||||||
emit_changed()
|
emit_changed()
|
||||||
|
|
||||||
@export var perfect_count: int = 0:
|
@export var perfect_count: int = 0:
|
||||||
set(value):
|
set(value):
|
||||||
if perfect_count != value:
|
if perfect_count != value:
|
||||||
perfect_count = value
|
perfect_count = value
|
||||||
emit_changed()
|
emit_changed()
|
||||||
|
|
||||||
@export var good_count: int = 0:
|
@export var good_count: int = 0:
|
||||||
set(value):
|
set(value):
|
||||||
if good_count != value:
|
if good_count != value:
|
||||||
good_count = value
|
good_count = value
|
||||||
emit_changed()
|
emit_changed()
|
||||||
|
|
||||||
@export var miss_count: int = 0:
|
@export var miss_count: int = 0:
|
||||||
set(value):
|
set(value):
|
||||||
if miss_count != value:
|
if miss_count != value:
|
||||||
|
|||||||
@@ -18,12 +18,14 @@ func _init(args: Variant) -> void:
|
|||||||
x_filter = LowPassFilter.new()
|
x_filter = LowPassFilter.new()
|
||||||
dx_filter = LowPassFilter.new()
|
dx_filter = LowPassFilter.new()
|
||||||
|
|
||||||
|
|
||||||
func alpha(rate: float, cutoff: float) -> float:
|
func alpha(rate: float, cutoff: float) -> float:
|
||||||
var tau: float = 1.0 / (2 * PI * cutoff)
|
var tau: float = 1.0 / (2 * PI * cutoff)
|
||||||
var te: float = 1.0 / rate
|
var te: float = 1.0 / rate
|
||||||
|
|
||||||
return 1.0 / (1.0 + tau/te)
|
return 1.0 / (1.0 + tau/te)
|
||||||
|
|
||||||
|
|
||||||
func filter(value: float, delta: float) -> float:
|
func filter(value: float, delta: float) -> float:
|
||||||
var rate: float = 1.0 / delta
|
var rate: float = 1.0 / delta
|
||||||
var dx: float = (value - x_filter.last_value) * rate
|
var dx: float = (value - x_filter.last_value) * rate
|
||||||
@@ -32,12 +34,15 @@ func filter(value: float, delta: float) -> float:
|
|||||||
var cutoff: float = min_cutoff + beta * abs(edx)
|
var cutoff: float = min_cutoff + beta * abs(edx)
|
||||||
return x_filter.filter(value, alpha(rate, cutoff))
|
return x_filter.filter(value, alpha(rate, cutoff))
|
||||||
|
|
||||||
|
|
||||||
class LowPassFilter:
|
class LowPassFilter:
|
||||||
var last_value: float
|
var last_value: float
|
||||||
|
|
||||||
|
|
||||||
func _init() -> void:
|
func _init() -> void:
|
||||||
last_value = 0
|
last_value = 0
|
||||||
|
|
||||||
|
|
||||||
func filter(value: float, alpha: float) -> float:
|
func filter(value: float, alpha: float) -> float:
|
||||||
var result := alpha * value + (1 - alpha) * last_value
|
var result := alpha * value + (1 - alpha) * last_value
|
||||||
last_value = result
|
last_value = result
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ var _guide_tween: Tween
|
|||||||
|
|
||||||
|
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
if Input.is_action_just_pressed("main_key"):
|
if Input.is_action_just_pressed(&"main_key"):
|
||||||
scale = 1.2 * Vector2.ONE
|
scale = 1.2 * Vector2.ONE
|
||||||
if _guide_tween:
|
if _guide_tween:
|
||||||
_guide_tween.kill()
|
_guide_tween.kill()
|
||||||
_guide_tween = create_tween().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_CUBIC)
|
_guide_tween = create_tween().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_CUBIC)
|
||||||
_guide_tween.tween_property(self, "scale", Vector2.ONE, 0.2)
|
_guide_tween.tween_property(self, ^"scale", Vector2.ONE, 0.2)
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ func hit_perfect() -> void:
|
|||||||
var tween := create_tween()
|
var tween := create_tween()
|
||||||
tween.set_ease(Tween.EASE_OUT)
|
tween.set_ease(Tween.EASE_OUT)
|
||||||
tween.set_trans(Tween.TRANS_QUAD)
|
tween.set_trans(Tween.TRANS_QUAD)
|
||||||
tween.parallel().tween_property(self, "modulate:a", 0, 0.2)
|
tween.parallel().tween_property(self, ^"modulate:a", 0, 0.2)
|
||||||
tween.parallel().tween_property($Sprite2D, "scale", 1.5 * Vector2.ONE, 0.2)
|
tween.parallel().tween_property($Sprite2D, ^"scale", 1.5 * Vector2.ONE, 0.2)
|
||||||
tween.tween_callback(queue_free)
|
tween.tween_callback(queue_free)
|
||||||
|
|
||||||
|
|
||||||
@@ -55,8 +55,8 @@ func hit_good() -> void:
|
|||||||
var tween := create_tween()
|
var tween := create_tween()
|
||||||
tween.set_ease(Tween.EASE_OUT)
|
tween.set_ease(Tween.EASE_OUT)
|
||||||
tween.set_trans(Tween.TRANS_QUAD)
|
tween.set_trans(Tween.TRANS_QUAD)
|
||||||
tween.parallel().tween_property(self, "modulate:a", 0, 0.2)
|
tween.parallel().tween_property(self, ^"modulate:a", 0, 0.2)
|
||||||
tween.parallel().tween_property($Sprite2D, "scale", 1.2 * Vector2.ONE, 0.2)
|
tween.parallel().tween_property($Sprite2D, ^"scale", 1.2 * Vector2.ONE, 0.2)
|
||||||
tween.tween_callback(queue_free)
|
tween.tween_callback(queue_free)
|
||||||
|
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ func miss(stop_movement: bool = true) -> void:
|
|||||||
modulate = Color.DARK_RED
|
modulate = Color.DARK_RED
|
||||||
|
|
||||||
var tween := create_tween()
|
var tween := create_tween()
|
||||||
tween.parallel().tween_property(self, "modulate:a", 0, 0.5)
|
tween.parallel().tween_property(self, ^"modulate:a", 0, 0.5)
|
||||||
tween.tween_callback(queue_free)
|
tween.tween_callback(queue_free)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func _ready() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
if Input.is_action_just_pressed("restart"):
|
if Input.is_action_just_pressed(&"restart"):
|
||||||
get_tree().reload_current_scene()
|
get_tree().reload_current_scene()
|
||||||
$Control/ErrorGraphVBox/CenterContainer/TimeGraph.queue_redraw()
|
$Control/ErrorGraphVBox/CenterContainer/TimeGraph.queue_redraw()
|
||||||
|
|
||||||
@@ -112,8 +112,8 @@ func _on_note_hit(beat: float, hit_type: Enums.HitType, hit_error: float) -> voi
|
|||||||
_judgment_tween.kill()
|
_judgment_tween.kill()
|
||||||
_judgment_tween = create_tween()
|
_judgment_tween = create_tween()
|
||||||
_judgment_tween.tween_interval(0.2)
|
_judgment_tween.tween_interval(0.2)
|
||||||
_judgment_tween.tween_property($Control/JudgmentHBox/LJudgmentLabel, "modulate:a", 0, 0.5)
|
_judgment_tween.tween_property($Control/JudgmentHBox/LJudgmentLabel, ^"modulate:a", 0, 0.5)
|
||||||
_judgment_tween.parallel().tween_property($Control/JudgmentHBox/RJudgmentLabel, "modulate:a", 0, 0.5)
|
_judgment_tween.parallel().tween_property($Control/JudgmentHBox/RJudgmentLabel, ^"modulate:a", 0, 0.5)
|
||||||
|
|
||||||
_hit_data.append(NoteHitData.new(beat, hit_type, hit_error))
|
_hit_data.append(NoteHitData.new(beat, hit_type, hit_error))
|
||||||
$Control/ErrorGraphVBox/CenterContainer/JudgmentsGraph.queue_redraw()
|
$Control/ErrorGraphVBox/CenterContainer/JudgmentsGraph.queue_redraw()
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ extends Node
|
|||||||
|
|
||||||
|
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
if Input.is_action_just_pressed("pause"):
|
if Input.is_action_just_pressed(&"pause"):
|
||||||
get_tree().paused = not get_tree().paused
|
get_tree().paused = not get_tree().paused
|
||||||
$"../Control/PauseLabel".visible = get_tree().paused
|
$"../Control/PauseLabel".visible = get_tree().paused
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user