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:
|
||||
var position := Vector2()
|
||||
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
|
||||
# faster to use RIDs compared to a high-level approach.
|
||||
var body := RID()
|
||||
@@ -42,9 +42,9 @@ func _ready() -> void:
|
||||
# Place bullets randomly on the viewport and move bullets outside the
|
||||
# play area so that they fade in nicely.
|
||||
bullet.position = Vector2(
|
||||
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.x) + get_viewport_rect().size.x,
|
||||
randf_range(0, get_viewport_rect().size.y)
|
||||
)
|
||||
var transform2d := Transform2D()
|
||||
transform2d.origin = bullet.position
|
||||
PhysicsServer2D.body_set_state(bullet.body, PhysicsServer2D.BODY_STATE_TRANSFORM, transform2d)
|
||||
|
||||
@@ -40,4 +40,4 @@ func _draw() -> void:
|
||||
Color.MEDIUM_AQUAMARINE,
|
||||
line_width_thin,
|
||||
use_antialiasing
|
||||
)
|
||||
)
|
||||
|
||||
@@ -26,11 +26,11 @@ func _draw() -> void:
|
||||
draw_animation_slice(ANIMATION_LENGTH, slice_begin, slice_end)
|
||||
draw_set_transform(margin + offset, deg_to_rad(randf_range(-5.0, 5.0)))
|
||||
draw_rect(
|
||||
Rect2(Vector2(), Vector2(100, 50)),
|
||||
Color.from_hsv(randf(), 0.4, 1.0),
|
||||
true,
|
||||
-1.0,
|
||||
use_antialiasing
|
||||
)
|
||||
Rect2(Vector2(), Vector2(100, 50)),
|
||||
Color.from_hsv(randf(), 0.4, 1.0),
|
||||
true,
|
||||
-1.0,
|
||||
use_antialiasing
|
||||
)
|
||||
|
||||
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_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).
|
||||
# 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)
|
||||
draw_set_transform(margin + offset, 0.0, Vector2(3.0, 1.0))
|
||||
draw_circle(Vector2(), 40, Color.ORANGE, false, line_width_thin, use_antialiasing)
|
||||
@@ -82,7 +82,7 @@ func _draw() -> void:
|
||||
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 an horizontally stretched arc.
|
||||
# Draw a horizontally stretched arc.
|
||||
offset += Vector2(200, 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)
|
||||
|
||||
@@ -40,12 +40,13 @@ func _ready() -> void:
|
||||
multi_mesh.set_instance_color(4, Color(0.7, 1, 1))
|
||||
multi_mesh.mesh = sphere_mesh
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
const margin := Vector2(300, 70)
|
||||
var offset := Vector2()
|
||||
|
||||
# `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).
|
||||
# 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 points := PackedVector2Array([
|
||||
Vector2(0, 0),
|
||||
Vector2(0, 60),
|
||||
Vector2(60, 90),
|
||||
Vector2(60, 0),
|
||||
Vector2(40, 25),
|
||||
Vector2(10, 40),
|
||||
])
|
||||
Vector2(0, 0),
|
||||
Vector2(0, 60),
|
||||
Vector2(60, 90),
|
||||
Vector2(60, 0),
|
||||
Vector2(40, 25),
|
||||
Vector2(10, 40),
|
||||
])
|
||||
var colors := PackedColorArray([
|
||||
Color.WHITE,
|
||||
Color.RED,
|
||||
Color.GREEN,
|
||||
Color.BLUE,
|
||||
Color.MAGENTA,
|
||||
Color.MAGENTA,
|
||||
])
|
||||
Color.WHITE,
|
||||
Color.RED,
|
||||
Color.GREEN,
|
||||
Color.BLUE,
|
||||
Color.MAGENTA,
|
||||
Color.MAGENTA,
|
||||
])
|
||||
|
||||
var offset := Vector2()
|
||||
# `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).
|
||||
# To reset back to the initial transform, call `draw_set_transform(Vector2())`.
|
||||
draw_set_transform(margin + offset)
|
||||
@@ -57,7 +57,7 @@ func _draw() -> void:
|
||||
draw_primitive(points.slice(0, 4), colors.slice(0, 4), PackedVector2Array())
|
||||
|
||||
# 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)
|
||||
draw_set_transform(margin + offset)
|
||||
draw_polygon(points, colors)
|
||||
|
||||
@@ -26,7 +26,7 @@ func _draw() -> void:
|
||||
false,
|
||||
line_width_thin,
|
||||
use_antialiasing
|
||||
)
|
||||
)
|
||||
|
||||
offset += Vector2(120, 0)
|
||||
draw_rect(
|
||||
@@ -35,7 +35,7 @@ func _draw() -> void:
|
||||
false,
|
||||
2.0 - antialiasing_width_offset,
|
||||
use_antialiasing
|
||||
)
|
||||
)
|
||||
|
||||
offset += Vector2(120, 0)
|
||||
draw_rect(
|
||||
@@ -44,7 +44,7 @@ func _draw() -> void:
|
||||
false,
|
||||
6.0 - antialiasing_width_offset,
|
||||
use_antialiasing
|
||||
)
|
||||
)
|
||||
|
||||
# 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.
|
||||
@@ -56,10 +56,10 @@ func _draw() -> void:
|
||||
true,
|
||||
-1.0,
|
||||
use_antialiasing
|
||||
)
|
||||
)
|
||||
|
||||
# `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).
|
||||
# To reset back to the initial transform, call `draw_set_transform(Vector2())`.
|
||||
offset += Vector2(170, 0)
|
||||
@@ -70,7 +70,7 @@ func _draw() -> void:
|
||||
false,
|
||||
line_width_thin,
|
||||
use_antialiasing
|
||||
)
|
||||
)
|
||||
offset += Vector2(120, 0)
|
||||
draw_set_transform(margin + offset, deg_to_rad(22.5))
|
||||
draw_rect(
|
||||
@@ -79,7 +79,7 @@ func _draw() -> void:
|
||||
false,
|
||||
2.0 - antialiasing_width_offset,
|
||||
use_antialiasing
|
||||
)
|
||||
)
|
||||
offset += Vector2(120, 0)
|
||||
draw_set_transform(margin + offset, deg_to_rad(22.5))
|
||||
draw_rect(
|
||||
@@ -88,7 +88,7 @@ func _draw() -> void:
|
||||
false,
|
||||
6.0 - antialiasing_width_offset,
|
||||
use_antialiasing
|
||||
)
|
||||
)
|
||||
|
||||
# `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
|
||||
@@ -99,12 +99,12 @@ func _draw() -> void:
|
||||
custom_transform.y.x -= 0.5
|
||||
draw_set_transform_matrix(custom_transform)
|
||||
draw_rect(
|
||||
Rect2(Vector2(), Vector2(100, 50)),
|
||||
Color.PURPLE,
|
||||
false,
|
||||
6.0 - antialiasing_width_offset,
|
||||
use_antialiasing
|
||||
)
|
||||
Rect2(Vector2(), Vector2(100, 50)),
|
||||
Color.PURPLE,
|
||||
false,
|
||||
6.0 - antialiasing_width_offset,
|
||||
use_antialiasing
|
||||
)
|
||||
draw_set_transform(Vector2())
|
||||
|
||||
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.
|
||||
# This determines the spacing between glyphs so the next character is positioned correctly.
|
||||
var glyph_idx := TextServerManager.get_primary_interface().font_get_glyph_index(
|
||||
get_theme_default_font().get_rids()[0],
|
||||
FONT_SIZE,
|
||||
character.unicode_at(0),
|
||||
0
|
||||
)
|
||||
get_theme_default_font().get_rids()[0],
|
||||
FONT_SIZE,
|
||||
character.unicode_at(0),
|
||||
0
|
||||
)
|
||||
advance.x += TextServerManager.get_primary_interface().font_get_glyph_advance(
|
||||
get_theme_default_font().get_rids()[0],
|
||||
FONT_SIZE,
|
||||
glyph_idx
|
||||
).x
|
||||
).x
|
||||
|
||||
offset += Vector2(0, 32)
|
||||
# When drawing a font outline, it must be drawn *before* the main text.
|
||||
@@ -44,7 +44,7 @@ func _draw() -> void:
|
||||
FONT_SIZE,
|
||||
12,
|
||||
Color.ORANGE.darkened(0.6)
|
||||
)
|
||||
)
|
||||
# NOTE: Use `draw_multiline_string()` to draw strings that contain line breaks (`\n`) or with
|
||||
# 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
|
||||
@@ -57,4 +57,4 @@ func _draw() -> void:
|
||||
-1,
|
||||
FONT_SIZE,
|
||||
Color.YELLOW
|
||||
)
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ func _draw() -> void:
|
||||
draw_texture(ICON, margin + offset, Color.WHITE)
|
||||
|
||||
# `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).
|
||||
# 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)),
|
||||
false,
|
||||
Color.GREEN
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# 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)),
|
||||
true,
|
||||
Color.GREEN
|
||||
)
|
||||
)
|
||||
|
||||
offset = Vector2(0, 300)
|
||||
|
||||
@@ -49,7 +49,7 @@ func _draw() -> void:
|
||||
Rect2(margin + offset, Vector2(128, 128)),
|
||||
Rect2(Vector2(32, 32), Vector2(64, 64)),
|
||||
Color.VIOLET
|
||||
)
|
||||
)
|
||||
|
||||
# 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.
|
||||
@@ -64,4 +64,4 @@ func _draw() -> void:
|
||||
Rect2(Vector2(), Vector2(512, 512)),
|
||||
Color.VIOLET,
|
||||
true
|
||||
)
|
||||
)
|
||||
|
||||
@@ -46,6 +46,7 @@ func _on_MobTimer_timeout():
|
||||
# Spawn the mob by adding it to the Main scene.
|
||||
add_child(mob)
|
||||
|
||||
|
||||
func _on_ScoreTimer_timeout():
|
||||
score += 1
|
||||
$HUD.update_score(score)
|
||||
|
||||
@@ -3,7 +3,7 @@ extends Node2D
|
||||
var bullet := preload("Bullet.tscn")
|
||||
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed("fire"):
|
||||
if input_event.is_action_pressed(&"fire"):
|
||||
fire()
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ var look_direction := Vector2.RIGHT:
|
||||
look_direction = value
|
||||
set_look_direction(value)
|
||||
|
||||
|
||||
func take_damage(attacker: Node, amount: float, effect: Node = null) -> void:
|
||||
if is_ancestor_of(attacker):
|
||||
return
|
||||
|
||||
@@ -36,6 +36,7 @@ func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(PLAYER_STATE.attack):
|
||||
if current_state in [attack, stagger]:
|
||||
return
|
||||
|
||||
_change_state(PLAYER_STATE.attack)
|
||||
return
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ extends "res://player/player_state.gd"
|
||||
# Collection of important methods to handle direction and animation.
|
||||
|
||||
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)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ func get_input_direction() -> Vector2:
|
||||
return Vector2(
|
||||
Input.get_axis(&"move_left", &"move_right"),
|
||||
Input.get_axis(&"move_up", &"move_down")
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
func update_look_direction(direction: Vector2) -> void:
|
||||
|
||||
@@ -22,7 +22,7 @@ func update(_delta: float) -> void:
|
||||
finished.emit(PLAYER_STATE.idle)
|
||||
update_look_direction(input_direction)
|
||||
|
||||
if Input.is_action_pressed("run"):
|
||||
if Input.is_action_pressed(&"run"):
|
||||
speed = max_run_speed
|
||||
else:
|
||||
speed = max_walk_speed
|
||||
@@ -30,7 +30,7 @@ func update(_delta: float) -> void:
|
||||
var collision_info := move(speed, input_direction)
|
||||
if not collision_info:
|
||||
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
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ var speed := 0.0
|
||||
var velocity := Vector2()
|
||||
|
||||
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)
|
||||
|
||||
return super.handle_input(input_event)
|
||||
|
||||
@@ -39,6 +39,7 @@ var combo := [{
|
||||
|
||||
var hit_objects := []
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
$AnimationPlayer.animation_finished.connect(_on_animation_finished)
|
||||
body_entered.connect(_on_body_entered)
|
||||
@@ -63,6 +64,7 @@ func _change_state(new_state: States) -> void:
|
||||
$AnimationPlayer.play(attack_current["animation"])
|
||||
visible = true
|
||||
monitoring = true
|
||||
|
||||
state = new_state
|
||||
|
||||
|
||||
@@ -71,7 +73,7 @@ func _unhandled_input(input_event: InputEvent) -> void:
|
||||
return
|
||||
if attack_input_state != AttackInputStates.LISTENING:
|
||||
return
|
||||
if input_event.is_action_pressed("attack"):
|
||||
if input_event.is_action_pressed(&"attack"):
|
||||
attack_input_state = AttackInputStates.REGISTERED
|
||||
|
||||
|
||||
@@ -96,7 +98,7 @@ func set_ready_for_next_attack() -> void:
|
||||
|
||||
|
||||
func _on_body_entered(body: Node2D) -> void:
|
||||
if not body.has_node("Health"):
|
||||
if not body.has_node(^"Health"):
|
||||
return
|
||||
if body.get_rid().get_id() in hit_objects:
|
||||
return
|
||||
|
||||
@@ -20,6 +20,7 @@ var _active := false:
|
||||
_active = value
|
||||
set_active(value)
|
||||
|
||||
|
||||
func _enter_tree() -> void:
|
||||
if start_state.is_empty():
|
||||
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:
|
||||
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:
|
||||
$WorldEnvironment.environment.glow_map = null
|
||||
# Restore glow intensity to its default value
|
||||
|
||||
@@ -31,8 +31,8 @@ var anim_directions = {
|
||||
|
||||
func _physics_process(_delta):
|
||||
var motion = Vector2()
|
||||
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.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 /= 2
|
||||
motion = motion.normalized() * MOTION_SPEED
|
||||
set_velocity(motion)
|
||||
|
||||
@@ -2,16 +2,16 @@ extends Node2D
|
||||
|
||||
|
||||
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
|
||||
|
||||
if event.is_action_pressed("toggle_point_lights"):
|
||||
for point_light in get_tree().get_nodes_in_group("point_light"):
|
||||
if event.is_action_pressed(&"toggle_point_lights"):
|
||||
for point_light in get_tree().get_nodes_in_group(&"point_light"):
|
||||
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)
|
||||
|
||||
if event.is_action_pressed("cycle_point_light_shadows_quality"):
|
||||
for point_light in get_tree().get_nodes_in_group("point_light"):
|
||||
if event.is_action_pressed(&"cycle_point_light_shadows_quality"):
|
||||
for point_light in get_tree().get_nodes_in_group(&"point_light"):
|
||||
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
|
||||
# Project > Project Settings > Input Map tab.
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if not event.is_action_pressed("click"):
|
||||
if not event.is_action_pressed(&"click"):
|
||||
return
|
||||
|
||||
set_movement_target(get_global_mouse_position())
|
||||
|
||||
@@ -18,7 +18,7 @@ var _path := PackedVector2Array()
|
||||
func _ready() -> void:
|
||||
# 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.
|
||||
# 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.cell_size = CELL_SIZE
|
||||
_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.
|
||||
var traversable_outline: PackedVector2Array = PackedVector2Array([
|
||||
Vector2(0.0, 0.0),
|
||||
Vector2(1920.0, 0.0),
|
||||
Vector2(1920.0, 1080.0),
|
||||
Vector2(0.0, 1080.0),
|
||||
])
|
||||
Vector2(0.0, 0.0),
|
||||
Vector2(1920.0, 0.0),
|
||||
Vector2(1920.0, 1080.0),
|
||||
Vector2(0.0, 1080.0),
|
||||
])
|
||||
source_geometry.add_traversable_outline(traversable_outline)
|
||||
|
||||
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.
|
||||
var start_chunk: Vector2 = floor(
|
||||
input_geometry_bounds.position / p_chunk_size
|
||||
)
|
||||
input_geometry_bounds.position / p_chunk_size
|
||||
)
|
||||
var end_chunk: Vector2 = floor(
|
||||
(input_geometry_bounds.position + input_geometry_bounds.size)
|
||||
/ p_chunk_size
|
||||
)
|
||||
(input_geometry_bounds.position + input_geometry_bounds.size)
|
||||
/ p_chunk_size
|
||||
)
|
||||
|
||||
for chunk_y in range(start_chunk.y, end_chunk.y + 1):
|
||||
for chunk_x in range(start_chunk.x, end_chunk.x + 1):
|
||||
var chunk_id: Vector2i = Vector2i(chunk_x, chunk_y)
|
||||
|
||||
var chunk_bounding_box: Rect2 = Rect2(
|
||||
Vector2(chunk_x, chunk_y) * p_chunk_size,
|
||||
Vector2(p_chunk_size, p_chunk_size),
|
||||
)
|
||||
Vector2(chunk_x, chunk_y) * p_chunk_size,
|
||||
Vector2(p_chunk_size, p_chunk_size),
|
||||
)
|
||||
# We grow the chunk bounding box to include geometry
|
||||
# from all the neighbor chunks so edges can align.
|
||||
# The border size is the same value as our grow amount so
|
||||
@@ -103,9 +103,9 @@ func _process(_delta: float) -> void:
|
||||
return
|
||||
|
||||
var closest_point_on_navmesh: Vector2 = NavigationServer2D.map_get_closest_point(
|
||||
map,
|
||||
mouse_cursor_position
|
||||
)
|
||||
map,
|
||||
mouse_cursor_position
|
||||
)
|
||||
|
||||
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
|
||||
path_start_position = closest_point_on_navmesh
|
||||
@@ -1,6 +1,6 @@
|
||||
[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"]
|
||||
script = ExtResource("1_d68tl")
|
||||
@@ -73,7 +73,7 @@ layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="CanvasLayer/PanelContainer/MarginContainer/VBoxContainer"]
|
||||
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"]
|
||||
layout_mode = 2
|
||||
@@ -87,7 +87,7 @@ color = Color(1, 0, 1, 1)
|
||||
|
||||
[node name="Label" type="Label" parent="CanvasLayer/PanelContainer/MarginContainer/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Path corridor-funnel"
|
||||
text = "Path corridor-funnel"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
@@ -12,7 +12,7 @@ config_version=5
|
||||
|
||||
config/name="Navigation Mesh Chunks 2D"
|
||||
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/icon="res://icon.webp"
|
||||
|
||||
|
||||
@@ -7,32 +7,32 @@ func _ready() -> void:
|
||||
if RenderingServer.get_current_rendering_method() == "gl_compatibility":
|
||||
is_compatibility = true
|
||||
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.
|
||||
get_node("../..").environment.glow_intensity = 4.0
|
||||
get_node(^"../..").environment.glow_intensity = 4.0
|
||||
|
||||
|
||||
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
|
||||
|
||||
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.
|
||||
# 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
|
||||
|
||||
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.
|
||||
# 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)
|
||||
|
||||
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.
|
||||
# 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)
|
||||
|
||||
if event.is_action_pressed("toggle_glow"):
|
||||
get_node("../..").environment.glow_enabled = not get_node("../..").environment.glow_enabled
|
||||
if event.is_action_pressed(&"toggle_glow"):
|
||||
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:
|
||||
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:
|
||||
return
|
||||
|
||||
($AnimationPlayer as AnimationPlayer).play("shutdown")
|
||||
($AnimationPlayer as AnimationPlayer).play(&"shutdown")
|
||||
disabled = true
|
||||
|
||||
@@ -19,8 +19,10 @@ class Circle2D:
|
||||
func _draw() -> void:
|
||||
draw_circle(center, radius, color)
|
||||
|
||||
|
||||
var _drawn_nodes := []
|
||||
|
||||
|
||||
func _enter_tree() -> void:
|
||||
if not _enable_debug_collision:
|
||||
get_tree().debug_collisions_hint = false
|
||||
|
||||
@@ -81,7 +81,7 @@ func _ready() -> void:
|
||||
|
||||
var floor_slider: Control = find_child("FloorMaxAngle")
|
||||
if floor_slider:
|
||||
floor_slider.get_node("HSlider").value = _floor_max_angle
|
||||
floor_slider.get_node(^"HSlider").value = _floor_max_angle
|
||||
|
||||
_start_test()
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ func _remove_objects() -> void:
|
||||
Log.print_log("* Removing objects...")
|
||||
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()
|
||||
for object_index in object_count:
|
||||
root_node.remove_child(_objects[object_count - object_index - 1])
|
||||
|
||||
@@ -199,7 +199,7 @@ func _despawn_objects() -> void:
|
||||
if object_count == 0:
|
||||
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):
|
||||
var node: Node2D = spawn_parent.get_child(object_count - object_index - 1)
|
||||
spawn_parent.remove_child(node)
|
||||
|
||||
@@ -69,5 +69,6 @@ func _integrate_forces(state: PhysicsDirectBodyState2D) -> void:
|
||||
_jumping = false
|
||||
_velocity.y = 0.0
|
||||
|
||||
|
||||
func is_on_floor() -> bool:
|
||||
return _on_floor
|
||||
|
||||
@@ -10,7 +10,7 @@ const WALK_SPEED = 22.0
|
||||
|
||||
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 floor_detector_left := $FloorDetectorLeft as RayCast2D
|
||||
@onready var floor_detector_right := $FloorDetectorRight as RayCast2D
|
||||
|
||||
@@ -18,17 +18,17 @@ func close() -> void:
|
||||
var tween := create_tween()
|
||||
get_tree().paused = false
|
||||
tween.tween_property(
|
||||
self,
|
||||
^"modulate:a",
|
||||
0.0,
|
||||
fade_out_duration
|
||||
).set_trans(Tween.TRANS_LINEAR).set_ease(Tween.EASE_OUT)
|
||||
self,
|
||||
^"modulate:a",
|
||||
0.0,
|
||||
fade_out_duration
|
||||
).set_trans(Tween.TRANS_LINEAR).set_ease(Tween.EASE_OUT)
|
||||
tween.parallel().tween_property(
|
||||
center_cont,
|
||||
^"anchor_bottom",
|
||||
0.5,
|
||||
fade_out_duration
|
||||
).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)
|
||||
center_cont,
|
||||
^"anchor_bottom",
|
||||
0.5,
|
||||
fade_out_duration
|
||||
).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)
|
||||
tween.tween_callback(hide)
|
||||
|
||||
|
||||
@@ -40,17 +40,17 @@ func open() -> void:
|
||||
center_cont.anchor_bottom = 0.5
|
||||
var tween := create_tween()
|
||||
tween.tween_property(
|
||||
self,
|
||||
^"modulate:a",
|
||||
1.0,
|
||||
fade_in_duration
|
||||
).set_trans(Tween.TRANS_LINEAR).set_ease(Tween.EASE_IN)
|
||||
self,
|
||||
^"modulate:a",
|
||||
1.0,
|
||||
fade_in_duration
|
||||
).set_trans(Tween.TRANS_LINEAR).set_ease(Tween.EASE_IN)
|
||||
tween.parallel().tween_property(
|
||||
center_cont,
|
||||
^"anchor_bottom",
|
||||
1.0,
|
||||
fade_out_duration
|
||||
).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)
|
||||
center_cont,
|
||||
^"anchor_bottom",
|
||||
1.0,
|
||||
fade_out_duration
|
||||
).set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)
|
||||
|
||||
|
||||
func _on_coin_collected() -> void:
|
||||
|
||||
@@ -9,7 +9,7 @@ const LIMIT_BOTTOM = 690
|
||||
func _ready():
|
||||
for child in get_children():
|
||||
if child is Player:
|
||||
var camera = child.get_node("Camera")
|
||||
var camera = child.get_node(^"Camera")
|
||||
camera.limit_left = LIMIT_LEFT
|
||||
camera.limit_top = LIMIT_TOP
|
||||
camera.limit_right = LIMIT_RIGHT
|
||||
|
||||
@@ -14,7 +14,7 @@ const TERMINAL_VELOCITY = 700
|
||||
## Used to separate controls for multiple players in splitscreen.
|
||||
@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 animation_player := $AnimationPlayer as AnimationPlayer
|
||||
@onready var shoot_timer := $ShootAnimation as Timer
|
||||
|
||||
@@ -19,7 +19,7 @@ func initialize(combat_combatants: Array[PackedScene]) -> void:
|
||||
var combatant := combatant_scene.instantiate()
|
||||
if combatant is 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:
|
||||
combatant.queue_free()
|
||||
ui.initialize()
|
||||
@@ -30,7 +30,7 @@ func clear_combat() -> void:
|
||||
for n in $Combatants.get_children():
|
||||
# Player characters.
|
||||
n.queue_free()
|
||||
for n in ui.get_node("Combatants").get_children():
|
||||
for n in ui.get_node(^"Combatants").get_children():
|
||||
# Health bars.
|
||||
n.queue_free()
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ signal turn_finished
|
||||
|
||||
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:
|
||||
active = value
|
||||
@@ -37,4 +37,4 @@ func flee() -> void:
|
||||
|
||||
func take_damage(damage_to_take: float) -> void:
|
||||
$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:
|
||||
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 health_info := info.get_node("VBoxContainer/HealthContainer/Health")
|
||||
var health_info := info.get_node(^"VBoxContainer/HealthContainer/Health")
|
||||
health_info.value = health.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)
|
||||
$Combatants.add_child(info)
|
||||
|
||||
@@ -22,25 +22,25 @@ func initialize() -> void:
|
||||
|
||||
|
||||
func _on_Attack_button_up() -> void:
|
||||
if not combatants_node.get_node("Player").active:
|
||||
if not combatants_node.get_node(^"Player").active:
|
||||
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:
|
||||
if not combatants_node.get_node("Player").active:
|
||||
if not combatants_node.get_node(^"Player").active:
|
||||
return
|
||||
|
||||
combatants_node.get_node("Player").defend()
|
||||
combatants_node.get_node(^"Player").defend()
|
||||
|
||||
|
||||
func _on_Flee_button_up() -> void:
|
||||
if not combatants_node.get_node("Player").active:
|
||||
if not combatants_node.get_node(^"Player").active:
|
||||
return
|
||||
|
||||
combatants_node.get_node("Player").flee()
|
||||
combatants_node.get_node(^"Player").flee()
|
||||
|
||||
var loser: Combatant = combatants_node.get_node("Player")
|
||||
var winner: Combatant = combatants_node.get_node("Opponent")
|
||||
var loser: Combatant = combatants_node.get_node(^"Player")
|
||||
var winner: Combatant = combatants_node.get_node(^"Opponent")
|
||||
flee.emit(winner, loser)
|
||||
|
||||
@@ -11,7 +11,7 @@ func show_dialogue(player: Pawn, dialogue: Node) -> void:
|
||||
$Button.grab_focus()
|
||||
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():
|
||||
dialogue_node.start_dialogue()
|
||||
$Name.text = "[center]" + dialogue_node.dialogue_name + "[/center]"
|
||||
|
||||
@@ -13,21 +13,21 @@ func _ready() -> void:
|
||||
for n in $Exploration/Grid.get_children():
|
||||
if not n.type == n.CellType.ACTOR:
|
||||
continue
|
||||
if not n.has_node("DialoguePlayer"):
|
||||
if not n.has_node(^"DialoguePlayer"):
|
||||
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)
|
||||
|
||||
|
||||
func start_combat(combat_actors: Array[PackedScene]) -> void:
|
||||
$AnimationPlayer.play("fade_to_black")
|
||||
$AnimationPlayer.play(&"fade_to_black")
|
||||
await $AnimationPlayer.animation_finished
|
||||
remove_child($Exploration)
|
||||
add_child(combat_screen)
|
||||
combat_screen.show()
|
||||
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:
|
||||
@@ -40,7 +40,7 @@ func _on_opponent_dialogue_finished(opponent: Pawn) -> void:
|
||||
|
||||
func _on_combat_finished(winner: Combatant, _loser: Combatant) -> void:
|
||||
remove_child(combat_screen)
|
||||
$AnimationPlayer.play_backwards("fade_to_black")
|
||||
$AnimationPlayer.play_backwards(&"fade_to_black")
|
||||
add_child(exploration_screen)
|
||||
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
|
||||
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()
|
||||
await dialogue.dialogue_finished
|
||||
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)
|
||||
#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
|
||||
|
||||
dialogue_ui.show_dialogue(pawn, target_pawn.get_node("DialoguePlayer"))
|
||||
dialogue_ui.show_dialogue(pawn, target_pawn.get_node(^"DialoguePlayer"))
|
||||
|
||||
return Vector2i.ZERO
|
||||
|
||||
@@ -18,4 +18,4 @@ func _process(_delta: float) -> void:
|
||||
|
||||
|
||||
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
|
||||
|
||||
@onready var grid : Grid = get_parent()
|
||||
@onready var animation_playback: AnimationNodeStateMachinePlayback = $AnimationTree.get("parameters/playback")
|
||||
@onready var walk_animation_time: float = $AnimationPlayer.get_animation("walk").length
|
||||
@onready var animation_playback: AnimationNodeStateMachinePlayback = $AnimationTree.get(&"parameters/playback")
|
||||
@onready var walk_animation_time: float = $AnimationPlayer.get_animation(&"walk").length
|
||||
@onready var pose := $Pivot/Slime
|
||||
|
||||
|
||||
@@ -27,28 +27,28 @@ func update_look_direction(direction: Vector2) -> void:
|
||||
func move_to(target_position: Vector2) -> void:
|
||||
set_process(false)
|
||||
var move_direction := (target_position - position).normalized()
|
||||
pose.play("idle")
|
||||
animation_playback.start("walk")
|
||||
pose.play(&"idle")
|
||||
animation_playback.start(&"walk")
|
||||
|
||||
var tween := create_tween()
|
||||
tween.set_ease(Tween.EASE_IN)
|
||||
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
|
||||
$Pivot.position = Vector2.ZERO
|
||||
position = target_position
|
||||
animation_playback.start("idle")
|
||||
pose.play("idle")
|
||||
animation_playback.start(&"idle")
|
||||
pose.play(&"idle")
|
||||
|
||||
set_process(true)
|
||||
|
||||
|
||||
func bump() -> void:
|
||||
set_process(false)
|
||||
pose.play("bump")
|
||||
animation_playback.start("bump")
|
||||
pose.play(&"bump")
|
||||
animation_playback.start(&"bump")
|
||||
await $AnimationTree.animation_finished
|
||||
animation_playback.start("idle")
|
||||
pose.play("idle")
|
||||
animation_playback.start(&"idle")
|
||||
pose.play(&"idle")
|
||||
set_process(true)
|
||||
|
||||
@@ -31,15 +31,15 @@ func _ready() -> void:
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var is_jumping := false
|
||||
if Input.is_action_just_pressed("jump"):
|
||||
if Input.is_action_just_pressed(&"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.
|
||||
velocity.y *= 0.6
|
||||
# Fall.
|
||||
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)
|
||||
|
||||
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.
|
||||
# Any number of Tweens can animate a single object in the same time.
|
||||
tween.parallel().tween_callback(func():
|
||||
# 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
|
||||
# on Tweeners can override them.
|
||||
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_IN)
|
||||
)
|
||||
# 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
|
||||
# on Tweeners can override them.
|
||||
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_IN)
|
||||
)
|
||||
|
||||
# Step 5
|
||||
|
||||
@@ -102,7 +102,7 @@ func start_animation() -> void:
|
||||
var tweener := tween.tween_method(
|
||||
func(v: float) -> void:
|
||||
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_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()]
|
||||
# Color FPS counter depending on framerate.
|
||||
# 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:
|
||||
$ViewportResolution.text = "Viewport resolution: %d×%d" % [
|
||||
get_viewport().size.x * get_viewport().scaling_3d_scale,
|
||||
get_viewport().size.y * get_viewport().scaling_3d_scale,
|
||||
]
|
||||
get_viewport().size.x * get_viewport().scaling_3d_scale,
|
||||
get_viewport().size.y * get_viewport().scaling_3d_scale,
|
||||
]
|
||||
|
||||
|
||||
func _on_v_sync_item_selected(index: int) -> void:
|
||||
|
||||
@@ -36,7 +36,7 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
if not result.is_empty():
|
||||
var decal := preload("res://decal.tscn").instantiate()
|
||||
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.transform.basis = camera.global_transform.basis
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Global Illumination
|
||||
|
||||
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>
|
||||
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 ReflectionProbe is parented to the sphere to showcase real-time reflections.
|
||||
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.
|
||||
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)
|
||||
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:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
else:
|
||||
@@ -31,7 +31,7 @@ func _process(delta: float) -> void:
|
||||
Input.get_axis(&"move_left", &"move_right"),
|
||||
0,
|
||||
Input.get_axis(&"move_forward", &"move_back")
|
||||
)
|
||||
)
|
||||
|
||||
# Normalize motion to prevent diagonal movement from being
|
||||
# `sqrt(2)` times faster than straight movement.
|
||||
|
||||
@@ -74,7 +74,7 @@ func _ready() -> void:
|
||||
# Remove unsupported VoxelGI/SDFGI references from the label.
|
||||
reflection_probe_mode_texts[0] = "Disabled - Using environment reflections (Fast)"
|
||||
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.
|
||||
$GrateOmniLight.light_energy = 0.25
|
||||
$GarageOmniLight.light_energy = 0.5
|
||||
@@ -94,7 +94,7 @@ Escape or F10: Toggle mouse capture"""
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("cycle_gi_mode"):
|
||||
if event.is_action_pressed(&"cycle_gi_mode"):
|
||||
if is_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
|
||||
@@ -103,10 +103,10 @@ func _input(event: InputEvent) -> void:
|
||||
else:
|
||||
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))
|
||||
|
||||
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))
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ func _ready() -> void:
|
||||
mark_as_unsupported(%SSReflectionsOptionButton)
|
||||
mark_as_unsupported(%SSILOptionButton)
|
||||
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/SpotLight3D.light_energy = 0.5
|
||||
$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()]
|
||||
# Color FPS counter depending on framerate.
|
||||
# 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:
|
||||
@@ -174,7 +174,7 @@ func _on_fxaa_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_*.
|
||||
# Other modes are maximized and minimized.
|
||||
if index == 0: # Disabled (default)
|
||||
|
||||
@@ -23,7 +23,7 @@ const CHAIN_MAX_ITER = 10
|
||||
var temp = get_node(skeleton_path)
|
||||
if temp != null:
|
||||
# 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
|
||||
bone_IDs = {}
|
||||
|
||||
@@ -109,7 +109,7 @@ func _ready():
|
||||
if target == null:
|
||||
# NOTE: You MUST have a node called Target as a child of this node!
|
||||
# So we create one if one doesn't already exist.
|
||||
if not has_node("Target"):
|
||||
if not has_node(^"Target"):
|
||||
target = Node3D.new()
|
||||
add_child(target)
|
||||
|
||||
@@ -127,7 +127,7 @@ func _ready():
|
||||
_make_editor_sphere_at_node(target, Color.MAGENTA)
|
||||
|
||||
if middle_joint_target == null:
|
||||
if not has_node("MiddleJoint"):
|
||||
if not has_node(^"MiddleJoint"):
|
||||
middle_joint_target = Node3D.new()
|
||||
add_child(middle_joint_target)
|
||||
|
||||
@@ -243,7 +243,7 @@ func solve_chain():
|
||||
else:
|
||||
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])
|
||||
|
||||
# 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.
|
||||
skeleton_path = value
|
||||
# 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:
|
||||
return
|
||||
_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_pos = skeleton_to_use.get_bone_global_pose(additional_bone_id)
|
||||
rest.origin = (
|
||||
additional_bone_pos.origin
|
||||
- additional_bone_pos.basis.z.normalized() * additional_bone_length
|
||||
)
|
||||
additional_bone_pos.origin
|
||||
- additional_bone_pos.basis.z.normalized() * additional_bone_length
|
||||
)
|
||||
|
||||
# Finally, apply the new rotation to the bone in the skeleton.
|
||||
skeleton_to_use.set_bone_global_pose_override(bone, rest, interpolation, true)
|
||||
|
||||
@@ -96,10 +96,10 @@ func process_input(delta):
|
||||
|
||||
if anim_done:
|
||||
if current_anim != "Aiming":
|
||||
anim_player.play("Aiming")
|
||||
anim_player.play(&"Aiming")
|
||||
current_anim = "Aiming"
|
||||
else:
|
||||
anim_player.play("Idle")
|
||||
anim_player.play(&"Idle")
|
||||
current_anim = "Idle"
|
||||
|
||||
anim_done = false
|
||||
|
||||
@@ -8,8 +8,8 @@ extends Camera3D
|
||||
|
||||
func _process(_delta):
|
||||
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:
|
||||
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.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.
|
||||
var bar_text := ""
|
||||
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:
|
||||
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)
|
||||
|
||||
|
||||
|
||||
@@ -40,5 +40,5 @@ func set_target_position(target_position: Vector3) -> void:
|
||||
start_position,
|
||||
target_position,
|
||||
optimize
|
||||
)
|
||||
)
|
||||
_nav_path_line.draw_path(path)
|
||||
|
||||
@@ -19,7 +19,7 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
get_world_3d().navigation_map,
|
||||
camera_ray_start,
|
||||
camera_ray_end
|
||||
)
|
||||
)
|
||||
_robot.set_target_position(closest_point_on_navmesh)
|
||||
|
||||
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.
|
||||
var start_chunk: Vector3 = floor(
|
||||
input_geometry_bounds.position / p_chunk_size
|
||||
)
|
||||
input_geometry_bounds.position / p_chunk_size
|
||||
)
|
||||
var end_chunk: Vector3 = floor(
|
||||
(input_geometry_bounds.position + input_geometry_bounds.size)
|
||||
/ p_chunk_size
|
||||
)
|
||||
(input_geometry_bounds.position + input_geometry_bounds.size)
|
||||
/ p_chunk_size
|
||||
)
|
||||
|
||||
# NavigationMesh.border_size is limited to the xz-axis.
|
||||
# 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_bounding_box: AABB = AABB(
|
||||
Vector3(chunk_x, bounds_min_height, chunk_z) * p_chunk_size,
|
||||
Vector3(p_chunk_size, bounds_max_height, p_chunk_size),
|
||||
)
|
||||
Vector3(chunk_x, bounds_min_height, chunk_z) * p_chunk_size,
|
||||
Vector3(p_chunk_size, bounds_max_height, p_chunk_size),
|
||||
)
|
||||
# We grow the chunk bounding box to include geometry
|
||||
# from all the neighbor chunks so edges can align.
|
||||
# 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_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(
|
||||
map,
|
||||
camera_ray_start,
|
||||
camera_ray_end
|
||||
)
|
||||
map,
|
||||
camera_ray_start,
|
||||
camera_ray_end
|
||||
)
|
||||
|
||||
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
|
||||
path_start_position = closest_point_on_navmesh
|
||||
|
||||
@@ -26,7 +26,7 @@ will vary depending on your CPU and GPU model.
|
||||
|
||||
> **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
|
||||
> occlusion culling is a demanding process on the CPU, which needs all the
|
||||
> 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)
|
||||
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:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
else:
|
||||
@@ -31,7 +31,7 @@ func _process(delta: float) -> void:
|
||||
Input.get_axis(&"move_left", &"move_right"),
|
||||
0,
|
||||
Input.get_axis(&"move_forward", &"move_back")
|
||||
)
|
||||
)
|
||||
|
||||
# Normalize motion to prevent diagonal movement from being
|
||||
# `sqrt(2)` times faster than straight movement.
|
||||
|
||||
@@ -3,16 +3,16 @@ extends Node3D
|
||||
var open := false
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("toggle_doors"):
|
||||
if event.is_action_pressed(&"toggle_doors"):
|
||||
if open:
|
||||
# Close the door.
|
||||
# The occluder will be re-enabled when the animation ends
|
||||
# using `_on_animation_player_animation_finished()`.
|
||||
$AnimationPlayer.play_backwards("open")
|
||||
$AnimationPlayer.play_backwards(&"open")
|
||||
open = false
|
||||
else:
|
||||
# Open the door.
|
||||
$AnimationPlayer.play("open")
|
||||
$AnimationPlayer.play(&"open")
|
||||
open = true
|
||||
# Disable the occluder as soon as the door starts opening.
|
||||
# The occluder is not part of the pivot to prevent it from having its
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
extends Node3D
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
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:
|
||||
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED)
|
||||
else:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# 3D 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
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@ func get_color_from_temperature(p_temperature: float) -> Color:
|
||||
var u := (
|
||||
(0.860117757 + 1.54118254e-4 * p_temperature + 1.28641212e-7 * t2) /
|
||||
(1.0 + 8.42420235e-4 * p_temperature + 7.08145163e-7 * t2)
|
||||
)
|
||||
)
|
||||
var v := (
|
||||
(0.317398726 + 4.22806245e-5 * p_temperature + 4.20481691e-8 * t2) /
|
||||
(1.0 - 2.89741816e-5 * p_temperature + 1.61456053e-7 * t2)
|
||||
)
|
||||
)
|
||||
|
||||
# Convert to xyY space.
|
||||
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,
|
||||
-0.9692660 * xyz.x + 1.8760108 * xyz.y + 0.0415560 * xyz.z,
|
||||
0.0556434 * xyz.x - 0.2040259 * xyz.y + 1.0572252 * xyz.z
|
||||
)
|
||||
)
|
||||
linear /= maxf(1e-5, linear[linear.max_axis_index()])
|
||||
# Normalize, clamp, and convert 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:
|
||||
lightbulb_1.light_temperature = 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:
|
||||
@@ -78,7 +78,7 @@ func _on_lightbulb2_intensity_value_changed(value: float) -> void:
|
||||
func _on_lightbulb2_temperature_value_changed(value: float) -> void:
|
||||
lightbulb_2.light_temperature = 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:
|
||||
|
||||
@@ -114,7 +114,7 @@ func cycle_camera_type() -> void:
|
||||
$Rig/Camera_TPS.make_current()
|
||||
CameraType.CAM_TPS:
|
||||
_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).
|
||||
if _cam_type == CameraType.CAM_FPS:
|
||||
|
||||
@@ -160,7 +160,7 @@ func start_test() -> void:
|
||||
animation_player.playback_process_mode = AnimationPlayer.ANIMATION_PROCESS_PHYSICS
|
||||
else:
|
||||
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
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ func _remove_objects() -> void:
|
||||
Log.print_log("* Removing objects...")
|
||||
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()
|
||||
for object_index in object_count:
|
||||
root_node.remove_child(_objects[object_count - object_index - 1])
|
||||
|
||||
@@ -190,7 +190,7 @@ func _despawn_objects() -> void:
|
||||
for spawn in spawns:
|
||||
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()
|
||||
for object_index in object_count:
|
||||
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),
|
||||
0xffffffff,
|
||||
collision_exception
|
||||
))
|
||||
))
|
||||
var col := ds.intersect_ray(PhysicsRayQueryParameters3D.create(
|
||||
target,
|
||||
target + difference,
|
||||
0xffffffff,
|
||||
collision_exception
|
||||
))
|
||||
))
|
||||
var col_right := ds.intersect_ray(PhysicsRayQueryParameters3D.create(
|
||||
target,
|
||||
target + Basis(Vector3.UP, deg_to_rad(-autoturn_ray_aperture)) * (difference),
|
||||
0xffffffff,
|
||||
collision_exception
|
||||
))
|
||||
))
|
||||
|
||||
if not col.is_empty():
|
||||
# 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:
|
||||
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.
|
||||
position = initial_position
|
||||
velocity = Vector3.ZERO
|
||||
@@ -48,10 +48,10 @@ func _physics_process(delta: float) -> void:
|
||||
# Update coin count and its "parallax" copies.
|
||||
# This gives text a pseudo-3D appearance while still using Label3D instead of the more limited TextMesh.
|
||||
%CoinCount.text = str(coins)
|
||||
%CoinCount.get_node("Parallax").text = str(coins)
|
||||
%CoinCount.get_node("Parallax2").text = str(coins)
|
||||
%CoinCount.get_node("Parallax3").text = str(coins)
|
||||
%CoinCount.get_node("Parallax4").text = str(coins)
|
||||
%CoinCount.get_node(^"Parallax").text = str(coins)
|
||||
%CoinCount.get_node(^"Parallax2").text = str(coins)
|
||||
%CoinCount.get_node(^"Parallax3").text = str(coins)
|
||||
%CoinCount.get_node(^"Parallax4").text = str(coins)
|
||||
|
||||
velocity += gravity * delta
|
||||
|
||||
@@ -79,12 +79,12 @@ func _physics_process(delta: float) -> void:
|
||||
if movement_direction.length() > 0.1 and not sharp_turn:
|
||||
if horizontal_speed > 0.001:
|
||||
horizontal_direction = adjust_facing(
|
||||
horizontal_direction,
|
||||
movement_direction,
|
||||
delta,
|
||||
1.0 / horizontal_speed * TURN_SPEED,
|
||||
Vector3.UP
|
||||
)
|
||||
horizontal_direction,
|
||||
movement_direction,
|
||||
delta,
|
||||
1.0 / horizontal_speed * TURN_SPEED,
|
||||
Vector3.UP
|
||||
)
|
||||
else:
|
||||
horizontal_direction = movement_direction
|
||||
|
||||
@@ -103,17 +103,17 @@ func _physics_process(delta: float) -> void:
|
||||
|
||||
if horizontal_speed > 0:
|
||||
facing_mesh = adjust_facing(
|
||||
facing_mesh,
|
||||
movement_direction,
|
||||
delta,
|
||||
1.0 / horizontal_speed * TURN_SPEED,
|
||||
Vector3.UP
|
||||
)
|
||||
facing_mesh,
|
||||
movement_direction,
|
||||
delta,
|
||||
1.0 / horizontal_speed * TURN_SPEED,
|
||||
Vector3.UP
|
||||
)
|
||||
var m3 := Basis(
|
||||
-facing_mesh,
|
||||
Vector3.UP,
|
||||
-facing_mesh.cross(Vector3.UP).normalized()
|
||||
).scaled(CHAR_SCALE)
|
||||
-facing_mesh,
|
||||
Vector3.UP,
|
||||
-facing_mesh.cross(Vector3.UP).normalized()
|
||||
).scaled(CHAR_SCALE)
|
||||
|
||||
$Player/Skeleton.set_transform(Transform3D(m3, mesh_xform.origin))
|
||||
|
||||
@@ -135,7 +135,7 @@ func _physics_process(delta: float) -> void:
|
||||
horizontal_speed = 0
|
||||
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.
|
||||
vertical_velocity *= 0.7
|
||||
|
||||
@@ -160,8 +160,8 @@ func _physics_process(delta: float) -> void:
|
||||
bullet.set_transform($Player/Skeleton/Bullet.get_global_transform().orthonormalized())
|
||||
get_parent().add_child(bullet)
|
||||
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)
|
||||
$SoundShoot.play()
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ resource dropdown.
|
||||
> **Warning**
|
||||
>
|
||||
> 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
|
||||
> complex sky shaders. The performance impact can be reduced by adjusting the
|
||||
> radiance map properties in Environment, but it will remain significant.
|
||||
|
||||
@@ -13,21 +13,21 @@ func _ready() -> void:
|
||||
func _process(delta: float) -> void:
|
||||
# Make the slider follow the day/night cycle.
|
||||
$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))
|
||||
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("toggle_gui"):
|
||||
if event.is_action_pressed(&"toggle_gui"):
|
||||
$Panel.visible = not $Panel.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
|
||||
|
||||
if event.is_action_pressed("toggle_mouse_capture"):
|
||||
if event.is_action_pressed(&"toggle_mouse_capture"):
|
||||
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
else:
|
||||
@@ -40,9 +40,9 @@ func _input(event: InputEvent) -> void:
|
||||
$YawCamera.rotation.y -= relative_motion.x * MOUSE_SENSITIVITY
|
||||
|
||||
# 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)
|
||||
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)
|
||||
|
||||
|
||||
@@ -81,12 +81,12 @@ func update_speed_label() -> 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)
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ var velocity: Vector3 = Vector3.ZERO
|
||||
func _process(delta: float) -> void:
|
||||
var input_vector: Vector2 = Vector2.ZERO
|
||||
|
||||
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.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")
|
||||
|
||||
if input_vector.length() > 0:
|
||||
input_vector = input_vector.normalized()
|
||||
@@ -20,8 +20,8 @@ func _process(delta: float) -> void:
|
||||
|
||||
# Play corresponding animation.
|
||||
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:
|
||||
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:
|
||||
sprite.stop()
|
||||
|
||||
@@ -20,7 +20,7 @@ func _ready():
|
||||
|
||||
|
||||
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()
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ func _on_mob_timer_timeout():
|
||||
var mob = mob_scene.instantiate()
|
||||
|
||||
# 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()
|
||||
|
||||
# Communicate the spawn location and the player's location to the mob.
|
||||
|
||||
@@ -14,13 +14,13 @@ signal hit
|
||||
|
||||
func _physics_process(delta):
|
||||
var direction = Vector3.ZERO
|
||||
if Input.is_action_pressed("move_right"):
|
||||
if Input.is_action_pressed(&"move_right"):
|
||||
direction.x += 1
|
||||
if Input.is_action_pressed("move_left"):
|
||||
if Input.is_action_pressed(&"move_left"):
|
||||
direction.x -= 1
|
||||
if Input.is_action_pressed("move_back"):
|
||||
if Input.is_action_pressed(&"move_back"):
|
||||
direction.z += 1
|
||||
if Input.is_action_pressed("move_forward"):
|
||||
if Input.is_action_pressed(&"move_forward"):
|
||||
direction.z -= 1
|
||||
|
||||
if direction != Vector3.ZERO:
|
||||
@@ -36,7 +36,7 @@ func _physics_process(delta):
|
||||
velocity.z = direction.z * speed
|
||||
|
||||
# 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
|
||||
|
||||
# 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.
|
||||
for index in range(get_slide_collision_count()):
|
||||
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()
|
||||
if Vector3.UP.dot(collision.get_normal()) > 0.1:
|
||||
mob.squash()
|
||||
|
||||
@@ -7,15 +7,15 @@ class_name GradientBars extends Node3D
|
||||
func set_num_steps(steps: int) -> void:
|
||||
var shader_mat: ShaderMaterial = hdr_bar.material_override as ShaderMaterial
|
||||
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:
|
||||
var shader_mat: ShaderMaterial = sdr_bar.material_override as ShaderMaterial
|
||||
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
|
||||
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)
|
||||
|
||||
@@ -22,10 +22,10 @@ func _on_steps_value_changed(value):
|
||||
for bar_path in bars:
|
||||
var bar = get_node(bar_path)
|
||||
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:
|
||||
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):
|
||||
@@ -37,10 +37,10 @@ func _on_exponential_toggled(button_pressed):
|
||||
for bar_path in bars:
|
||||
var bar = get_node(bar_path)
|
||||
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.set_shader_parameter("exponential_view", button_pressed)
|
||||
shader_mat.set_shader_parameter(&"exponential_view", button_pressed)
|
||||
if hues:
|
||||
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,
|
||||
false,
|
||||
Image.FORMAT_RGB8
|
||||
)
|
||||
)
|
||||
|
||||
for z in size:
|
||||
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(((y + 0.2) / float(size - 1)) * 255),
|
||||
roundi(((z + 0.2) / float(size - 1)) * 255)
|
||||
))
|
||||
))
|
||||
|
||||
image.save_png("user://" + name + ".png")
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ func _process(_delta: float) -> void:
|
||||
text = "Speed: " + ("%.0f" % speed) + " mph"
|
||||
|
||||
# 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:
|
||||
|
||||
@@ -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)
|
||||
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:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
else:
|
||||
@@ -32,7 +32,7 @@ func _process(delta: float) -> void:
|
||||
Input.get_axis(&"move_left", &"move_right"),
|
||||
0,
|
||||
Input.get_axis(&"move_forward", &"move_back")
|
||||
)
|
||||
)
|
||||
|
||||
# Normalize motion to prevent diagonal movement from being
|
||||
# `sqrt(2)` times faster than straight movement.
|
||||
|
||||
@@ -18,10 +18,10 @@ func _ready() -> void:
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
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,
|
||||
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
|
||||
# `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)
|
||||
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:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
else:
|
||||
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
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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_depth = clamp(volumetric_fog_volume_depth + 16, 16, 384)
|
||||
RenderingServer.environment_set_volumetric_fog_volume_size(volumetric_fog_volume_size, volumetric_fog_volume_depth)
|
||||
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_depth = clamp(volumetric_fog_volume_depth - 16, 16, 384)
|
||||
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:
|
||||
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" % [
|
||||
get_world_3d().environment.volumetric_fog_density,
|
||||
get_world_3d().environment.volumetric_fog_temporal_reprojection_amount,
|
||||
volumetric_fog_volume_size,
|
||||
volumetric_fog_volume_size,
|
||||
volumetric_fog_volume_depth,
|
||||
]
|
||||
get_world_3d().environment.volumetric_fog_density,
|
||||
get_world_3d().environment.volumetric_fog_temporal_reprojection_amount,
|
||||
volumetric_fog_volume_size,
|
||||
volumetric_fog_volume_size,
|
||||
volumetric_fog_volume_depth,
|
||||
]
|
||||
else:
|
||||
label.text = "Fog density: %.2f\nTemporal reprojection: Disabled\nVolumetric fog quality: %d×%d×%d" % [
|
||||
get_world_3d().environment.volumetric_fog_density,
|
||||
volumetric_fog_volume_size,
|
||||
volumetric_fog_volume_size,
|
||||
volumetric_fog_volume_depth,
|
||||
]
|
||||
get_world_3d().environment.volumetric_fog_density,
|
||||
volumetric_fog_volume_size,
|
||||
volumetric_fog_volume_size,
|
||||
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)
|
||||
var breaking := Input.is_action_just_pressed(&"break")
|
||||
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:
|
||||
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))
|
||||
|
||||
# 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))
|
||||
|
||||
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
|
||||
|
||||
return [
|
||||
# Godot 4 has a weird bug where there are seams at the edge
|
||||
# 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.99),
|
||||
TEXTURE_TILE_SIZE * Vector2(col + 0.99, row + 0.01),
|
||||
TEXTURE_TILE_SIZE * Vector2(col + 0.99, row + 0.99),
|
||||
]
|
||||
# Godot 4 has a weird bug where there are seams at the edge
|
||||
# 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.99),
|
||||
TEXTURE_TILE_SIZE * Vector2(col + 0.99, row + 0.01),
|
||||
TEXTURE_TILE_SIZE * Vector2(col + 0.99, row + 0.99),
|
||||
]
|
||||
|
||||
|
||||
static func calculate_block_verts(block_position: Vector3) -> Array[Vector3]:
|
||||
return [
|
||||
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 + 1, block_position.z),
|
||||
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 + 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 + 1),
|
||||
]
|
||||
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 + 1, block_position.z),
|
||||
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 + 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 + 1),
|
||||
]
|
||||
|
||||
|
||||
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"),
|
||||
0,
|
||||
Input.get_axis(&"move_forward", &"move_back")
|
||||
)
|
||||
)
|
||||
|
||||
# Normalize motion to prevent diagonal movement from being
|
||||
# `sqrt(2)` times faster than straight movement.
|
||||
|
||||
@@ -47,7 +47,7 @@ func _process(_delta: float) -> void:
|
||||
var viewport_base_size: Vector2i = (
|
||||
get_viewport().content_scale_size if get_viewport().content_scale_size > Vector2i(0, 0)
|
||||
else get_viewport().size
|
||||
)
|
||||
)
|
||||
|
||||
if not sticky:
|
||||
# For non-sticky waypoints, we don't need to clamp and calculate
|
||||
@@ -80,7 +80,7 @@ func _process(_delta: float) -> void:
|
||||
position = Vector2(
|
||||
clamp(unprojected_position.x, MARGIN, viewport_base_size.x - MARGIN),
|
||||
clamp(unprojected_position.y, MARGIN, viewport_base_size.y - MARGIN)
|
||||
)
|
||||
)
|
||||
|
||||
label.visible = true
|
||||
rotation = 0
|
||||
|
||||
@@ -9,7 +9,7 @@ var format := AudioStreamWAV.FORMAT_16_BITS # This is the default format on rec
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var idx := AudioServer.get_bus_index("Record")
|
||||
var idx := AudioServer.get_bus_index(&"Record")
|
||||
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
|
||||
# value is very jittery, but will always match what the player is hearing.
|
||||
_song_time_audio = (
|
||||
player.get_playback_position()
|
||||
# The 1st beat may not start at second 0 of the audio track. Compensate
|
||||
# with an offset setting.
|
||||
- first_beat_offset_ms / 1000.0
|
||||
# For most platforms, the playback position value updates in chunks,
|
||||
# with each chunk being one "mix". Smooth this out by adding in the time
|
||||
# since the last chunk was processed.
|
||||
+ last_mix
|
||||
# Current processed audio is heard later.
|
||||
- _cached_output_latency
|
||||
)
|
||||
player.get_playback_position()
|
||||
# The 1st beat may not start at second 0 of the audio track. Compensate
|
||||
# with an offset setting.
|
||||
- first_beat_offset_ms / 1000.0
|
||||
# For most platforms, the playback position value updates in chunks,
|
||||
# with each chunk being one "mix". Smooth this out by adding in the time
|
||||
# since the last chunk was processed.
|
||||
+ last_mix
|
||||
# Current processed audio is heard later.
|
||||
- _cached_output_latency
|
||||
)
|
||||
|
||||
# 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,
|
||||
@@ -126,17 +126,17 @@ func play() -> void:
|
||||
|
||||
# Capture the start of the song using the system clock.
|
||||
_song_time_begin = (
|
||||
Time.get_ticks_usec() / 1000000.0
|
||||
# The 1st beat may not start at second 0 of the audio track. Compensate
|
||||
# with an offset setting.
|
||||
+ first_beat_offset_ms / 1000.0
|
||||
# Playback does not start immediately, but only when the next audio
|
||||
# chunk is processed (the "mix" step). Add in the time until that
|
||||
# happens.
|
||||
+ AudioServer.get_time_to_next_mix()
|
||||
# Add in additional output latency.
|
||||
+ _cached_output_latency
|
||||
)
|
||||
Time.get_ticks_usec() / 1000000.0
|
||||
# The 1st beat may not start at second 0 of the audio track. Compensate
|
||||
# with an offset setting.
|
||||
+ first_beat_offset_ms / 1000.0
|
||||
# Playback does not start immediately, but only when the next audio
|
||||
# chunk is processed (the "mix" step). Add in the time until that
|
||||
# happens.
|
||||
+ AudioServer.get_time_to_next_mix()
|
||||
# Add in additional output latency.
|
||||
+ _cached_output_latency
|
||||
)
|
||||
|
||||
|
||||
func stop() -> void:
|
||||
|
||||
@@ -24,9 +24,9 @@ var _hit_count: int = 0
|
||||
func _ready() -> void:
|
||||
_play_stats = PlayStats.new()
|
||||
_play_stats.changed.connect(
|
||||
func() -> void:
|
||||
play_stats_updated.emit(_play_stats)
|
||||
)
|
||||
func() -> void:
|
||||
play_stats_updated.emit(_play_stats)
|
||||
)
|
||||
|
||||
var chart_data := ChartData.get_chart_data(chart)
|
||||
|
||||
@@ -58,7 +58,7 @@ func _process(_delta: float) -> void:
|
||||
|
||||
_miss_old_notes()
|
||||
|
||||
if Input.is_action_just_pressed("main_key"):
|
||||
if Input.is_action_just_pressed(&"main_key"):
|
||||
_handle_keypress()
|
||||
|
||||
if _notes.is_empty():
|
||||
|
||||
@@ -6,16 +6,19 @@ extends Resource
|
||||
if mean_hit_error != value:
|
||||
mean_hit_error = value
|
||||
emit_changed()
|
||||
|
||||
@export var perfect_count: int = 0:
|
||||
set(value):
|
||||
if perfect_count != value:
|
||||
perfect_count = value
|
||||
emit_changed()
|
||||
|
||||
@export var good_count: int = 0:
|
||||
set(value):
|
||||
if good_count != value:
|
||||
good_count = value
|
||||
emit_changed()
|
||||
|
||||
@export var miss_count: int = 0:
|
||||
set(value):
|
||||
if miss_count != value:
|
||||
|
||||
@@ -18,12 +18,14 @@ func _init(args: Variant) -> void:
|
||||
x_filter = LowPassFilter.new()
|
||||
dx_filter = LowPassFilter.new()
|
||||
|
||||
|
||||
func alpha(rate: float, cutoff: float) -> float:
|
||||
var tau: float = 1.0 / (2 * PI * cutoff)
|
||||
var te: float = 1.0 / rate
|
||||
|
||||
return 1.0 / (1.0 + tau/te)
|
||||
|
||||
|
||||
func filter(value: float, delta: float) -> float:
|
||||
var rate: float = 1.0 / delta
|
||||
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)
|
||||
return x_filter.filter(value, alpha(rate, cutoff))
|
||||
|
||||
|
||||
class LowPassFilter:
|
||||
var last_value: float
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
last_value = 0
|
||||
|
||||
|
||||
func filter(value: float, alpha: float) -> float:
|
||||
var result := alpha * value + (1 - alpha) * last_value
|
||||
last_value = result
|
||||
|
||||
@@ -4,9 +4,9 @@ var _guide_tween: Tween
|
||||
|
||||
|
||||
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
|
||||
if _guide_tween:
|
||||
_guide_tween.kill()
|
||||
_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()
|
||||
tween.set_ease(Tween.EASE_OUT)
|
||||
tween.set_trans(Tween.TRANS_QUAD)
|
||||
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(self, ^"modulate:a", 0, 0.2)
|
||||
tween.parallel().tween_property($Sprite2D, ^"scale", 1.5 * Vector2.ONE, 0.2)
|
||||
tween.tween_callback(queue_free)
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ func hit_good() -> void:
|
||||
var tween := create_tween()
|
||||
tween.set_ease(Tween.EASE_OUT)
|
||||
tween.set_trans(Tween.TRANS_QUAD)
|
||||
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(self, ^"modulate:a", 0, 0.2)
|
||||
tween.parallel().tween_property($Sprite2D, ^"scale", 1.2 * Vector2.ONE, 0.2)
|
||||
tween.tween_callback(queue_free)
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ func miss(stop_movement: bool = true) -> void:
|
||||
modulate = Color.DARK_RED
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ func _ready() -> 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()
|
||||
$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 = create_tween()
|
||||
_judgment_tween.tween_interval(0.2)
|
||||
_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.tween_property($Control/JudgmentHBox/LJudgmentLabel, ^"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))
|
||||
$Control/ErrorGraphVBox/CenterContainer/JudgmentsGraph.queue_redraw()
|
||||
|
||||
@@ -3,6 +3,6 @@ extends Node
|
||||
|
||||
|
||||
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
|
||||
$"../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