mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2025-12-13 12:10:04 +01:00
Improve style in many demos (#1263)
This commit is contained in:
@@ -5,7 +5,7 @@ extends Node2D
|
||||
# is less visual. Bullets are managed together in the `bullets.gd` script.
|
||||
|
||||
## The number of bullets currently touched by the player.
|
||||
var touching := 0
|
||||
var touching: int = 0
|
||||
|
||||
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
|
||||
|
||||
@@ -16,10 +16,10 @@ func _ready() -> void:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
# Getting the movement of the mouse so the sprite can follow its position.
|
||||
if event is InputEventMouseMotion:
|
||||
position = event.position - Vector2(0, 16)
|
||||
if input_event is InputEventMouseMotion:
|
||||
position = input_event.position - Vector2(0, 16)
|
||||
|
||||
|
||||
func _on_body_shape_entered(_body_id: RID, _body: Node2D, _body_shape_index: int, _local_shape_index: int) -> void:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
@tool
|
||||
extends Panel
|
||||
|
||||
var use_antialiasing := false
|
||||
var use_antialiasing: bool = false
|
||||
|
||||
var time := 0.0
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
extends Control
|
||||
|
||||
var use_antialiasing := false
|
||||
|
||||
var use_antialiasing: bool = false
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
var margin := Vector2(240, 70)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
@tool
|
||||
extends Panel
|
||||
|
||||
var use_antialiasing := false
|
||||
var use_antialiasing: bool = false
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
@tool
|
||||
extends Panel
|
||||
|
||||
var use_antialiasing := false
|
||||
var use_antialiasing: bool = false
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
@tool
|
||||
extends Panel
|
||||
|
||||
var use_antialiasing := false
|
||||
var use_antialiasing: bool = false
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
@tool
|
||||
extends Panel
|
||||
|
||||
var use_antialiasing := false
|
||||
var use_antialiasing: bool = false
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
@tool
|
||||
extends Panel
|
||||
|
||||
var use_antialiasing := false
|
||||
var use_antialiasing: bool = false
|
||||
|
||||
func _draw() -> void:
|
||||
const ICON = preload("res://icon.svg")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
extends TileMapLayer
|
||||
|
||||
# You can have multiple layers if you make this an array.
|
||||
var player_in_secret := false
|
||||
var player_in_secret: bool = false
|
||||
var layer_alpha := 1.0
|
||||
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ extends Panel
|
||||
@onready var fsm_node: Node = get_node(^"../../Player/StateMachine")
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
var states_names := ""
|
||||
var numbers := ""
|
||||
var states_names: String = ""
|
||||
var numbers: String = ""
|
||||
var index := 0
|
||||
|
||||
for state: Node in fsm_node.states_stack:
|
||||
|
||||
@@ -15,7 +15,7 @@ enum AttackInputStates {
|
||||
|
||||
var state: States = States.IDLE
|
||||
var attack_input_state := AttackInputStates.IDLE
|
||||
var ready_for_next_attack := false
|
||||
var ready_for_next_attack: bool = false
|
||||
const MAX_COMBO_COUNT = 3
|
||||
var combo_count := 0
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ var states_map := {}
|
||||
|
||||
var states_stack := []
|
||||
var current_state: Node = null
|
||||
var _active := false:
|
||||
var _active: bool = false:
|
||||
set(value):
|
||||
_active = value
|
||||
set_active(value)
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
const CAVE_LIMIT = 1000
|
||||
|
||||
var glow_map := preload("res://glow_map.webp")
|
||||
|
||||
@onready var cave: Node2D = $Cave
|
||||
|
||||
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"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventMouseMotion and input_event.button_mask > 0:
|
||||
cave.position.x = clampf(cave.position.x + input_event.screen_relative.x, -CAVE_LIMIT, 0)
|
||||
|
||||
if input_event.is_action_pressed(&"toggle_glow_map"):
|
||||
if $WorldEnvironment.environment.glow_map:
|
||||
$WorldEnvironment.environment.glow_map = null
|
||||
# Restore glow intensity to its default value
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
@export var ball_scene: PackedScene = preload("res://ball.tscn")
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_echo():
|
||||
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_echo():
|
||||
return
|
||||
|
||||
if event is InputEventMouseButton and event.is_pressed():
|
||||
if event.button_index == MOUSE_BUTTON_LEFT:
|
||||
if input_event is InputEventMouseButton and input_event.is_pressed():
|
||||
if input_event.button_index == MOUSE_BUTTON_LEFT:
|
||||
spawn(get_global_mouse_position())
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"toggle_directional_light"):
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"toggle_directional_light"):
|
||||
$DirectionalLight2D.visible = not $DirectionalLight2D.visible
|
||||
|
||||
if event.is_action_pressed(&"toggle_point_lights"):
|
||||
if input_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 input_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"):
|
||||
if input_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)
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
|
||||
var movement_speed := 200.0
|
||||
|
||||
@onready var navigation_agent: NavigationAgent2D = $NavigationAgent2D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# These values need to be adjusted for the actor's speed
|
||||
# and the navigation layout.
|
||||
@@ -14,8 +16,8 @@ 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"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if not input_event.is_action_pressed(&"click"):
|
||||
return
|
||||
|
||||
set_movement_target(get_global_mouse_position())
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
const PathFindAStar = preload("./pathfind_astar.gd")
|
||||
|
||||
enum State {
|
||||
@@ -21,6 +22,7 @@ var _next_point := Vector2()
|
||||
|
||||
@onready var _tile_map: PathFindAStar = $"../TileMapLayer"
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_change_state(State.IDLE)
|
||||
|
||||
@@ -38,14 +40,14 @@ func _physics_process(_delta: float) -> void:
|
||||
_next_point = _path[0]
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
_click_position = get_global_mouse_position()
|
||||
if _tile_map.is_point_walkable(_click_position):
|
||||
if event.is_action_pressed(&"teleport_to", false, true):
|
||||
if input_event.is_action_pressed(&"teleport_to", false, true):
|
||||
_change_state(State.IDLE)
|
||||
global_position = _tile_map.round_local_position(_click_position)
|
||||
reset_physics_interpolation()
|
||||
elif event.is_action_pressed(&"move_to"):
|
||||
elif input_event.is_action_pressed(&"move_to"):
|
||||
_change_state(State.FOLLOW)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
extends Label
|
||||
|
||||
var is_compatibility := false
|
||||
|
||||
var is_compatibility: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -12,27 +13,27 @@ func _ready() -> void:
|
||||
get_node(^"../..").environment.glow_intensity = 4.0
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"toggle_pause"):
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_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 input_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"):
|
||||
particles.trail_enabled = not particles.trail_enabled
|
||||
|
||||
if not is_compatibility and event.is_action_pressed(&"increase_trail_length"):
|
||||
if not is_compatibility and input_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"):
|
||||
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 input_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"):
|
||||
particles.trail_lifetime = clampf(particles.trail_lifetime - 0.05, 0.1, 1.0)
|
||||
|
||||
if event.is_action_pressed(&"toggle_glow"):
|
||||
if input_event.is_action_pressed(&"toggle_glow"):
|
||||
get_node(^"../..").environment.glow_enabled = not get_node(^"../..").environment.glow_enabled
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class_name Coin
|
||||
extends Area2D
|
||||
|
||||
var taken := false
|
||||
var taken: bool = false
|
||||
|
||||
func _on_body_enter(body: Node2D) -> void:
|
||||
if not taken and body is Player:
|
||||
|
||||
@@ -11,7 +11,7 @@ enum State {
|
||||
var _state := State.WALKING
|
||||
|
||||
var direction := -1
|
||||
var anim := ""
|
||||
var anim: String = ""
|
||||
|
||||
@onready var rc_left := $RaycastLeft as RayCast2D
|
||||
@onready var rc_right := $RaycastRight as RayCast2D
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class_name Bullet
|
||||
extends RigidBody2D
|
||||
|
||||
var disabled := false
|
||||
var disabled: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
($Timer as Timer).start()
|
||||
|
||||
@@ -14,11 +14,11 @@ const MAX_FLOOR_AIRBORNE_TIME = 0.15
|
||||
const BULLET_SCENE = preload("res://player/bullet.tscn")
|
||||
const ENEMY_SCENE = preload("res://enemy/enemy.tscn")
|
||||
|
||||
var anim := ""
|
||||
var siding_left := false
|
||||
var jumping := false
|
||||
var stopping_jump := false
|
||||
var shooting := false
|
||||
var anim: String = ""
|
||||
var siding_left: bool = false
|
||||
var jumping: bool = false
|
||||
var stopping_jump: bool = false
|
||||
var shooting: bool = false
|
||||
|
||||
var floor_h_velocity: float = 0.0
|
||||
|
||||
@@ -55,7 +55,7 @@ func _integrate_forces(state: PhysicsDirectBodyState2D) -> void:
|
||||
floor_h_velocity = 0.0
|
||||
|
||||
# Find the floor (a contact with upwards facing collision normal).
|
||||
var found_floor := false
|
||||
var found_floor: bool = false
|
||||
var floor_index := -1
|
||||
|
||||
for contact_index in state.get_contact_count():
|
||||
|
||||
@@ -3,17 +3,17 @@ extends Node2D
|
||||
|
||||
signal wait_done()
|
||||
|
||||
@export var _enable_debug_collision := true
|
||||
@export var _enable_debug_collision: bool = true
|
||||
|
||||
var _timer: Timer
|
||||
var _timer_started := false
|
||||
var _timer_started: bool = false
|
||||
|
||||
var _wait_physics_ticks_counter := 0
|
||||
var _wait_physics_ticks_counter: int = 0
|
||||
|
||||
class Circle2D:
|
||||
extends Node2D
|
||||
var center := Vector2()
|
||||
var radius := 0.0
|
||||
var radius: float = 0.0
|
||||
var color := Color()
|
||||
|
||||
func _draw() -> void:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
extends Node
|
||||
|
||||
var _tests := [
|
||||
var _tests: Array[Dictionary] = [
|
||||
{
|
||||
"id": "Functional Tests/Shapes",
|
||||
"path": "res://tests/functional/test_shapes.tscn",
|
||||
@@ -58,5 +58,5 @@ var _tests := [
|
||||
|
||||
func _ready() -> void:
|
||||
var test_menu: OptionMenu = $TestsMenu
|
||||
for test: Variant in _tests:
|
||||
for test: Dictionary in _tests:
|
||||
test_menu.add_test(test.id, test.path)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class_name TestCharacter
|
||||
extends Test
|
||||
|
||||
|
||||
enum BodyType {
|
||||
CHARACTER_BODY,
|
||||
CHARACTER_BODY_RAY,
|
||||
@@ -20,19 +21,19 @@ const OPTION_MOVE_CHARACTER_CONSTANT_SPEED = "Move Options/Use constant speed (C
|
||||
|
||||
@export var _initial_velocity := Vector2.ZERO
|
||||
@export var _constant_velocity := Vector2.ZERO
|
||||
@export var _motion_speed := 400.0
|
||||
@export var _gravity_force := 50.0
|
||||
@export var _jump_force := 1000.0
|
||||
@export var _snap_distance := 0.0
|
||||
@export var _floor_max_angle := 45.0
|
||||
@export var _motion_speed: float = 400.0
|
||||
@export var _gravity_force: float = 50.0
|
||||
@export var _jump_force: float = 1000.0
|
||||
@export var _snap_distance: float = 0.0
|
||||
@export var _floor_max_angle: float = 45.0
|
||||
@export var _body_type := BodyType.CHARACTER_BODY
|
||||
|
||||
@onready var options: OptionMenu = $Options
|
||||
|
||||
var _use_snap := true
|
||||
var _use_stop_on_slope := true
|
||||
var _use_floor_only := true
|
||||
var _use_constant_speed := false
|
||||
var _use_snap: bool = true
|
||||
var _use_stop_on_slope: bool = true
|
||||
var _use_floor_only: bool = true
|
||||
var _use_constant_speed: bool = false
|
||||
|
||||
var _body_parent: Node = null
|
||||
var _character_body_template: CharacterBody2D = null
|
||||
@@ -99,8 +100,8 @@ func _process(_delta: float) -> void:
|
||||
label_floor.visible = false
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
var key_event := event as InputEventKey
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
var key_event := input_event as InputEventKey
|
||||
if key_event and not key_event.pressed:
|
||||
if key_event.keycode == KEY_1:
|
||||
if _character_body_template:
|
||||
@@ -180,7 +181,7 @@ func _start_test() -> void:
|
||||
_moving_body.queue_free()
|
||||
_moving_body = null
|
||||
|
||||
var test_label := "Testing: "
|
||||
var test_label: String = "Testing: "
|
||||
|
||||
var template: PhysicsBody2D = null
|
||||
match _body_type:
|
||||
|
||||
@@ -7,12 +7,13 @@ const OPTION_TEST_CASE_DETECT_FLOOR_MOTION_CHANGES = "Test Cases/Floor detection
|
||||
const MOTION_CHANGES_DIR = Vector2(1.0, 1.0)
|
||||
const MOTION_CHANGES_SPEEDS: Array[float] = [0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0]
|
||||
|
||||
var _test_floor_detection := false
|
||||
var _test_motion_changes := false
|
||||
var _floor_detected := false
|
||||
var _floor_lost := false
|
||||
var _test_floor_detection: bool = false
|
||||
var _test_motion_changes: bool = false
|
||||
var _floor_detected: bool = false
|
||||
var _floor_lost: bool = false
|
||||
|
||||
var _failed_reason: String = ""
|
||||
|
||||
var _failed_reason := ""
|
||||
|
||||
func _ready() -> void:
|
||||
super._ready()
|
||||
@@ -42,11 +43,11 @@ func _physics_process(delta: float) -> void:
|
||||
#Log.print_log("Velocity: %s" % velocity)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
super._input(event)
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
super._input(input_event)
|
||||
|
||||
if event is InputEventKey and not event.pressed:
|
||||
if event.keycode == KEY_0:
|
||||
if input_event is InputEventKey and not input_event.pressed:
|
||||
if input_event.keycode == KEY_0:
|
||||
await _on_option_selected(OPTION_TEST_CASE_ALL)
|
||||
|
||||
|
||||
@@ -118,7 +119,7 @@ func _test_all() -> void:
|
||||
|
||||
|
||||
func _set_result(test_passed: bool) -> void:
|
||||
var result := ""
|
||||
var result: String = ""
|
||||
if test_passed:
|
||||
result = "PASSED"
|
||||
else:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends TestCharacter
|
||||
|
||||
|
||||
const OPTION_TEST_CASE_ALL = "Test Cases/TEST ALL (0)"
|
||||
const OPTION_TEST_CASE_JUMP_ONE_WAY_RIGID = "Test Cases/Jump through one-way tiles (Rigid Body)"
|
||||
const OPTION_TEST_CASE_JUMP_ONE_WAY_CHARACTER = "Test Cases/Jump through one-way tiles (Character Body)"
|
||||
@@ -7,13 +8,14 @@ const OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_RIGID = "Test Cases/Jump through one-
|
||||
const OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_CHARACTER = "Test Cases/Jump through one-way corner (Character Body)"
|
||||
const OPTION_TEST_CASE_FALL_ONE_WAY_CHARACTER = "Test Cases/Fall and pushed on one-way tiles (Character Body)"
|
||||
|
||||
var _test_jump_one_way := false
|
||||
var _test_jump_one_way_corner := false
|
||||
var _test_fall_one_way := false
|
||||
var _test_jump_one_way: bool = false
|
||||
var _test_jump_one_way_corner: bool = false
|
||||
var _test_fall_one_way: bool = false
|
||||
|
||||
var _extra_body: PhysicsBody2D = null
|
||||
|
||||
var _failed_reason := ""
|
||||
var _failed_reason: String = ""
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
super._ready()
|
||||
@@ -26,11 +28,11 @@ func _ready() -> void:
|
||||
options.add_menu_item(OPTION_TEST_CASE_FALL_ONE_WAY_CHARACTER)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
super._input(event)
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
super._input(input_event)
|
||||
|
||||
if event is InputEventKey and not event.pressed:
|
||||
if event.keycode == KEY_0:
|
||||
if input_event is InputEventKey and not input_event.pressed:
|
||||
if input_event.keycode == KEY_0:
|
||||
await _on_option_selected(OPTION_TEST_CASE_ALL)
|
||||
|
||||
|
||||
@@ -113,7 +115,7 @@ func _test_all() -> void:
|
||||
|
||||
|
||||
func _set_result(test_passed: bool) -> void:
|
||||
var result := ""
|
||||
var result: String = ""
|
||||
if test_passed:
|
||||
result = "PASSED"
|
||||
else:
|
||||
@@ -187,7 +189,7 @@ func _start_fall_one_way() -> void:
|
||||
|
||||
|
||||
func _finalize_jump_one_way() -> void:
|
||||
var passed := true
|
||||
var passed: bool = true
|
||||
if not $JumpTargetArea2D.overlaps_body(_moving_body):
|
||||
passed = false
|
||||
_failed_reason = ": the body wasn't able to jump all the way through."
|
||||
@@ -199,7 +201,7 @@ func _finalize_jump_one_way() -> void:
|
||||
|
||||
|
||||
func _finalize_fall_one_way() -> void:
|
||||
var passed := true
|
||||
var passed: bool = true
|
||||
if $FallTargetArea2D.overlaps_body(_moving_body):
|
||||
passed = false
|
||||
_failed_reason = ": the body was pushed through the one-way collision."
|
||||
|
||||
@@ -19,7 +19,7 @@ const OFFSET_RANGE = 120.0
|
||||
|
||||
@onready var options: OptionMenu = $Options
|
||||
|
||||
var _update_collision := false
|
||||
var _update_collision: bool = false
|
||||
var _collision_test_index := 0
|
||||
var _collision_shapes: Array[Shape2D] = []
|
||||
|
||||
@@ -50,8 +50,8 @@ func _ready() -> void:
|
||||
_update_collision = true
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
var key_event := event as InputEventKey
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
var key_event := input_event as InputEventKey
|
||||
if key_event and not key_event.pressed:
|
||||
if key_event.keycode == KEY_1:
|
||||
_on_option_selected(OPTION_TYPE_RECTANGLE)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Test
|
||||
|
||||
|
||||
const OPTION_JOINT_TYPE = "Joint Type/%s Joint (%d)"
|
||||
|
||||
const OPTION_TEST_CASE_BODIES_COLLIDE = "Test case/Attached bodies collide"
|
||||
@@ -10,27 +11,28 @@ const OPTION_TEST_CASE_CHANGE_POSITIONS = "Test case/Set body positions after ad
|
||||
|
||||
const BOX_SIZE = Vector2(64, 64)
|
||||
|
||||
var _update_joint := false
|
||||
var _update_joint: bool = false
|
||||
var _selected_joint: Joint2D = null
|
||||
|
||||
var _bodies_collide := false
|
||||
var _world_attachement := false
|
||||
var _dynamic_attachement := false
|
||||
var _destroy_body := false
|
||||
var _change_positions := false
|
||||
var _bodies_collide: bool = false
|
||||
var _world_attachement: bool = false
|
||||
var _dynamic_attachement: bool = false
|
||||
var _destroy_body: bool = false
|
||||
var _change_positions: bool = false
|
||||
|
||||
var _joint_types: Dictionary[String, Joint2D] = {}
|
||||
|
||||
var _joint_types := {}
|
||||
|
||||
func _ready() -> void:
|
||||
var options: OptionMenu = $Options
|
||||
|
||||
var joints: Node2D = $Joints
|
||||
for joint_index in joints.get_child_count():
|
||||
var joint_node := joints.get_child(joint_index)
|
||||
var joint_node: Joint2D = joints.get_child(joint_index)
|
||||
joint_node.visible = false
|
||||
var joint_name := String(joint_node.name)
|
||||
var joint_short := joint_name.substr(0, joint_name.length() - 7)
|
||||
var option_name := OPTION_JOINT_TYPE % [joint_short, joint_index + 1]
|
||||
var joint_short: String = joint_name.substr(0, joint_name.length() - 7)
|
||||
var option_name: String = OPTION_JOINT_TYPE % [joint_short, joint_index + 1]
|
||||
options.add_menu_item(option_name)
|
||||
_joint_types[option_name] = joint_node
|
||||
|
||||
@@ -54,9 +56,9 @@ func _process(_delta: float) -> void:
|
||||
$LabelJointType.text = "Joint Type: " + String(_selected_joint.name)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and not event.pressed:
|
||||
var joint_index: int = event.keycode - KEY_1
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventKey and not input_event.pressed:
|
||||
var joint_index: int = input_event.keycode - KEY_1
|
||||
if joint_index >= 0 and joint_index < _joint_types.size():
|
||||
_selected_joint = _joint_types.values()[joint_index]
|
||||
_update_joint = true
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@tool
|
||||
extends Test
|
||||
|
||||
|
||||
signal all_tests_done()
|
||||
signal test_done()
|
||||
|
||||
@@ -18,23 +19,23 @@ const OPTION_TEST_CASE_MOVING_PLATFORM_CHARACTER = "Test Cases/Moving Platform (
|
||||
const TEST_ALL_ANGLES_STEP = 15.0
|
||||
const TEST_ALL_ANGLES_MAX = 344.0
|
||||
|
||||
@export_range(64, 256, 0.1) var _platform_size := 128.0:
|
||||
@export_range(64, 256, 0.1) var _platform_size: float = 128.0:
|
||||
set(value):
|
||||
if value == _platform_size:
|
||||
return
|
||||
_platform_size = value
|
||||
_update_platform_size(value)
|
||||
|
||||
@export_range(0, 360, 0.1) var _platform_angle := 0.0:
|
||||
@export_range(0, 360, 0.1) var _platform_angle: float = 0.0:
|
||||
set(value):
|
||||
if value == _platform_angle:
|
||||
return
|
||||
_platform_angle = value
|
||||
_update_platform_angle(value)
|
||||
|
||||
@export var _platform_speed := 0.0
|
||||
@export var _platform_speed: float = 0.0
|
||||
|
||||
@export_range(0, 360, 0.1) var _body_angle := 0.0:
|
||||
@export_range(0, 360, 0.1) var _body_angle: float = 0.0:
|
||||
set(value):
|
||||
if value == _body_angle:
|
||||
return
|
||||
@@ -42,7 +43,7 @@ const TEST_ALL_ANGLES_MAX = 344.0
|
||||
_update_rigidbody_angle(value)
|
||||
|
||||
@export var _body_velocity := Vector2(400.0, 0.0)
|
||||
@export var _use_character_body := false
|
||||
@export var _use_character_body: bool = false
|
||||
|
||||
@onready var options: OptionMenu = $Options
|
||||
|
||||
@@ -56,15 +57,15 @@ var _platform_velocity := Vector2.ZERO
|
||||
|
||||
@onready var _target_area: Area2D = $TargetArea2D
|
||||
|
||||
var _contact_detected := false
|
||||
var _target_entered := false
|
||||
var _test_passed := false
|
||||
var _contact_detected: bool = false
|
||||
var _target_entered: bool = false
|
||||
var _test_passed: bool = false
|
||||
var _test_step := 0
|
||||
|
||||
var _test_all_angles := false
|
||||
var _lock_controls := false
|
||||
var _test_all_angles: bool = false
|
||||
var _lock_controls: bool = false
|
||||
|
||||
var _test_canceled := false
|
||||
var _test_canceled: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -124,13 +125,13 @@ func _physics_process(delta: float) -> void:
|
||||
_platform_body.global_position += motion
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and not event.pressed:
|
||||
if event.keycode == KEY_0:
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventKey and not input_event.pressed:
|
||||
if input_event.keycode == KEY_0:
|
||||
await _on_option_selected(OPTION_TEST_CASE_ALL)
|
||||
if event.keycode == KEY_1:
|
||||
if input_event.keycode == KEY_1:
|
||||
await _on_option_selected(OPTION_OBJECT_TYPE_RIGIDBODY)
|
||||
elif event.keycode == KEY_2:
|
||||
elif input_event.keycode == KEY_2:
|
||||
await _on_option_selected(OPTION_OBJECT_TYPE_CHARACTER)
|
||||
|
||||
|
||||
@@ -347,7 +348,7 @@ func _test_all() -> void:
|
||||
|
||||
|
||||
func _start_test() -> void:
|
||||
var test_label := "Testing: "
|
||||
var test_label: String = "Testing: "
|
||||
|
||||
var platform_angle := _platform_template.rotation
|
||||
if _platform_body:
|
||||
@@ -510,7 +511,7 @@ func _on_timeout() -> void:
|
||||
|
||||
|
||||
func _set_result() -> void:
|
||||
var result := ""
|
||||
var result: String = ""
|
||||
if _test_passed:
|
||||
result = "PASSED"
|
||||
$LabelResult.self_modulate = Color.GREEN
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
extends Test
|
||||
|
||||
@export_range(1, 100) var height := 10
|
||||
|
||||
@export_range(1, 100) var height: int = 10
|
||||
@export var box_size := Vector2(40.0, 40.0)
|
||||
@export var box_spacing := Vector2(0.0, 0.0)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_create_pyramid()
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
extends Test
|
||||
|
||||
|
||||
const OPTION_TEST_CASE_HIT_FROM_INSIDE = "Test case/Hit from inside"
|
||||
|
||||
var _hit_from_inside := false
|
||||
var _do_raycasts := false
|
||||
var _hit_from_inside: bool = false
|
||||
var _do_raycasts: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var options: OptionMenu = $Options
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
extends Test
|
||||
|
||||
@export var height := 10
|
||||
@export var width := 1
|
||||
|
||||
@export var height: int = 10
|
||||
@export var width: int = 1
|
||||
@export var box_size := Vector2(40.0, 40.0)
|
||||
@export var box_spacing := Vector2(0.0, 0.0)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_create_stack()
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ const BOX_SPACE = Vector2(50, 50)
|
||||
|
||||
var _objects: Array[Node2D] = []
|
||||
|
||||
var _log_physics := false
|
||||
var _log_physics: bool = false
|
||||
var _log_physics_time := 0
|
||||
var _log_physics_time_start := 0
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ const OPTION_TYPE_CONCAVE_POLYGON = "Shape type/Concave Polygon"
|
||||
|
||||
var _object_templates: Array[Node2D] = []
|
||||
|
||||
var _log_physics := false
|
||||
var _log_physics: bool = false
|
||||
var _log_physics_time := 0
|
||||
var _log_physics_time_start := 0
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ extends OptionMenu
|
||||
|
||||
|
||||
class TestData:
|
||||
var id := ""
|
||||
var scene_path := ""
|
||||
var id: String = ""
|
||||
var scene_path: String = ""
|
||||
|
||||
|
||||
var _test_list := []
|
||||
@@ -11,6 +11,7 @@ var _test_list := []
|
||||
var _current_test: TestData = null
|
||||
var _current_test_scene: Node = null
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
option_selected.connect(_on_option_selected)
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@ var _jump_force := 1000.0
|
||||
var _velocity := Vector2.ZERO
|
||||
var _snap := 0.0
|
||||
var _floor_max_angle := 45.0
|
||||
var _stop_on_slope := false
|
||||
var _move_on_floor_only := false
|
||||
var _constant_speed := false
|
||||
var _jumping := false
|
||||
var _keep_velocity := false
|
||||
var _stop_on_slope: bool = false
|
||||
var _move_on_floor_only: bool = false
|
||||
var _constant_speed: bool = false
|
||||
var _jumping: bool = false
|
||||
var _keep_velocity: bool = false
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
extends Label
|
||||
|
||||
func _ready() -> void:
|
||||
var engine_name := ""
|
||||
var engine_name: String = ""
|
||||
|
||||
match System.get_physics_engine():
|
||||
System.PhysicsEngine.GODOT_PHYSICS:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
extends Label
|
||||
|
||||
var test_name := "":
|
||||
var test_name: String = "":
|
||||
set(value):
|
||||
if (test_name != value):
|
||||
return
|
||||
|
||||
@@ -10,7 +10,7 @@ func add_menu_item(item_path: String, checkbox: bool = false, checked: bool = fa
|
||||
var path_element_count := path_elements.size()
|
||||
assert(path_element_count > 0)
|
||||
|
||||
var path := ""
|
||||
var path: String = ""
|
||||
var popup := get_popup()
|
||||
for element_index in range(path_element_count - 1):
|
||||
var popup_label := path_elements[element_index]
|
||||
|
||||
@@ -7,9 +7,9 @@ var _gravity_force := 50.0
|
||||
var _jump_force := 1000.0
|
||||
var _velocity := Vector2.ZERO
|
||||
var _floor_max_angle := 45.0
|
||||
var _on_floor := false
|
||||
var _jumping := false
|
||||
var _keep_velocity := false
|
||||
var _on_floor: bool = false
|
||||
var _jumping: bool = false
|
||||
var _keep_velocity: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
gravity_scale = 0.0
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
extends RigidBody2D
|
||||
|
||||
var _picked := false
|
||||
var _picked: bool = false
|
||||
var _last_mouse_pos := Vector2.ZERO
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@ func _ready() -> void:
|
||||
input_pickable = true
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
var mouse_event := event as InputEventMouseButton
|
||||
func _input(any_input_event: InputEvent) -> void:
|
||||
var mouse_event := any_input_event as InputEventMouseButton
|
||||
if mouse_event and not mouse_event.pressed:
|
||||
_picked = false
|
||||
|
||||
|
||||
func _input_event(_viewport: Node, event: InputEvent, _shape_idx: int) -> void:
|
||||
var mouse_event := event as InputEventMouseButton
|
||||
func _input_event(_viewport: Node, any_input_event: InputEvent, _shape_idx: int) -> void:
|
||||
var mouse_event := any_input_event as InputEventMouseButton
|
||||
if mouse_event and mouse_event.pressed:
|
||||
_picked = true
|
||||
_last_mouse_pos = get_global_mouse_position()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
extends ScrollContainer
|
||||
|
||||
@export var auto_scroll := false
|
||||
@export var auto_scroll: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
var scrollbar := get_v_scroll_bar()
|
||||
|
||||
@@ -5,8 +5,8 @@ extends Node
|
||||
@onready var _pause_menu := $InterfaceLayer/PauseMenu as PauseMenu
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"toggle_fullscreen"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"toggle_fullscreen"):
|
||||
var mode := DisplayServer.window_get_mode()
|
||||
if mode == DisplayServer.WINDOW_MODE_FULLSCREEN or \
|
||||
mode == DisplayServer.WINDOW_MODE_EXCLUSIVE_FULLSCREEN:
|
||||
@@ -15,7 +15,7 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
||||
get_tree().root.set_input_as_handled()
|
||||
|
||||
elif event.is_action_pressed(&"toggle_pause"):
|
||||
elif input_event.is_action_pressed(&"toggle_pause"):
|
||||
var tree := get_tree()
|
||||
tree.paused = not tree.paused
|
||||
if tree.paused:
|
||||
|
||||
@@ -12,7 +12,7 @@ const TERMINAL_VELOCITY = 700
|
||||
|
||||
## The player listens for input actions appended with this suffix.[br]
|
||||
## Used to separate controls for multiple players in splitscreen.
|
||||
@export var action_suffix := ""
|
||||
@export var action_suffix: String = ""
|
||||
|
||||
var gravity: int = ProjectSettings.get(&"physics/2d/default_gravity")
|
||||
@onready var platform_detector := $PlatformDetector as RayCast2D
|
||||
@@ -22,7 +22,7 @@ var gravity: int = ProjectSettings.get(&"physics/2d/default_gravity")
|
||||
@onready var jump_sound := $Jump as AudioStreamPlayer2D
|
||||
@onready var gun: Gun = sprite.get_node(^"Gun")
|
||||
@onready var camera := $Camera as Camera2D
|
||||
var _double_jump_charged := false
|
||||
var _double_jump_charged: bool = false
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
@@ -48,7 +48,7 @@ func _physics_process(delta: float) -> void:
|
||||
floor_stop_on_slope = not platform_detector.is_colliding()
|
||||
move_and_slide()
|
||||
|
||||
var is_shooting := false
|
||||
var is_shooting: bool = false
|
||||
if Input.is_action_just_pressed("shoot" + action_suffix):
|
||||
is_shooting = gun.shoot(sprite.scale.x)
|
||||
|
||||
@@ -59,7 +59,7 @@ func _physics_process(delta: float) -> void:
|
||||
animation_player.play(animation)
|
||||
|
||||
|
||||
func get_new_animation(is_shooting := false) -> String:
|
||||
func get_new_animation(is_shooting: bool = false) -> String:
|
||||
var animation_new: String
|
||||
if is_on_floor():
|
||||
if absf(velocity.x) > 0.1:
|
||||
|
||||
@@ -6,7 +6,7 @@ signal turn_finished
|
||||
@export var damage := 1
|
||||
@export var defense := 1
|
||||
|
||||
var active := false: set = set_active
|
||||
var active: bool = false: set = set_active
|
||||
|
||||
@onready var animation_playback: AnimationNodeStateMachinePlayback = $Sprite2D/AnimationTree.get(&"parameters/playback")
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ signal dialogue_finished
|
||||
|
||||
@export_file("*.json") var dialogue_file: String
|
||||
var dialogue_keys := []
|
||||
var dialogue_name := ""
|
||||
var dialogue_name: String = ""
|
||||
var current := 0
|
||||
var dialogue_text := ""
|
||||
var dialogue_text: String = ""
|
||||
|
||||
|
||||
func start_dialogue() -> void:
|
||||
|
||||
@@ -9,7 +9,7 @@ enum CellType {
|
||||
|
||||
@export var type := CellType.ACTOR
|
||||
|
||||
var active := true: set = set_active
|
||||
var active: bool = true: set = set_active
|
||||
|
||||
func set_active(value: bool) -> void:
|
||||
active = value
|
||||
|
||||
@@ -5,7 +5,7 @@ extends Pawn
|
||||
@export var combat_actor: PackedScene
|
||||
@export var pose_anims: SpriteFrames
|
||||
|
||||
var lost := false
|
||||
var lost: bool = false
|
||||
var grid_size: float
|
||||
|
||||
@onready var grid : Grid = get_parent()
|
||||
|
||||
@@ -16,8 +16,8 @@ const JUMP_VELOCITY = -400.0
|
||||
## Maximum speed at which the player can fall.
|
||||
const TERMINAL_VELOCITY = 400
|
||||
|
||||
var falling_slow := false
|
||||
var falling_fast := false
|
||||
var falling_slow: bool = false
|
||||
var falling_fast: bool = false
|
||||
var no_move_horizontal_time := 0.0
|
||||
|
||||
@onready var gravity := float(ProjectSettings.get_setting("physics/2d/default_gravity"))
|
||||
@@ -30,7 +30,7 @@ func _ready() -> void:
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var is_jumping := false
|
||||
var is_jumping: bool = false
|
||||
if Input.is_action_just_pressed(&"jump"):
|
||||
is_jumping = try_jump()
|
||||
elif Input.is_action_just_released(&"jump") and velocity.y < 0.0:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Node
|
||||
|
||||
|
||||
const ROT_SPEED = 0.003
|
||||
const ZOOM_SPEED = 0.125
|
||||
const MAIN_BUTTONS = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT | MOUSE_BUTTON_MASK_MIDDLE
|
||||
@@ -15,7 +16,7 @@ var camera_distance := 2.0
|
||||
@onready var camera: Camera3D = $CameraHolder/RotationX/Camera3D
|
||||
@onready var fps_label: Label = $FPSLabel
|
||||
|
||||
var is_compatibility := false
|
||||
var is_compatibility: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -41,22 +42,22 @@ func _ready() -> void:
|
||||
get_viewport().size_changed.connect(_on_viewport_size_changed)
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"ui_left"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"ui_left"):
|
||||
_on_previous_pressed()
|
||||
if event.is_action_pressed(&"ui_right"):
|
||||
if input_event.is_action_pressed(&"ui_right"):
|
||||
_on_next_pressed()
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
camera_distance -= ZOOM_SPEED
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
camera_distance += ZOOM_SPEED
|
||||
camera_distance = clamp(camera_distance, 1.5, 6)
|
||||
|
||||
if event is InputEventMouseMotion and event.button_mask & MAIN_BUTTONS:
|
||||
if input_event is InputEventMouseMotion and input_event.button_mask & MAIN_BUTTONS:
|
||||
# Use `screen_relative` to make mouse sensitivity independent of viewport resolution.
|
||||
var relative_motion: Vector2 = event.screen_relative
|
||||
var relative_motion: Vector2 = input_event.screen_relative
|
||||
rot_y -= relative_motion.x * ROT_SPEED
|
||||
rot_x -= relative_motion.y * ROT_SPEED
|
||||
rot_x = clamp(rot_x, -1.57, 0)
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
extends Node
|
||||
|
||||
|
||||
const ROT_SPEED = 0.003
|
||||
const ZOOM_SPEED = 0.125
|
||||
const MAIN_BUTTONS = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT | MOUSE_BUTTON_MASK_MIDDLE
|
||||
|
||||
var tester_index := 0
|
||||
var rot_x := -TAU / 16 # This must be kept in sync with RotationX.
|
||||
var rot_y := TAU / 8 # This must be kept in sync with CameraHolder.
|
||||
var camera_distance := 4.0
|
||||
var tester_index: int = 0
|
||||
var rot_x: float = -TAU / 16 # This must be kept in sync with RotationX.
|
||||
var rot_y: float = TAU / 8 # This must be kept in sync with CameraHolder.
|
||||
var camera_distance: float = 4.0
|
||||
|
||||
@onready var testers: Node3D = $Testers
|
||||
@onready var camera_holder: Node3D = $CameraHolder # Has a position and rotates on Y.
|
||||
@@ -29,22 +30,22 @@ func _ready() -> void:
|
||||
update_gui()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"ui_left"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"ui_left"):
|
||||
_on_previous_pressed()
|
||||
if event.is_action_pressed(&"ui_right"):
|
||||
if input_event.is_action_pressed(&"ui_right"):
|
||||
_on_next_pressed()
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
camera_distance -= ZOOM_SPEED
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
camera_distance += ZOOM_SPEED
|
||||
camera_distance = clamp(camera_distance, 1.5, 6)
|
||||
|
||||
if event is InputEventMouseMotion and event.button_mask & MAIN_BUTTONS:
|
||||
if input_event is InputEventMouseMotion and input_event.button_mask & MAIN_BUTTONS:
|
||||
# Use `screen_relative` to make mouse sensitivity independent of viewport resolution.
|
||||
var relative_motion: Vector2 = event.screen_relative
|
||||
var relative_motion: Vector2 = input_event.screen_relative
|
||||
rot_y -= relative_motion.x * ROT_SPEED
|
||||
rot_x -= relative_motion.y * ROT_SPEED
|
||||
rot_x = clamp(rot_x, -1.57, 0)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends WorldEnvironment
|
||||
|
||||
|
||||
const ROT_SPEED = 0.003
|
||||
const ZOOM_SPEED = 0.125
|
||||
const MAIN_BUTTONS = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT | MOUSE_BUTTON_MASK_MIDDLE
|
||||
@@ -14,19 +15,20 @@ var zoom := 1.5
|
||||
@onready var rotation_x: Node3D = $CameraHolder/RotationX
|
||||
@onready var camera: Camera3D = $CameraHolder/RotationX/Camera3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
camera_holder.transform.basis = Basis.from_euler(Vector3(0, rot_y, 0))
|
||||
rotation_x.transform.basis = Basis.from_euler(Vector3(rot_x, 0, 0))
|
||||
update_gui()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"ui_left"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"ui_left"):
|
||||
_on_previous_pressed()
|
||||
if event.is_action_pressed(&"ui_right"):
|
||||
if input_event.is_action_pressed(&"ui_right"):
|
||||
_on_next_pressed()
|
||||
|
||||
if event.is_action_pressed(&"place_decal"):
|
||||
if input_event.is_action_pressed(&"place_decal"):
|
||||
var origin := camera.global_position
|
||||
var target := camera.project_position(get_viewport().get_mouse_position(), 100)
|
||||
|
||||
@@ -40,16 +42,16 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
decal.position = result["position"]
|
||||
decal.transform.basis = camera.global_transform.basis
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
zoom -= ZOOM_SPEED
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
zoom += ZOOM_SPEED
|
||||
zoom = clampf(zoom, 1.5, 4)
|
||||
|
||||
if event is InputEventMouseMotion and event.button_mask & MAIN_BUTTONS:
|
||||
if input_event is InputEventMouseMotion and input_event.button_mask & MAIN_BUTTONS:
|
||||
# Use `screen_relative` to make mouse sensitivity independent of viewport resolution.
|
||||
var relative_motion: Vector2 = event.screen_relative
|
||||
var relative_motion: Vector2 = input_event.screen_relative
|
||||
rot_y -= relative_motion.x * ROT_SPEED
|
||||
rot_x -= relative_motion.y * ROT_SPEED
|
||||
rot_x = clampf(rot_x, deg_to_rad(-90), 0)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Camera3D
|
||||
|
||||
|
||||
const MOUSE_SENSITIVITY = 0.002
|
||||
const MOVE_SPEED = 1.5
|
||||
|
||||
@@ -10,16 +11,16 @@ func _ready() -> void:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
# Mouse look (only if the mouse is captured).
|
||||
if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
if input_event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
# Horizontal mouse look.
|
||||
rot.y -= event.screen_relative.x * MOUSE_SENSITIVITY
|
||||
rot.y -= input_event.screen_relative.x * MOUSE_SENSITIVITY
|
||||
# Vertical mouse look.
|
||||
rot.x = clamp(rot.x - event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
||||
rot.x = clamp(rot.x - input_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 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:
|
||||
|
||||
@@ -51,7 +51,7 @@ var gi_mode_texts: Array[String] = [
|
||||
var gi_mode := GIMode.NONE
|
||||
var reflection_probe_mode := ReflectionProbeMode.NONE
|
||||
var ssil_mode := SSILMode.NONE
|
||||
var is_compatibility := false
|
||||
var is_compatibility: bool = false
|
||||
|
||||
# This is replaced further below if using Compatibility to point to a newly created DirectionalLight3D
|
||||
# (which does not affect sky rendering).
|
||||
@@ -93,8 +93,8 @@ Escape or F10: Toggle mouse capture"""
|
||||
set_ssil_mode(ssil_mode)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"cycle_gi_mode"):
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_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 input_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 input_event.is_action_pressed(&"cycle_ssil_mode"):
|
||||
set_ssil_mode(wrapi(ssil_mode + 1, 0, SSILMode.MAX))
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ extends Control
|
||||
@onready var fps_label := $FPSLabel
|
||||
@onready var resolution_label := $ResolutionLabel
|
||||
|
||||
var counter := 0.0
|
||||
var counter: float = 0.0
|
||||
|
||||
# When the screen changes size, we need to update the 3D
|
||||
# viewport quality setting. If we don't do this, the viewport will take
|
||||
@@ -20,7 +20,7 @@ var viewport_start_size := Vector2(
|
||||
ProjectSettings.get_setting(&"display/window/size/viewport_height")
|
||||
)
|
||||
|
||||
var is_compatibility := false
|
||||
var is_compatibility: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
extends Node
|
||||
|
||||
|
||||
const ROT_SPEED = 0.003
|
||||
const ZOOM_SPEED = 0.125
|
||||
const MAIN_BUTTONS = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT | MOUSE_BUTTON_MASK_MIDDLE
|
||||
|
||||
var tester_index := 0
|
||||
var rot_x := -TAU / 16 # This must be kept in sync with RotationX.
|
||||
var rot_y := TAU / 8 # This must be kept in sync with CameraHolder.
|
||||
var camera_distance := 2.0
|
||||
var tester_index: int = 0
|
||||
var rot_x: float = -TAU / 16 # This must be kept in sync with RotationX.
|
||||
var rot_y: float = TAU / 8 # This must be kept in sync with CameraHolder.
|
||||
var camera_distance: float = 2.0
|
||||
|
||||
@onready var testers: Node3D = $Testers
|
||||
@onready var camera_holder: Node3D = $CameraHolder # Has a position and rotates on Y.
|
||||
@@ -21,25 +22,25 @@ func _ready() -> void:
|
||||
update_gui()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"ui_left"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"ui_left"):
|
||||
_on_previous_pressed()
|
||||
if event.is_action_pressed(&"ui_right"):
|
||||
if input_event.is_action_pressed(&"ui_right"):
|
||||
_on_next_pressed()
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
camera_distance -= ZOOM_SPEED
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
camera_distance += ZOOM_SPEED
|
||||
camera_distance = clamp(camera_distance, 1.5, 6)
|
||||
camera_distance = clampf(camera_distance, 1.5, 6.0)
|
||||
|
||||
if event is InputEventMouseMotion and event.button_mask & MAIN_BUTTONS:
|
||||
if input_event is InputEventMouseMotion and input_event.button_mask & MAIN_BUTTONS:
|
||||
# Use `screen_relative` to make mouse sensitivity independent of viewport resolution.
|
||||
var relative_motion: Vector2 = event.screen_relative
|
||||
var relative_motion: Vector2 = input_event.screen_relative
|
||||
rot_y -= relative_motion.x * ROT_SPEED
|
||||
rot_x -= relative_motion.y * ROT_SPEED
|
||||
rot_x = clamp(rot_x, -1.57, 0)
|
||||
rot_x = clampf(rot_x, -1.57, 0.0)
|
||||
camera_holder.transform.basis = Basis.from_euler(Vector3(0, rot_y, 0))
|
||||
rotation_x.transform.basis = Basis.from_euler(Vector3(rot_x, 0, 0))
|
||||
|
||||
@@ -54,12 +55,12 @@ func _process(delta: float) -> void:
|
||||
|
||||
|
||||
func _on_previous_pressed() -> void:
|
||||
tester_index = max(0, tester_index - 1)
|
||||
tester_index = maxi(0, tester_index - 1)
|
||||
update_gui()
|
||||
|
||||
|
||||
func _on_next_pressed() -> void:
|
||||
tester_index = min(tester_index + 1, testers.get_child_count() - 1)
|
||||
tester_index = mini(tester_index + 1, testers.get_child_count() - 1)
|
||||
update_gui()
|
||||
|
||||
|
||||
|
||||
@@ -56,8 +56,8 @@ func set_health(p_health: int) -> void:
|
||||
|
||||
# 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 := ""
|
||||
var bar_text: String = ""
|
||||
var bar_text_bg: String = ""
|
||||
for i in roundi((health / 100.0) * BAR_WIDTH):
|
||||
bar_text += "|"
|
||||
for i in BAR_WIDTH:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends WorldEnvironment
|
||||
|
||||
|
||||
const ROT_SPEED = 0.003
|
||||
const ZOOM_SPEED = 0.125
|
||||
const MAIN_BUTTONS = MOUSE_BUTTON_MASK_LEFT | MOUSE_BUTTON_MASK_RIGHT | MOUSE_BUTTON_MASK_MIDDLE
|
||||
@@ -21,22 +22,22 @@ func _ready() -> void:
|
||||
update_gui()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"ui_left"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"ui_left"):
|
||||
_on_previous_pressed()
|
||||
if event.is_action_pressed(&"ui_right"):
|
||||
if input_event.is_action_pressed(&"ui_right"):
|
||||
_on_next_pressed()
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
zoom -= ZOOM_SPEED
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
zoom += ZOOM_SPEED
|
||||
zoom = clamp(zoom, 1.5, 4)
|
||||
|
||||
if event is InputEventMouseMotion and event.button_mask & MAIN_BUTTONS:
|
||||
if input_event is InputEventMouseMotion and input_event.button_mask & MAIN_BUTTONS:
|
||||
# Use `screen_relative` to make mouse sensitivity independent of viewport resolution.
|
||||
var relative_motion: Vector2 = event.screen_relative
|
||||
var relative_motion: Vector2 = input_event.screen_relative
|
||||
rot_y -= relative_motion.x * ROT_SPEED
|
||||
rot_x -= relative_motion.y * ROT_SPEED
|
||||
rot_x = clamp(rot_x, deg_to_rad(-90), 0)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Node3D
|
||||
|
||||
|
||||
const INTERP_SPEED = 2
|
||||
const ROT_SPEED = 0.003
|
||||
const ZOOM_SPEED = 0.1
|
||||
@@ -26,6 +27,7 @@ var backgrounds: Array[Dictionary] = [
|
||||
@onready var rotation_x: Node3D = $CameraHolder/RotationX
|
||||
@onready var camera: Camera3D = $CameraHolder/RotationX/Camera
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if RenderingServer.get_current_rendering_method() == "gl_compatibility":
|
||||
# Tweak scene brightness to better match Forward+/Mobile.
|
||||
@@ -38,23 +40,23 @@ func _ready() -> void:
|
||||
update_gui()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"ui_left"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"ui_left"):
|
||||
_on_previous_pressed()
|
||||
if event.is_action_pressed(&"ui_right"):
|
||||
if input_event.is_action_pressed(&"ui_right"):
|
||||
_on_next_pressed()
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
zoom -= ZOOM_SPEED
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
zoom += ZOOM_SPEED
|
||||
zoom = clamp(zoom, 2, 8)
|
||||
camera.position.z = zoom
|
||||
|
||||
if event is InputEventMouseMotion and event.button_mask & MAIN_BUTTONS:
|
||||
if input_event is InputEventMouseMotion and input_event.button_mask & MAIN_BUTTONS:
|
||||
# Use `screen_relative` to make mouse sensitivity independent of viewport resolution.
|
||||
var relative_motion: Vector2 = event.screen_relative
|
||||
var relative_motion: Vector2 = input_event.screen_relative
|
||||
rot_y -= relative_motion.x * ROT_SPEED
|
||||
rot_y = clamp(rot_y, -1.95, 1.95)
|
||||
rot_x -= relative_motion.y * ROT_SPEED
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
extends Marker3D
|
||||
|
||||
@export var character_speed := 10.0
|
||||
@export var show_path := true
|
||||
@export var show_path: bool = true
|
||||
|
||||
var _nav_path_line: Line3D
|
||||
|
||||
@@ -33,7 +33,7 @@ func set_target_position(target_position: Vector3) -> void:
|
||||
# Get a full navigation path with the NavigationServer API.
|
||||
if show_path:
|
||||
var start_position := global_transform.origin
|
||||
var optimize := true
|
||||
var optimize: bool = true
|
||||
var navigation_map := get_world_3d().get_navigation_map()
|
||||
var path := NavigationServer3D.map_get_path(
|
||||
navigation_map,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Node3D
|
||||
|
||||
|
||||
const Character = preload("res://character.gd")
|
||||
|
||||
var _cam_rotation := 0.0
|
||||
@@ -7,10 +8,11 @@ var _cam_rotation := 0.0
|
||||
@onready var _camera := $CameraBase/Camera3D as Camera3D
|
||||
@onready var _robot := $RobotBase as Character
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
||||
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventMouseButton and input_event.button_index == MOUSE_BUTTON_LEFT and input_event.pressed:
|
||||
# Get closest point on navmesh for the current mouse cursor position.
|
||||
var mouse_cursor_position: Vector2 = event.position
|
||||
var mouse_cursor_position: Vector2 = input_event.position
|
||||
var camera_ray_length := 1000.0
|
||||
var camera_ray_start := _camera.project_ray_origin(mouse_cursor_position)
|
||||
var camera_ray_end := camera_ray_start + _camera.project_ray_normal(mouse_cursor_position) * camera_ray_length
|
||||
@@ -22,7 +24,7 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
)
|
||||
_robot.set_target_position(closest_point_on_navmesh)
|
||||
|
||||
elif event is InputEventMouseMotion:
|
||||
if event.button_mask & (MOUSE_BUTTON_MASK_MIDDLE + MOUSE_BUTTON_MASK_RIGHT):
|
||||
_cam_rotation -= event.screen_relative.x * 0.005
|
||||
elif input_event is InputEventMouseMotion:
|
||||
if input_event.button_mask & (MOUSE_BUTTON_MASK_MIDDLE + MOUSE_BUTTON_MASK_RIGHT):
|
||||
_cam_rotation -= input_event.screen_relative.x * 0.005
|
||||
$CameraBase.set_rotation(Vector3.UP * _cam_rotation)
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
extends Camera3D
|
||||
|
||||
|
||||
const MOUSE_SENSITIVITY = 0.002
|
||||
const MOVE_SPEED = 1.5
|
||||
|
||||
var rot := Vector3()
|
||||
var velocity := Vector3()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
# Mouse look (only if the mouse is captured).
|
||||
if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
if input_event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
# Horizontal mouse look.
|
||||
rot.y -= event.screen_relative.x * MOUSE_SENSITIVITY
|
||||
rot.y -= input_event.screen_relative.x * MOUSE_SENSITIVITY
|
||||
# Vertical mouse look.
|
||||
rot.x = clamp(rot.x - event.screen_relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
||||
rot.x = clamp(rot.x - input_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 input_event.is_action_pressed(&"toggle_mouse_capture"):
|
||||
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
else:
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
extends Node3D
|
||||
|
||||
var open := false
|
||||
var open: bool = false
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
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")
|
||||
open = false
|
||||
else:
|
||||
# Open the door.
|
||||
$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
|
||||
# position changed every frame, which causes the occlusion culling BVH
|
||||
# to be rebuilt each frame. This causes a CPU performance penalty.
|
||||
$OccluderInstance3D.visible = false
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if not input_event.is_action_pressed(&"toggle_doors"):
|
||||
return
|
||||
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")
|
||||
open = false
|
||||
else:
|
||||
# Open the door.
|
||||
$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
|
||||
# position changed every frame, which causes the occlusion culling BVH
|
||||
# to be rebuilt each frame. This causes a CPU performance penalty.
|
||||
$OccluderInstance3D.visible = false
|
||||
|
||||
|
||||
func _on_animation_player_animation_finished(_anim_name: StringName) -> void:
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
extends Node3D
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"toggle_occlusion_culling"):
|
||||
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_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 input_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 input_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 input_event.is_action_pressed(&"toggle_vsync"):
|
||||
if DisplayServer.window_get_vsync_mode() == DisplayServer.VSYNC_DISABLED:
|
||||
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED)
|
||||
else:
|
||||
|
||||
@@ -20,22 +20,22 @@ func _ready() -> void:
|
||||
update_gui()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"ui_left"):
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event.is_action_pressed(&"ui_left"):
|
||||
_on_previous_pressed()
|
||||
if event.is_action_pressed(&"ui_right"):
|
||||
if input_event.is_action_pressed(&"ui_right"):
|
||||
_on_next_pressed()
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
zoom -= ZOOM_SPEED
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
if input_event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
zoom += ZOOM_SPEED
|
||||
zoom = clamp(zoom, 1.5, 4)
|
||||
|
||||
if event is InputEventMouseMotion and event.button_mask & MAIN_BUTTONS:
|
||||
if input_event is InputEventMouseMotion and input_event.button_mask & MAIN_BUTTONS:
|
||||
# Use `screen_relative` to make mouse sensitivity independent of viewport resolution.
|
||||
var relative_motion: Vector2 = event.screen_relative
|
||||
var relative_motion: Vector2 = input_event.screen_relative
|
||||
rot_y -= relative_motion.x * ROT_SPEED
|
||||
rot_x -= relative_motion.y * ROT_SPEED
|
||||
rot_x = clamp(rot_x, deg_to_rad(-90), 0)
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
extends Control
|
||||
|
||||
|
||||
@export var sun: DirectionalLight3D
|
||||
@export var lightbulb_1: OmniLight3D
|
||||
@export var lightbulb_2: OmniLight3D
|
||||
@export var world_environment: WorldEnvironment
|
||||
|
||||
|
||||
## Returns color from a given temperature in kelvins (6500K is nearly white).
|
||||
## Valid range is [1000; 15000].
|
||||
## As explained in the Filament documentation:
|
||||
|
||||
@@ -45,10 +45,10 @@ func _ready() -> void:
|
||||
cycle_camera_type()
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseMotion:
|
||||
_yaw -= event.screen_relative.x * MOUSE_SENSITIVITY * 0.001
|
||||
_pitch += event.screen_relative.y * MOUSE_SENSITIVITY * 0.002
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventMouseMotion:
|
||||
_yaw -= input_event.screen_relative.x * MOUSE_SENSITIVITY * 0.001
|
||||
_pitch += input_event.screen_relative.y * MOUSE_SENSITIVITY * 0.002
|
||||
_pitch = clamp(_pitch, -PI, PI)
|
||||
$Rig.rotation = Vector3(0, _yaw, 0)
|
||||
|
||||
|
||||
@@ -96,10 +96,10 @@ character_jump={
|
||||
[physics]
|
||||
|
||||
3d/physics_engine="Jolt Physics"
|
||||
jolt_physics_3d/limits/temporary_memory_buffer_size=128
|
||||
jolt_physics_3d/limits/temporary_memory_buffer_size=256
|
||||
jolt_physics_3d/limits/max_bodies=262144
|
||||
jolt_physics_3d/limits/max_body_pairs=262144
|
||||
jolt_physics_3d/limits/max_contact_constraints=262144
|
||||
jolt_physics_3d/limits/max_contact_constraints=524288
|
||||
common/physics_interpolation=true
|
||||
|
||||
[rendering]
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
class_name Test
|
||||
extends Node
|
||||
|
||||
|
||||
signal wait_done()
|
||||
|
||||
@export var _enable_debug_collision := true
|
||||
@export var _enable_debug_collision: bool = true
|
||||
|
||||
var _timer: Timer
|
||||
var _timer_started := false
|
||||
var _timer_started: bool = false
|
||||
|
||||
var _wait_physics_ticks_counter := 0
|
||||
var _wait_physics_ticks_counter: int = 0
|
||||
|
||||
var _drawn_nodes: Array[Node3D] = []
|
||||
|
||||
|
||||
func _enter_tree() -> void:
|
||||
if not _enable_debug_collision:
|
||||
get_tree().debug_collisions_hint = false
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Test
|
||||
|
||||
|
||||
const OPTION_TYPE_BOX = "Collision type/Box (1)"
|
||||
const OPTION_TYPE_SPHERE = "Collision type/Sphere (2)"
|
||||
const OPTION_TYPE_CAPSULE = "Collision type/Capsule (3)"
|
||||
@@ -17,10 +18,11 @@ const OFFSET_RANGE = 3.0
|
||||
|
||||
@export var offset := Vector3.ZERO
|
||||
|
||||
var _update_collision := false
|
||||
var _collision_test_index := 0
|
||||
var _update_collision: bool = false
|
||||
var _collision_test_index: int = 0
|
||||
var _collision_shapes: Array[Shape3D] = []
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_initialize_collision_shapes()
|
||||
|
||||
@@ -47,17 +49,17 @@ func _ready() -> void:
|
||||
_update_collision = true
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and event.pressed:
|
||||
if event.keycode == KEY_1:
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventKey and input_event.pressed:
|
||||
if input_event.keycode == KEY_1:
|
||||
_on_option_selected(OPTION_TYPE_BOX)
|
||||
elif event.keycode == KEY_2:
|
||||
elif input_event.keycode == KEY_2:
|
||||
_on_option_selected(OPTION_TYPE_SPHERE)
|
||||
elif event.keycode == KEY_3:
|
||||
elif input_event.keycode == KEY_3:
|
||||
_on_option_selected(OPTION_TYPE_CAPSULE)
|
||||
elif event.keycode == KEY_4:
|
||||
elif input_event.keycode == KEY_4:
|
||||
_on_option_selected(OPTION_TYPE_CYLINDER)
|
||||
elif event.keycode == KEY_5:
|
||||
elif input_event.keycode == KEY_5:
|
||||
_on_option_selected(OPTION_TYPE_CONVEX_POLYGON)
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Test
|
||||
|
||||
|
||||
const OPTION_JOINT_TYPE = "Joint Type/%s Joint (%d)"
|
||||
|
||||
const OPTION_TEST_CASE_BODIES_COLLIDE = "Test case/Attached bodies collide"
|
||||
@@ -10,27 +11,28 @@ const OPTION_TEST_CASE_CHANGE_POSITIONS = "Test case/Set body positions after ad
|
||||
|
||||
const BOX_SIZE = Vector3(1.0, 1.0, 1.0)
|
||||
|
||||
var _update_joint := false
|
||||
var _update_joint: bool = false
|
||||
var _selected_joint: Joint3D
|
||||
|
||||
var _bodies_collide := false
|
||||
var _world_attachement := false
|
||||
var _dynamic_attachement := false
|
||||
var _destroy_body := false
|
||||
var _change_positions := false
|
||||
var _bodies_collide: bool = false
|
||||
var _world_attachement: bool = false
|
||||
var _dynamic_attachement: bool = false
|
||||
var _destroy_body: bool = false
|
||||
var _change_positions: bool = false
|
||||
|
||||
var _joint_types: Dictionary[String, Joint3D] = {}
|
||||
|
||||
var _joint_types := {}
|
||||
|
||||
func _ready() -> void:
|
||||
var options: OptionMenu = $Options
|
||||
|
||||
var joints: Node3D = $Joints
|
||||
for joint_index in joints.get_child_count():
|
||||
var joint_node := joints.get_child(joint_index)
|
||||
var joint_node: Joint3D = joints.get_child(joint_index)
|
||||
joint_node.visible = false
|
||||
var joint_name := String(joint_node.name)
|
||||
var joint_short := joint_name.substr(0, joint_name.length() - 5)
|
||||
var option_name := OPTION_JOINT_TYPE % [joint_short, joint_index + 1]
|
||||
var joint_short: String = joint_name.substr(0, joint_name.length() - 5)
|
||||
var option_name: String = OPTION_JOINT_TYPE % [joint_short, joint_index + 1]
|
||||
options.add_menu_item(option_name)
|
||||
_joint_types[option_name] = joint_node
|
||||
|
||||
@@ -54,9 +56,9 @@ func _process(_delta: float) -> void:
|
||||
$LabelJointType.text = "Joint Type: " + String(_selected_joint.name)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and event.pressed:
|
||||
var joint_index: int = event.keycode - KEY_1
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventKey and input_event.pressed:
|
||||
var joint_index: int = input_event.keycode - KEY_1
|
||||
if joint_index >= 0 and joint_index < _joint_types.size():
|
||||
_selected_joint = _joint_types.values()[joint_index]
|
||||
_update_joint = true
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Test
|
||||
|
||||
|
||||
const OPTION_BODY_TYPE = "Body Type/%s (%d)"
|
||||
|
||||
const OPTION_SLOPE = "Physics options/Stop on slope (Character only)"
|
||||
@@ -14,21 +15,22 @@ const SHAPE_CYLINDER = "Collision shapes/Cylinder"
|
||||
const SHAPE_SPHERE = "Collision shapes/Sphere"
|
||||
const SHAPE_CONVEX = "Collision shapes/Convex"
|
||||
|
||||
var _slope := false
|
||||
var _snap := false
|
||||
var _friction := false
|
||||
var _rough := false
|
||||
var _animation_physics := false
|
||||
var _slope: bool = false
|
||||
var _snap: bool = false
|
||||
var _friction: bool = false
|
||||
var _rough: bool = false
|
||||
var _animation_physics: bool = false
|
||||
|
||||
var _body_scene := {}
|
||||
var _key_list := []
|
||||
var _current_body_index := 0
|
||||
var _current_body_key := ""
|
||||
var _current_body_key: String = ""
|
||||
var _current_body: PhysicsBody3D = null
|
||||
var _body_type := ["CharacterBody3D", "RigidBody"]
|
||||
|
||||
var _shapes := {}
|
||||
var _current_shape := ""
|
||||
var _current_shape: String = ""
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var options: OptionMenu = $Options
|
||||
@@ -66,9 +68,9 @@ func _ready() -> void:
|
||||
spawn_body_index(_current_body_index)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and not event.pressed:
|
||||
var _index: int = event.keycode - KEY_1
|
||||
func _input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventKey and not input_event.pressed:
|
||||
var _index: int = input_event.keycode - KEY_1
|
||||
if _index >= 0 and _index < _key_list.size():
|
||||
spawn_body_index(_index)
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
extends Test
|
||||
|
||||
@export_range(1, 100) var height := 10
|
||||
@export_range(1, 100) var width_max := 100
|
||||
@export_range(1, 100) var depth_max := 1
|
||||
|
||||
@export_range(1, 100) var height: int = 10
|
||||
@export_range(1, 100) var width_max: int = 100
|
||||
@export_range(1, 100) var depth_max: int = 1
|
||||
@export var box_size := Vector3(1.0, 1.0, 1.0)
|
||||
@export var box_spacing := Vector3(0.0, 0.0, 0.0)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_create_pyramid()
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
extends Test
|
||||
|
||||
|
||||
const OPTION_TEST_CASE_HIT_FROM_INSIDE = "Test case/Hit from inside"
|
||||
|
||||
var _hit_from_inside := false
|
||||
var _do_raycasts := false
|
||||
var _hit_from_inside: bool = false
|
||||
var _do_raycasts: bool = false
|
||||
|
||||
@onready var _raycast_visuals := ImmediateMesh.new()
|
||||
@onready var _material := StandardMaterial3D.new()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Test
|
||||
|
||||
|
||||
const OPTION_BIG = "Floor options/Big"
|
||||
const OPTION_SMALL = "Floor options/Small"
|
||||
|
||||
@@ -8,13 +9,14 @@ const SHAPE_CONVEX = "Collision shapes/Convex"
|
||||
const SHAPE_BOX = "Collision shapes/Box"
|
||||
|
||||
var _dynamic_shapes_scene: PackedScene
|
||||
var _floor_shapes := {}
|
||||
var _floor_size := "Small"
|
||||
var _floor_shapes: Dictionary[String, PackedScene] = {}
|
||||
var _floor_size: String = "Small"
|
||||
|
||||
var _current_floor_name := SHAPE_CONCAVE
|
||||
var _current_bodies: Node3D
|
||||
var _current_floor: Node3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var options: OptionMenu = $Options
|
||||
_dynamic_shapes_scene = get_packed_scene($DynamicShapes/Bodies)
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
extends Test
|
||||
|
||||
@export_range(1, 100) var height := 10
|
||||
@export_range(1, 100) var width := 1
|
||||
@export_range(1, 100) var depth := 1
|
||||
|
||||
@export_range(1, 100) var height: int = 10
|
||||
@export_range(1, 100) var width: int = 1
|
||||
@export_range(1, 100) var depth: int = 1
|
||||
@export var box_size := Vector3(1.0, 1.0, 1.0)
|
||||
@export var box_spacing := Vector3(0.0, 0.0, 0.0)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_create_stack()
|
||||
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
extends Test
|
||||
|
||||
|
||||
const BOX_SIZE = Vector3(0.8, 0.8, 0.8)
|
||||
const BOX_SPACE = Vector3(1.0, 1.0, 1.0)
|
||||
|
||||
@export_range(1, 1000) var row_size := 20
|
||||
@export_range(1, 1000) var column_size := 20
|
||||
@export_range(1, 1000) var depth_size := 20
|
||||
@export_range(1, 1000) var row_size: int = 20
|
||||
@export_range(1, 1000) var column_size: int = 20
|
||||
@export_range(1, 1000) var depth_size: int = 20
|
||||
|
||||
var _objects: Array[Node3D] = []
|
||||
|
||||
var _log_physics := false
|
||||
var _log_physics_time := 0
|
||||
var _log_physics_time_start := 0
|
||||
var _log_physics: bool = false
|
||||
var _log_physics_time_usec: int = 0
|
||||
var _log_physics_time_usec_start: int = 0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
await start_timer(1.0).timeout
|
||||
@@ -75,16 +77,16 @@ func _physics_process(delta: float) -> void:
|
||||
|
||||
if _log_physics:
|
||||
var time := Time.get_ticks_usec()
|
||||
var time_delta := time - _log_physics_time
|
||||
var time_total := time - _log_physics_time_start
|
||||
_log_physics_time = time
|
||||
var time_delta := time - _log_physics_time_usec
|
||||
var time_total := time - _log_physics_time_usec_start
|
||||
_log_physics_time_usec = time
|
||||
Log.print_log(" Physics Tick: %.3f ms (total = %.3f ms)" % [0.001 * time_delta, 0.001 * time_total])
|
||||
|
||||
|
||||
func _log_physics_start() -> void:
|
||||
_log_physics = true
|
||||
_log_physics_time_start = Time.get_ticks_usec()
|
||||
_log_physics_time = _log_physics_time_start
|
||||
_log_physics_time_usec_start = Time.get_ticks_usec()
|
||||
_log_physics_time_usec = _log_physics_time_usec_start
|
||||
|
||||
|
||||
func _log_physics_stop() -> void:
|
||||
|
||||
@@ -8,14 +8,14 @@ const OPTION_TYPE_CYLINDER = "Shape type/Cylinder"
|
||||
const OPTION_TYPE_CONVEX = "Shape type/Convex"
|
||||
|
||||
@export var spawns: Array[NodePath] = []
|
||||
@export var spawn_count := 100
|
||||
@export var spawn_count: int = 100
|
||||
@export var spawn_randomize := Vector3.ZERO
|
||||
|
||||
var _object_templates: Array[Node3D] = []
|
||||
|
||||
var _log_physics := false
|
||||
var _log_physics_time := 0
|
||||
var _log_physics_time_start := 0
|
||||
var _log_physics: bool = false
|
||||
var _log_physics_time_usec: int = 0
|
||||
var _log_physics_time_usec_start: int = 0
|
||||
|
||||
func _ready() -> void:
|
||||
await start_timer(0.5).timeout
|
||||
@@ -48,16 +48,16 @@ func _physics_process(delta: float) -> void:
|
||||
|
||||
if _log_physics:
|
||||
var time := Time.get_ticks_usec()
|
||||
var time_delta := time - _log_physics_time
|
||||
var time_total := time - _log_physics_time_start
|
||||
_log_physics_time = time
|
||||
var time_delta := time - _log_physics_time_usec
|
||||
var time_total := time - _log_physics_time_usec_start
|
||||
_log_physics_time_usec = time
|
||||
Log.print_log(" Physics Tick: %.3f ms (total = %.3f ms)" % [0.001 * time_delta, 0.001 * time_total])
|
||||
|
||||
|
||||
func _log_physics_start() -> void:
|
||||
_log_physics = true
|
||||
_log_physics_time_start = Time.get_ticks_usec()
|
||||
_log_physics_time = _log_physics_time_start
|
||||
_log_physics_time_usec_start = Time.get_ticks_usec()
|
||||
_log_physics_time_usec = _log_physics_time_usec_start
|
||||
|
||||
|
||||
func _log_physics_stop() -> void:
|
||||
|
||||
@@ -2,8 +2,8 @@ extends OptionMenu
|
||||
|
||||
|
||||
class TestData:
|
||||
var id := ""
|
||||
var scene_path := ""
|
||||
var id: String = ""
|
||||
var scene_path: String = ""
|
||||
|
||||
|
||||
var _test_list: Array[TestData] = []
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
extends Camera3D
|
||||
|
||||
|
||||
const ROTATION_COEFF = 0.02
|
||||
|
||||
var _rotation_enabled := false
|
||||
var _rotation_enabled: bool = false
|
||||
var _rotation_pivot: Node3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_initialize_pivot.call_deferred()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_RIGHT:
|
||||
_rotation_enabled = event.pressed
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_RIGHT:
|
||||
_rotation_enabled = input_event.pressed
|
||||
|
||||
return
|
||||
|
||||
if not _rotation_enabled:
|
||||
return
|
||||
|
||||
if event is InputEventMouseMotion:
|
||||
var rotation_delta: float = event.screen_relative.x
|
||||
if input_event is InputEventMouseMotion:
|
||||
var rotation_delta: float = input_event.screen_relative.x
|
||||
_rotation_pivot.rotate(Vector3.UP, -rotation_delta * ROTATION_COEFF)
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
@export var _stop_on_slopes := false
|
||||
@export var use_snap := false
|
||||
|
||||
var _gravity := 20.0
|
||||
@export var _stop_on_slopes: bool = false
|
||||
@export var use_snap: bool = false
|
||||
|
||||
var _gravity: float = 20.0
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if is_on_floor():
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Control
|
||||
|
||||
|
||||
const MAX_ENTRIES = 100
|
||||
|
||||
var _entry_template: Label
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
extends Control
|
||||
|
||||
|
||||
@export var world_offset := Vector3.ZERO
|
||||
|
||||
var _pos_offset: Vector2
|
||||
var _attachment: Node3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_pos_offset = position
|
||||
_attachment = get_parent()
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
extends Label
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var engine_name := ""
|
||||
var engine_name: String = ""
|
||||
match System.get_physics_engine():
|
||||
System.PhysicsEngine.GODOT_PHYSICS:
|
||||
engine_name = "GodotPhysics 3D"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
extends Label
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
text = "%d FPS (%.2f mspf)" % [Engine.get_frames_per_second(), 1000.0 / Engine.get_frames_per_second()]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
extends Label
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
visible = get_tree().paused
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
extends Label
|
||||
|
||||
var test_name := "":
|
||||
|
||||
var test_name: String = "":
|
||||
set(value):
|
||||
if (test_name != value):
|
||||
return
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
extends Label
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
set_text("Godot Version: %s" % Engine.get_version_info().string)
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
class_name OptionMenu
|
||||
extends MenuButton
|
||||
|
||||
|
||||
signal option_selected(item_path: String)
|
||||
signal option_changed(item_path: String, checked: bool)
|
||||
|
||||
|
||||
func add_menu_item(item_path: String, checkbox: bool = false, checked: bool = false) -> void:
|
||||
var path_elements := item_path.split("/", false)
|
||||
var path_element_count := path_elements.size()
|
||||
assert(path_element_count > 0)
|
||||
|
||||
var path := ""
|
||||
var path: String = ""
|
||||
var popup := get_popup()
|
||||
for element_index in path_element_count - 1:
|
||||
var popup_label := path_elements[element_index]
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
extends RigidBody3D
|
||||
|
||||
var _dir := 1.0
|
||||
var _distance := 10.0
|
||||
var _walk_spd := 100.0
|
||||
var _acceleration := 22.0
|
||||
var _is_on_floor := false
|
||||
|
||||
var _dir: float = 1.0 # -1.0 or 1.0
|
||||
var _distance: float = 10.0
|
||||
var _walk_spd: float = 100.0
|
||||
var _acceleration: float = 22.0
|
||||
var _is_on_floor: bool = false
|
||||
|
||||
@onready var _forward := -transform.basis.z
|
||||
@onready var _collision_shape := $CollisionShape
|
||||
@onready var _material: StandardMaterial3D = $CollisionShape/MeshInstance3D.get_active_material(0)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if not _material:
|
||||
_material = StandardMaterial3D.new()
|
||||
@@ -24,20 +26,20 @@ func _process(_delta: float) -> void:
|
||||
|
||||
|
||||
func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
|
||||
var delta := state.step
|
||||
var velocity := (_forward * _dir * _walk_spd * delta) + (state.linear_velocity * Vector3.UP)
|
||||
var delta: float = state.step
|
||||
var velocity := (_forward * _dir * _walk_spd * delta) + (state.linear_velocity * Vector3.UP)
|
||||
state.linear_velocity = state.linear_velocity.move_toward(velocity, _acceleration * delta)
|
||||
|
||||
if state.transform.origin.z < -_distance:
|
||||
_dir = -1
|
||||
_dir = -1.0
|
||||
if state.transform.origin.z > _distance:
|
||||
_dir = 1
|
||||
_dir = 1.0
|
||||
|
||||
ground_check()
|
||||
|
||||
|
||||
func ground_check() -> void:
|
||||
var space_state := get_world_3d().direct_space_state
|
||||
var space_state: PhysicsDirectSpaceState3D = get_world_3d().direct_space_state
|
||||
var shape := PhysicsShapeQueryParameters3D.new()
|
||||
shape.transform = _collision_shape.global_transform
|
||||
shape.shape_rid = _collision_shape.shape.get_rid()
|
||||
|
||||
@@ -1,30 +1,32 @@
|
||||
extends RigidBody3D
|
||||
|
||||
const MOUSE_DELTA_COEFFICIENT = 0.01
|
||||
const CAMERA_DISTANCE_COEFFICIENT = 0.2
|
||||
|
||||
var _picked := false
|
||||
const MOUSE_DELTA_COEFFICIENT: float = 0.01
|
||||
const CAMERA_DISTANCE_COEFFICIENT: float = 0.2
|
||||
|
||||
var _picked: bool = false
|
||||
var _last_mouse_pos := Vector2.ZERO
|
||||
var _mouse_pos := Vector2.ZERO
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
input_ray_pickable = true
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
if not event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
func _input(any_input_event: InputEvent) -> void:
|
||||
if any_input_event is InputEventMouseButton:
|
||||
if not any_input_event.pressed and any_input_event.button_index == MOUSE_BUTTON_LEFT:
|
||||
_picked = false
|
||||
|
||||
if event is InputEventMouseMotion:
|
||||
_mouse_pos = event.position
|
||||
if any_input_event is InputEventMouseMotion:
|
||||
_mouse_pos = any_input_event.position
|
||||
|
||||
|
||||
func _input_event(_camera: Camera3D, event: InputEvent, _position: Vector3, _normal: Vector3, _shape_idx: int) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
if event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
func _input_event(_camera: Camera3D, any_input_event: InputEvent, _position: Vector3, _normal: Vector3, _shape_idx: int) -> void:
|
||||
if any_input_event is InputEventMouseButton:
|
||||
if any_input_event.pressed and any_input_event.button_index == MOUSE_BUTTON_LEFT:
|
||||
_picked = true
|
||||
_mouse_pos = event.position
|
||||
_mouse_pos = any_input_event.position
|
||||
_last_mouse_pos = _mouse_pos
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
extends ScrollContainer
|
||||
|
||||
@export var auto_scroll := false
|
||||
|
||||
@export var auto_scroll: bool = false
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if auto_scroll:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Node
|
||||
|
||||
|
||||
enum PhysicsEngine {
|
||||
GODOT_PHYSICS,
|
||||
JOLT_PHYSICS,
|
||||
@@ -8,6 +9,7 @@ enum PhysicsEngine {
|
||||
|
||||
var _engine := PhysicsEngine.OTHER
|
||||
|
||||
|
||||
func _enter_tree() -> void:
|
||||
process_mode = Node.PROCESS_MODE_ALWAYS
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
extends Node
|
||||
|
||||
|
||||
enum LogType {
|
||||
LOG,
|
||||
ERROR,
|
||||
@@ -7,6 +8,7 @@ enum LogType {
|
||||
|
||||
signal entry_logged(message: String, type: LogType)
|
||||
|
||||
|
||||
func print_log(message: String) -> void:
|
||||
print(message)
|
||||
entry_logged.emit(message, LogType.LOG)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
extends Area3D
|
||||
|
||||
var taken := false
|
||||
|
||||
var taken: bool = false
|
||||
|
||||
|
||||
func _on_coin_body_enter(body: Node) -> void:
|
||||
if not taken and body is Player:
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
extends RigidBody3D
|
||||
|
||||
const ACCEL = 5.0
|
||||
const DEACCEL = 20.0
|
||||
const MAX_SPEED = 2.0
|
||||
const ROT_SPEED = 1.0
|
||||
|
||||
var prev_advance := false
|
||||
var dying := false
|
||||
var rot_dir := 4
|
||||
const ACCEL: float = 5.0
|
||||
const DEACCEL: float = 20.0
|
||||
const MAX_SPEED: float = 2.0
|
||||
const ROT_SPEED: float = 1.0
|
||||
|
||||
var prev_advance: bool = false
|
||||
var dying: bool = false
|
||||
var rot_dir: float = 4.0
|
||||
|
||||
@onready var gravity := Vector3(
|
||||
ProjectSettings.get_setting("physics/3d/default_gravity") * ProjectSettings.get_setting("physics/3d/default_gravity_vector")
|
||||
@@ -17,6 +18,7 @@ var rot_dir := 4
|
||||
@onready var _ray_floor := $Enemy/Skeleton/RayFloor as RayCast3D
|
||||
@onready var _ray_wall := $Enemy/Skeleton/RayWall as RayCast3D
|
||||
|
||||
|
||||
func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
|
||||
var delta := state.get_step()
|
||||
var lin_velocity := state.get_linear_velocity()
|
||||
@@ -51,10 +53,10 @@ func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
|
||||
$SoundHit.play()
|
||||
return
|
||||
|
||||
var advance := _ray_floor.is_colliding() and not _ray_wall.is_colliding()
|
||||
var advance: bool = _ray_floor.is_colliding() and not _ray_wall.is_colliding()
|
||||
|
||||
var dir := ($Enemy/Skeleton as Node3D).get_transform().basis[2].normalized()
|
||||
var deaccel_dir := dir
|
||||
var dir: Vector3 = ($Enemy/Skeleton as Node3D).get_transform().basis.z.normalized()
|
||||
var deaccel_dir: Vector3 = dir
|
||||
|
||||
if advance:
|
||||
if dir.dot(lin_velocity) < MAX_SPEED:
|
||||
@@ -67,7 +69,7 @@ func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
|
||||
dir = Basis(up, rot_dir * ROT_SPEED * (delta)) * dir
|
||||
$Enemy/Skeleton.set_transform(Transform3D().looking_at(-dir, up))
|
||||
|
||||
var dspeed := deaccel_dir.dot(lin_velocity)
|
||||
var dspeed: float = deaccel_dir.dot(lin_velocity)
|
||||
dspeed -= DEACCEL * delta
|
||||
if dspeed < 0:
|
||||
dspeed = 0
|
||||
|
||||
@@ -3,4 +3,4 @@ extends RigidBody3D
|
||||
|
||||
## If `true`, the bullet can hit enemies. This is set to `false` when the bullet
|
||||
## hits an enemy so it can't hit an enemy multiple times while the bullet is fading out.
|
||||
var enabled := true
|
||||
var enabled: bool = true
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
extends Camera3D
|
||||
|
||||
|
||||
const MAX_HEIGHT = 2.0
|
||||
const MIN_HEIGHT = 0.0
|
||||
|
||||
var collision_exception: Array[RID] = []
|
||||
|
||||
@export var min_distance := 0.5
|
||||
@export var max_distance := 3.5
|
||||
@export var angle_v_adjust := 0.0
|
||||
@export var autoturn_ray_aperture := 25.0
|
||||
@export var autoturn_speed := 50.0
|
||||
@export var min_distance: float = 0.5
|
||||
@export var max_distance: float = 3.5
|
||||
@export var angle_v_adjust: float = 0.0
|
||||
@export var autoturn_ray_aperture: float = 25.0
|
||||
@export var autoturn_speed: float = 50.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# Find collision exceptions for ray.
|
||||
|
||||
@@ -6,26 +6,26 @@ enum _Anim {
|
||||
AIR,
|
||||
}
|
||||
|
||||
const SHOOT_TIME = 1.5
|
||||
const SHOOT_SCALE = 2.0
|
||||
const CHAR_SCALE = Vector3(0.3, 0.3, 0.3)
|
||||
const MAX_SPEED = 6.0
|
||||
const TURN_SPEED = 40.0
|
||||
const JUMP_VELOCITY = 12.5
|
||||
const BULLET_SPEED = 20.0
|
||||
const AIR_IDLE_DEACCEL = false
|
||||
const ACCEL = 14.0
|
||||
const DEACCEL = 14.0
|
||||
const AIR_ACCEL_FACTOR = 0.5
|
||||
const SHARP_TURN_THRESHOLD = deg_to_rad(140.0)
|
||||
const SHOOT_TIME: float = 1.5
|
||||
const SHOOT_SCALE: float = 2.0
|
||||
const CHAR_SCALE := Vector3(0.3, 0.3, 0.3)
|
||||
const MAX_SPEED: float = 6.0
|
||||
const TURN_SPEED: float = 40.0
|
||||
const JUMP_VELOCITY: float = 12.5
|
||||
const BULLET_SPEED: float = 20.0
|
||||
const AIR_IDLE_DEACCEL: bool = false
|
||||
const ACCEL: float = 14.0
|
||||
const DEACCEL: float = 14.0
|
||||
const AIR_ACCEL_FACTOR: float = 0.5
|
||||
const SHARP_TURN_THRESHOLD: float = deg_to_rad(140.0)
|
||||
|
||||
var movement_dir := Vector3()
|
||||
var jumping := false
|
||||
var prev_shoot := false
|
||||
var shoot_blend := 0.0
|
||||
var jumping: bool = false
|
||||
var prev_shoot: bool = false
|
||||
var shoot_blend: float = 0.0
|
||||
|
||||
# Number of coins collected.
|
||||
var coins := 0
|
||||
var coins: int = 0
|
||||
|
||||
@onready var initial_position := position
|
||||
@onready var gravity: Vector3 = ProjectSettings.get_setting("physics/3d/default_gravity") * \
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user