Browse Source

Use static typing in all demos (#1063)

This leads to code that is easier to understand and runs
faster thanks to GDScript's typed instructions.

The untyped declaration warning is now enabled on all projects
where type hints were added. All projects currently run without
any untyped declration warnings.

Dodge the Creeps and Squash the Creeps demos intentionally don't
use type hints to match the documentation, where type hints haven't
been adopted yet (given its beginner focus).
Hugo Locurcio 1 year ago
parent
commit
bac1e69164
100 changed files with 917 additions and 875 deletions
  1. 18 18
      2d/bullet_shower/bullets.gd
  2. 7 7
      2d/bullet_shower/player.gd
  3. 4 0
      2d/bullet_shower/project.godot
  4. 12 11
      2d/dynamic_tilemap_layers/level/tile_map.gd
  5. 3 3
      2d/dynamic_tilemap_layers/player/player.gd
  6. 5 1
      2d/dynamic_tilemap_layers/project.godot
  7. 10 8
      2d/finite_state_machine/debug/states_stack_displayer.gd
  8. 8 8
      2d/finite_state_machine/player/bullet/bullet.gd
  9. 4 4
      2d/finite_state_machine/player/bullet/bullet_spawner.gd
  10. 6 5
      2d/finite_state_machine/player/player_controller.gd
  11. 10 8
      2d/finite_state_machine/player/player_state_machine.gd
  12. 2 2
      2d/finite_state_machine/player/states/combat/attack.gd
  13. 2 2
      2d/finite_state_machine/player/states/combat/stagger.gd
  14. 5 5
      2d/finite_state_machine/player/states/debug/state_name_displayer.gd
  15. 2 2
      2d/finite_state_machine/player/states/die.gd
  16. 20 20
      2d/finite_state_machine/player/states/motion/in_air/jump.gd
  17. 4 5
      2d/finite_state_machine/player/states/motion/motion.gd
  18. 4 4
      2d/finite_state_machine/player/states/motion/on_ground/idle.gd
  19. 13 12
      2d/finite_state_machine/player/states/motion/on_ground/move.gd
  20. 3 3
      2d/finite_state_machine/player/states/motion/on_ground/on_ground.gd
  21. 34 24
      2d/finite_state_machine/player/weapon/sword.gd
  22. 3 3
      2d/finite_state_machine/player/weapon/weapon_pivot.gd
  23. 4 0
      2d/finite_state_machine/project.godot
  24. 6 6
      2d/finite_state_machine/state_machine/state.gd
  25. 14 13
      2d/finite_state_machine/state_machine/state_machine.gd
  26. 3 3
      2d/glow/beach_cave.gd
  27. 0 1
      2d/glow/beach_cave.tscn
  28. 4 0
      2d/glow/project.godot
  29. 0 0
      2d/hexagonal_map/map.tscn
  30. 4 0
      2d/hexagonal_map/project.godot
  31. 2 2
      2d/hexagonal_map/troll.gd
  32. 3 2
      2d/hexagonal_map/troll.tscn
  33. 8 8
      2d/instancing/ball.tscn
  34. 4 3
      2d/instancing/ball_factory.gd
  35. 5 0
      2d/instancing/project.godot
  36. 4 2
      2d/instancing/scene_instancing.tscn
  37. 1 1
      2d/kinematic_character/level/princess.gd
  38. 3 3
      2d/kinematic_character/player/player.gd
  39. 4 0
      2d/kinematic_character/project.godot
  40. 4 0
      2d/light2d_as_mask/project.godot
  41. 1 1
      2d/lights_and_shadows/light_shadows.gd
  42. 4 0
      2d/lights_and_shadows/project.godot
  43. 6 6
      2d/navigation/character.gd
  44. 8 0
      2d/navigation/project.godot
  45. 20 16
      2d/navigation_astar/character.gd
  46. 19 15
      2d/navigation_astar/pathfind_astar.gd
  47. 4 0
      2d/navigation_astar/project.godot
  48. 5 7
      2d/particles/particles.tscn
  49. 1 1
      2d/particles/pause.gd
  50. 4 0
      2d/particles/project.godot
  51. 2 2
      2d/physics_platformer/coin/coin.gd
  52. 0 1
      2d/physics_platformer/enemy/enemy.gd
  53. 1 1
      2d/physics_platformer/enemy/enemy.tscn
  54. 3 3
      2d/physics_platformer/player/bullet.gd
  55. 2 2
      2d/physics_platformer/player/player.gd
  56. 4 0
      2d/physics_platformer/project.godot
  57. 2 2
      2d/physics_tests/assets/tileset/tileset.tres
  58. 16 8
      2d/physics_tests/main.tscn
  59. 12 7
      2d/physics_tests/project.godot
  60. 36 37
      2d/physics_tests/test.gd
  61. 4 5
      2d/physics_tests/tests.gd
  62. 46 48
      2d/physics_tests/tests/functional/test_character.gd
  63. 24 26
      2d/physics_tests/tests/functional/test_character_pixels.gd
  64. 25 28
      2d/physics_tests/tests/functional/test_character_tilemap.gd
  65. 27 37
      2d/physics_tests/tests/functional/test_character_tilemap.tscn
  66. 34 38
      2d/physics_tests/tests/functional/test_collision_pairs.gd
  67. 29 33
      2d/physics_tests/tests/functional/test_joints.gd
  68. 2 5
      2d/physics_tests/tests/functional/test_joints.tscn
  69. 62 64
      2d/physics_tests/tests/functional/test_one_way_collision.gd
  70. 14 16
      2d/physics_tests/tests/functional/test_pyramid.gd
  71. 2 2
      2d/physics_tests/tests/functional/test_pyramid.tscn
  72. 17 21
      2d/physics_tests/tests/functional/test_raycasting.gd
  73. 14 16
      2d/physics_tests/tests/functional/test_stack.gd
  74. 29 31
      2d/physics_tests/tests/performance/test_perf_broadphase.gd
  75. 2 2
      2d/physics_tests/tests/performance/test_perf_broadphase.tscn
  76. 37 38
      2d/physics_tests/tests/performance/test_perf_contacts.gd
  77. 15 15
      2d/physics_tests/tests/performance/test_perf_contacts.tscn
  78. 13 14
      2d/physics_tests/tests_menu.gd
  79. 16 17
      2d/physics_tests/utils/characterbody_controller.gd
  80. 9 11
      2d/physics_tests/utils/container_log.gd
  81. 5 4
      2d/physics_tests/utils/label_engine.gd
  82. 2 3
      2d/physics_tests/utils/label_fps.gd
  83. 1 1
      2d/physics_tests/utils/label_pause.gd
  84. 2 2
      2d/physics_tests/utils/label_slider_value.gd
  85. 2 3
      2d/physics_tests/utils/label_test.gd
  86. 2 3
      2d/physics_tests/utils/label_version.gd
  87. 20 21
      2d/physics_tests/utils/option_menu.gd
  88. 17 18
      2d/physics_tests/utils/rigidbody_controller.gd
  89. 9 10
      2d/physics_tests/utils/rigidbody_pick.gd
  90. 7 9
      2d/physics_tests/utils/scroll_log.gd
  91. 2 2
      2d/physics_tests/utils/slider.gd
  92. 10 10
      2d/physics_tests/utils/system.gd
  93. 3 5
      2d/physics_tests/utils/system_log.gd
  94. 2 2
      2d/platformer/enemy/enemy.gd
  95. 2 1
      2d/platformer/game.gd
  96. 2 2
      2d/platformer/gui/coins_counter.gd
  97. 2 1
      2d/platformer/gui/pause_menu.gd
  98. 2 1
      2d/platformer/level/coin.gd
  99. 0 1
      2d/platformer/level/level.gd
  100. 2 1
      2d/platformer/player/bullet.gd

+ 18 - 18
2d/bullet_shower/bullets.gd

@@ -8,28 +8,28 @@ const BULLET_COUNT = 500
 const SPEED_MIN = 20
 const SPEED_MIN = 20
 const SPEED_MAX = 80
 const SPEED_MAX = 80
 
 
-const bullet_image = preload("res://bullet.png")
+const bullet_image := preload("res://bullet.png")
 
 
 var bullets := []
 var bullets := []
-var shape
+var shape := RID()
 
 
 
 
 class Bullet:
 class Bullet:
-	var position = Vector2()
-	var speed = 1.0
+	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 a RID, which is an "opaque" way to access resources.
 	# With large amounts of objects (thousands or more), it can be significantly
 	# With large amounts of objects (thousands or more), it can be significantly
 	# faster to use RIDs compared to a high-level approach.
 	# faster to use RIDs compared to a high-level approach.
-	var body = RID()
+	var body := RID()
 
 
 
 
-func _ready():
+func _ready() -> void:
 	shape = PhysicsServer2D.circle_shape_create()
 	shape = PhysicsServer2D.circle_shape_create()
 	# Set the collision shape's radius for each bullet in pixels.
 	# Set the collision shape's radius for each bullet in pixels.
 	PhysicsServer2D.shape_set_data(shape, 8)
 	PhysicsServer2D.shape_set_data(shape, 8)
 
 
 	for _i in BULLET_COUNT:
 	for _i in BULLET_COUNT:
-		var bullet = Bullet.new()
+		var bullet := Bullet.new()
 		# Give each bullet its own random speed.
 		# Give each bullet its own random speed.
 		bullet.speed = randf_range(SPEED_MIN, SPEED_MAX)
 		bullet.speed = randf_range(SPEED_MIN, SPEED_MAX)
 		bullet.body = PhysicsServer2D.body_create()
 		bullet.body = PhysicsServer2D.body_create()
@@ -45,22 +45,22 @@ func _ready():
 			randf_range(0, get_viewport_rect().size.x) + get_viewport_rect().size.x,
 			randf_range(0, get_viewport_rect().size.x) + get_viewport_rect().size.x,
 			randf_range(0, get_viewport_rect().size.y)
 			randf_range(0, get_viewport_rect().size.y)
 		)
 		)
-		var transform2d = Transform2D()
+		var transform2d := Transform2D()
 		transform2d.origin = bullet.position
 		transform2d.origin = bullet.position
 		PhysicsServer2D.body_set_state(bullet.body, PhysicsServer2D.BODY_STATE_TRANSFORM, transform2d)
 		PhysicsServer2D.body_set_state(bullet.body, PhysicsServer2D.BODY_STATE_TRANSFORM, transform2d)
 
 
 		bullets.push_back(bullet)
 		bullets.push_back(bullet)
 
 
 
 
-func _process(_delta):
+func _process(_delta: float) -> void:
 	# Order the CanvasItem to update every frame.
 	# Order the CanvasItem to update every frame.
 	queue_redraw()
 	queue_redraw()
 
 
 
 
-func _physics_process(delta):
-	var transform2d = Transform2D()
-	var offset = get_viewport_rect().size.x + 16
-	for bullet in bullets:
+func _physics_process(delta: float) -> void:
+	var transform2d := Transform2D()
+	var offset := get_viewport_rect().size.x + 16
+	for bullet: Bullet in bullets:
 		bullet.position.x -= bullet.speed * delta
 		bullet.position.x -= bullet.speed * delta
 
 
 		if bullet.position.x < -16:
 		if bullet.position.x < -16:
@@ -73,15 +73,15 @@ func _physics_process(delta):
 
 
 # Instead of drawing each bullet individually in a script attached to each bullet,
 # Instead of drawing each bullet individually in a script attached to each bullet,
 # we are drawing *all* the bullets at once here.
 # we are drawing *all* the bullets at once here.
-func _draw():
-	var offset = -bullet_image.get_size() * 0.5
-	for bullet in bullets:
+func _draw() -> void:
+	var offset := -bullet_image.get_size() * 0.5
+	for bullet: Bullet in bullets:
 		draw_texture(bullet_image, bullet.position + offset)
 		draw_texture(bullet_image, bullet.position + offset)
 
 
 
 
 # Perform cleanup operations (required to exit without error messages in the console).
 # Perform cleanup operations (required to exit without error messages in the console).
-func _exit_tree():
-	for bullet in bullets:
+func _exit_tree() -> void:
+	for bullet: Bullet in bullets:
 		PhysicsServer2D.free_rid(bullet.body)
 		PhysicsServer2D.free_rid(bullet.body)
 
 
 	PhysicsServer2D.free_rid(shape)
 	PhysicsServer2D.free_rid(shape)

+ 7 - 7
2d/bullet_shower/player.gd

@@ -4,32 +4,32 @@ extends Node2D
 # efficient than using instancing and nodes, but requires more programming and
 # efficient than using instancing and nodes, but requires more programming and
 # is less visual. Bullets are managed together in the `bullets.gd` script.
 # is less visual. Bullets are managed together in the `bullets.gd` script.
 
 
-# The number of bullets currently touched by the player.
-var touching = 0
+## The number of bullets currently touched by the player.
+var touching := 0
 
 
-@onready var sprite = $AnimatedSprite2D
+@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
 
 
 
 
-func _ready():
+func _ready() -> void:
 	# The player follows the mouse cursor automatically, so there's no point
 	# The player follows the mouse cursor automatically, so there's no point
 	# in displaying the mouse cursor.
 	# in displaying the mouse cursor.
 	Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
 	Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
 
 
 
 
-func _input(event):
+func _input(event: InputEvent) -> void:
 	# Getting the movement of the mouse so the sprite can follow its position.
 	# Getting the movement of the mouse so the sprite can follow its position.
 	if event is InputEventMouseMotion:
 	if event is InputEventMouseMotion:
 		position = event.position - Vector2(0, 16)
 		position = event.position - Vector2(0, 16)
 
 
 
 
-func _on_body_shape_entered(_body_id, _body, _body_shape, _local_shape):
+func _on_body_shape_entered(_body_id: RID, _body: Node2D, _body_shape_index: int, _local_shape_index: int) -> void:
 	# Player got touched by a bullet so sprite changes to sad face.
 	# Player got touched by a bullet so sprite changes to sad face.
 	touching += 1
 	touching += 1
 	if touching >= 1:
 	if touching >= 1:
 		sprite.frame = 1
 		sprite.frame = 1
 
 
 
 
-func _on_body_shape_exited(_body_id, _body, _body_shape, _local_shape):
+func _on_body_shape_exited(_body_id: RID, _body: Node2D, _body_shape_index: int, _local_shape_index: int) -> void:
 	touching -= 1
 	touching -= 1
 	# When non of the bullets are touching the player,
 	# When non of the bullets are touching the player,
 	# sprite changes to happy face.
 	# sprite changes to happy face.

+ 4 - 0
2d/bullet_shower/project.godot

@@ -17,6 +17,10 @@ run/main_scene="res://shower.tscn"
 config/features=PackedStringArray("4.2")
 config/features=PackedStringArray("4.2")
 config/icon="res://icon.webp"
 config/icon="res://icon.webp"
 
 
+[debug]
+
+gdscript/warnings/untyped_declaration=1
+
 [display]
 [display]
 
 
 window/stretch/mode="canvas_items"
 window/stretch/mode="canvas_items"

+ 12 - 11
2d/dynamic_tilemap_layers/level/tile_map.gd

@@ -1,13 +1,13 @@
 extends TileMap
 extends TileMap
 
 
-
-var secret_layer: int # You can have multiple layers if you make this an array.
-var player_in_secret: bool
+# You can have multiple layers if you make this an array.
+var secret_layer := 0
+var player_in_secret := false
 var layer_alpha := 1.0
 var layer_alpha := 1.0
 
 
-
 func _init() -> void:
 func _init() -> void:
-	for i in get_layers_count(): # Find the secret layer by name.
+	for i in get_layers_count():
+		# Find the secret layer by name.
 		if get_layer_name(i) == "Secret":
 		if get_layer_name(i) == "Secret":
 			secret_layer = i
 			secret_layer = i
 
 
@@ -19,7 +19,8 @@ func _ready() -> void:
 func _process(delta: float) -> void:
 func _process(delta: float) -> void:
 	if player_in_secret:
 	if player_in_secret:
 		if layer_alpha > 0.3:
 		if layer_alpha > 0.3:
-			layer_alpha = move_toward(layer_alpha, 0.3, delta) # Animate the layer transparency.
+			# Animate the layer transparency.
+			layer_alpha = move_toward(layer_alpha, 0.3, delta)
 			set_layer_modulate(secret_layer, Color(1, 1, 1, layer_alpha))
 			set_layer_modulate(secret_layer, Color(1, 1, 1, layer_alpha))
 		else:
 		else:
 			set_process(false)
 			set_process(false)
@@ -32,17 +33,17 @@ func _process(delta: float) -> void:
 
 
 
 
 func _use_tile_data_runtime_update(layer: int, _coords: Vector2i) -> bool:
 func _use_tile_data_runtime_update(layer: int, _coords: Vector2i) -> bool:
-	if layer == secret_layer:
-		return true
-	return false
+	return layer == secret_layer
 
 
 
 
 func _tile_data_runtime_update(_layer: int, _coords: Vector2i, tile_data: TileData) -> void:
 func _tile_data_runtime_update(_layer: int, _coords: Vector2i, tile_data: TileData) -> void:
-	tile_data.set_collision_polygons_count(0, 0) # Remove collision for secret layer.
+	# Remove collision for secret layer.
+	tile_data.set_collision_polygons_count(0, 0)
 
 
 
 
 func _on_secret_detector_body_entered(body: Node2D) -> void:
 func _on_secret_detector_body_entered(body: Node2D) -> void:
-	if not body is CharacterBody2D: # Detect player only.
+	if not body is CharacterBody2D:
+		# Detect the player only.
 		return
 		return
 
 
 	player_in_secret = true
 	player_in_secret = true

+ 3 - 3
2d/dynamic_tilemap_layers/player/player.gd

@@ -5,11 +5,11 @@ const WALK_MAX_SPEED = 200
 const STOP_FORCE = 1300
 const STOP_FORCE = 1300
 const JUMP_SPEED = 200
 const JUMP_SPEED = 200
 
 
-@onready var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
+@onready var gravity: float = ProjectSettings.get_setting("physics/2d/default_gravity")
 
 
-func _physics_process(delta):
+func _physics_process(delta: float) -> void:
 	# Horizontal movement code. First, get the player's input.
 	# Horizontal movement code. First, get the player's input.
-	var walk = WALK_FORCE * (Input.get_axis(&"move_left", &"move_right"))
+	var walk := WALK_FORCE * (Input.get_axis(&"move_left", &"move_right"))
 	# Slow down the player if they're not trying to move.
 	# Slow down the player if they're not trying to move.
 	if abs(walk) < WALK_FORCE * 0.2:
 	if abs(walk) < WALK_FORCE * 0.2:
 		# The velocity, slowed down a bit, and then reassigned.
 		# The velocity, slowed down a bit, and then reassigned.

+ 5 - 1
2d/dynamic_tilemap_layers/project.godot

@@ -14,10 +14,14 @@ config/name="Dynamic TileMap Layers"
 config/description="Example of how to make a kinematic character controller in 2D using
 config/description="Example of how to make a kinematic character controller in 2D using
 CharacterBody2D. The character moves around, is affected by moving
 CharacterBody2D. The character moves around, is affected by moving
 platforms, can jump through one-way collision platforms, etc."
 platforms, can jump through one-way collision platforms, etc."
+config/tags=PackedStringArray("2d", "demo", "official", "tilemap")
 run/main_scene="res://world.tscn"
 run/main_scene="res://world.tscn"
 config/features=PackedStringArray("4.2")
 config/features=PackedStringArray("4.2")
 config/icon="res://icon.png"
 config/icon="res://icon.png"
-config/tags=PackedStringArray("2d", "demo", "official", "tilemap")
+
+[debug]
+
+gdscript/warnings/untyped_declaration=1
 
 
 [display]
 [display]
 
 

+ 10 - 8
2d/finite_state_machine/debug/states_stack_displayer.gd

@@ -1,14 +1,16 @@
 extends Panel
 extends Panel
 
 
-@onready var fsm_node = get_node(^"../../Player/StateMachine")
-
-func _process(_delta):
-	var states_names = ""
-	var numbers = ""
-	var index = 0
-	for state in fsm_node.states_stack:
-		states_names += String(state.get_name()) + "\n"
+@onready var fsm_node: Node = get_node(^"../../Player/StateMachine")
+
+func _process(_delta: float) -> void:
+	var states_names := ""
+	var numbers := ""
+	var index := 0
+
+	for state: Node in fsm_node.states_stack:
+		states_names += String(state.name) + "\n"
 		numbers += str(index) + "\n"
 		numbers += str(index) + "\n"
 		index += 1
 		index += 1
+
 	%States.text = states_names
 	%States.text = states_names
 	%Numbers.text = numbers
 	%Numbers.text = numbers

+ 8 - 8
2d/finite_state_machine/player/bullet/bullet.gd

@@ -1,23 +1,23 @@
 extends CharacterBody2D
 extends CharacterBody2D
 
 
-var direction = Vector2()
-@export var speed: float = 1000.0
+var direction := Vector2()
+@export var speed := 1000.0
 
 
-@onready var root = get_tree().root
+@onready var root := get_tree().root
 
 
-func _ready():
+func _ready() -> void:
 	set_as_top_level(true)
 	set_as_top_level(true)
 
 
 
 
-func _physics_process(delta):
+func _physics_process(delta: float) -> void:
 	if not root.get_visible_rect().has_point(position):
 	if not root.get_visible_rect().has_point(position):
 		queue_free()
 		queue_free()
 
 
-	var motion = direction * speed * delta
-	var collision_info = move_and_collide(motion)
+	var motion := direction * speed * delta
+	var collision_info := move_and_collide(motion)
 	if collision_info:
 	if collision_info:
 		queue_free()
 		queue_free()
 
 
 
 
-func _draw():
+func _draw() -> void:
 	draw_circle(Vector2(), $CollisionShape2D.shape.radius, Color.WHITE)
 	draw_circle(Vector2(), $CollisionShape2D.shape.radius, Color.WHITE)

+ 4 - 4
2d/finite_state_machine/player/bullet/bullet_spawner.gd

@@ -1,18 +1,18 @@
 extends Node2D
 extends Node2D
 
 
-var bullet = preload("Bullet.tscn")
+var bullet := preload("Bullet.tscn")
 
 
-func _unhandled_input(event):
+func _unhandled_input(event: InputEvent) -> void:
 	if event.is_action_pressed("fire"):
 	if event.is_action_pressed("fire"):
 		fire()
 		fire()
 
 
 
 
-func fire():
+func fire() -> void:
 	if not $CooldownTimer.is_stopped():
 	if not $CooldownTimer.is_stopped():
 		return
 		return
 
 
 	$CooldownTimer.start()
 	$CooldownTimer.start()
-	var new_bullet = bullet.instantiate()
+	var new_bullet := bullet.instantiate()
 	add_child(new_bullet)
 	add_child(new_bullet)
 	new_bullet.position = global_position
 	new_bullet.position = global_position
 	new_bullet.direction = owner.look_direction
 	new_bullet.direction = owner.look_direction

+ 6 - 5
2d/finite_state_machine/player/player_controller.gd

@@ -3,25 +3,26 @@ extends CharacterBody2D
 # It can move, collide with the world, etc...
 # It can move, collide with the world, etc...
 # The player has a state machine, but the body and the state machine are separate.
 # The player has a state machine, but the body and the state machine are separate.
 
 
-signal direction_changed(new_direction)
+signal direction_changed(new_direction: Vector2)
 
 
-var look_direction = Vector2.RIGHT:
+var look_direction := Vector2.RIGHT:
 	set(value):
 	set(value):
 		look_direction = value
 		look_direction = value
 		set_look_direction(value)
 		set_look_direction(value)
 
 
-func take_damage(attacker, amount, effect = null):
+func take_damage(attacker: Node, amount: float, effect: Node = null) -> void:
 	if is_ancestor_of(attacker):
 	if is_ancestor_of(attacker):
 		return
 		return
+
 	$States/Stagger.knockback_direction = (attacker.global_position - global_position).normalized()
 	$States/Stagger.knockback_direction = (attacker.global_position - global_position).normalized()
 	$Health.take_damage(amount, effect)
 	$Health.take_damage(amount, effect)
 
 
 
 
-func set_dead(value):
+func set_dead(value: bool) -> void:
 	set_process_input(not value)
 	set_process_input(not value)
 	set_physics_process(not value)
 	set_physics_process(not value)
 	$CollisionPolygon2D.disabled = value
 	$CollisionPolygon2D.disabled = value
 
 
 
 
-func set_look_direction(value):
+func set_look_direction(value: Vector2) -> void:
 	direction_changed.emit(value)
 	direction_changed.emit(value)

+ 10 - 8
2d/finite_state_machine/player/player_state_machine.gd

@@ -1,12 +1,12 @@
 extends "res://state_machine/state_machine.gd"
 extends "res://state_machine/state_machine.gd"
 
 
-@onready var idle = $Idle
-@onready var move = $Move
-@onready var jump = $Jump
-@onready var stagger = $Stagger
-@onready var attack = $Attack
+@onready var idle: Node = $Idle
+@onready var move: Node = $Move
+@onready var jump: Node = $Jump
+@onready var stagger: Node = $Stagger
+@onready var attack: Node = $Attack
 
 
-func _ready():
+func _ready() -> void:
 	states_map = {
 	states_map = {
 		"idle": idle,
 		"idle": idle,
 		"move": move,
 		"move": move,
@@ -16,7 +16,7 @@ func _ready():
 	}
 	}
 
 
 
 
-func _change_state(state_name):
+func _change_state(state_name: String) -> void:
 	# The base state_machine interface this node extends does most of the work.
 	# The base state_machine interface this node extends does most of the work.
 	if not _active:
 	if not _active:
 		return
 		return
@@ -24,10 +24,11 @@ func _change_state(state_name):
 		states_stack.push_front(states_map[state_name])
 		states_stack.push_front(states_map[state_name])
 	if state_name == "jump" and current_state == move:
 	if state_name == "jump" and current_state == move:
 		jump.initialize(move.speed, move.velocity)
 		jump.initialize(move.speed, move.velocity)
+
 	super._change_state(state_name)
 	super._change_state(state_name)
 
 
 
 
-func _unhandled_input(event):
+func _unhandled_input(event: InputEvent) -> void:
 	# Here we only handle input that can interrupt states, attacking in this case,
 	# Here we only handle input that can interrupt states, attacking in this case,
 	# otherwise we let the state node handle it.
 	# otherwise we let the state node handle it.
 	if event.is_action_pressed("attack"):
 	if event.is_action_pressed("attack"):
@@ -35,4 +36,5 @@ func _unhandled_input(event):
 			return
 			return
 		_change_state("attack")
 		_change_state("attack")
 		return
 		return
+
 	current_state.handle_input(event)
 	current_state.handle_input(event)

+ 2 - 2
2d/finite_state_machine/player/states/combat/attack.gd

@@ -1,8 +1,8 @@
 extends "res://state_machine/state.gd"
 extends "res://state_machine/state.gd"
 
 
-func enter():
+func enter() -> void:
 	owner.get_node(^"AnimationPlayer").play("idle")
 	owner.get_node(^"AnimationPlayer").play("idle")
 
 
 
 
-func _on_Sword_attack_finished():
+func _on_Sword_attack_finished() -> void:
 	finished.emit("previous")
 	finished.emit("previous")

+ 2 - 2
2d/finite_state_machine/player/states/combat/stagger.gd

@@ -3,10 +3,10 @@ extends "res://state_machine/state.gd"
 # The animation only affects the Body Sprite2D's modulate property so it
 # The animation only affects the Body Sprite2D's modulate property so it
 # could stack with other animations if we had two AnimationPlayer nodes.
 # could stack with other animations if we had two AnimationPlayer nodes.
 
 
-func enter():
+func enter() -> void:
 	owner.get_node(^"AnimationPlayer").play("stagger")
 	owner.get_node(^"AnimationPlayer").play("stagger")
 
 
 
 
-func _on_animation_finished(anim_name):
+func _on_animation_finished(anim_name: String) -> void:
 	assert(anim_name == "stagger")
 	assert(anim_name == "stagger")
 	finished.emit("previous")
 	finished.emit("previous")

+ 5 - 5
2d/finite_state_machine/player/states/debug/state_name_displayer.gd

@@ -1,14 +1,14 @@
 extends Label
 extends Label
 
 
-var start_position = Vector2()
+var start_position := Vector2()
 
 
-func _ready():
+func _ready() -> void:
 	start_position = position
 	start_position = position
 
 
 
 
-func _physics_process(_delta):
+func _physics_process(_delta: float) -> void:
 	position = $"../BodyPivot".position + start_position
 	position = $"../BodyPivot".position + start_position
 
 
 
 
-func _on_StateMachine_state_changed(current_state):
-	text = String(current_state.get_name())
+func _on_StateMachine_state_changed(current_state: Node) -> void:
+	text = String(current_state.name)

+ 2 - 2
2d/finite_state_machine/player/states/die.gd

@@ -1,10 +1,10 @@
 extends "res://state_machine/state.gd"
 extends "res://state_machine/state.gd"
 
 
 # Initialize the state. E.g. change the animation.
 # Initialize the state. E.g. change the animation.
-func enter():
+func enter() -> void:
 	owner.set_dead(true)
 	owner.set_dead(true)
 	owner.get_node(^"AnimationPlayer").play("die")
 	owner.get_node(^"AnimationPlayer").play("die")
 
 
 
 
-func _on_animation_finished(_anim_name):
+func _on_animation_finished(_anim_name: String) -> void:
 	finished.emit("dead")
 	finished.emit("dead")

+ 20 - 20
2d/finite_state_machine/player/states/motion/in_air/jump.gd

@@ -1,23 +1,23 @@
 extends "../motion.gd"
 extends "../motion.gd"
 
 
-@export var base_max_horizontal_speed: float = 400.0
+@export var base_max_horizontal_speed := 400.0
 
 
-@export var air_acceleration: float = 1000.0
-@export var air_deceleration: float = 2000.0
-@export var air_steering_power: float = 50.0
+@export var air_acceleration := 1000.0
+@export var air_deceleration := 2000.0
+@export var air_steering_power := 50.0
 
 
-@export var gravity: float = 1600.0
+@export var gravity := 1600.0
 
 
-var enter_velocity = Vector2()
+var enter_velocity := Vector2()
 
 
-var max_horizontal_speed = 0.0
-var horizontal_speed = 0.0
-var horizontal_velocity = Vector2()
+var max_horizontal_speed := 0.0
+var horizontal_speed := 0.0
+var horizontal_velocity := Vector2()
 
 
-var vertical_speed = 0.0
-var height = 0.0
+var vertical_speed := 0.0
+var height := 0.0
 
 
-func initialize(speed, velocity):
+func initialize(speed: float, velocity: Vector2) -> void:
 	horizontal_speed = speed
 	horizontal_speed = speed
 	if speed > 0.0:
 	if speed > 0.0:
 		max_horizontal_speed = speed
 		max_horizontal_speed = speed
@@ -26,8 +26,8 @@ func initialize(speed, velocity):
 	enter_velocity = velocity
 	enter_velocity = velocity
 
 
 
 
-func enter():
-	var input_direction = get_input_direction()
+func enter() -> void:
+	var input_direction := get_input_direction()
 	update_look_direction(input_direction)
 	update_look_direction(input_direction)
 
 
 	if input_direction:
 	if input_direction:
@@ -39,8 +39,8 @@ func enter():
 	owner.get_node(^"AnimationPlayer").play("idle")
 	owner.get_node(^"AnimationPlayer").play("idle")
 
 
 
 
-func update(delta):
-	var input_direction = get_input_direction()
+func update(delta: float) -> void:
+	var input_direction := get_input_direction()
 	update_look_direction(input_direction)
 	update_look_direction(input_direction)
 
 
 	move_horizontally(delta, input_direction)
 	move_horizontally(delta, input_direction)
@@ -49,22 +49,22 @@ func update(delta):
 		finished.emit("previous")
 		finished.emit("previous")
 
 
 
 
-func move_horizontally(delta, direction):
+func move_horizontally(delta: float, direction: Vector2) -> void:
 	if direction:
 	if direction:
 		horizontal_speed += air_acceleration * delta
 		horizontal_speed += air_acceleration * delta
 	else:
 	else:
 		horizontal_speed -= air_deceleration * delta
 		horizontal_speed -= air_deceleration * delta
 	horizontal_speed = clamp(horizontal_speed, 0, max_horizontal_speed)
 	horizontal_speed = clamp(horizontal_speed, 0, max_horizontal_speed)
 
 
-	var target_velocity = horizontal_speed * direction.normalized()
-	var steering_velocity = (target_velocity - horizontal_velocity).normalized() * air_steering_power
+	var target_velocity := horizontal_speed * direction.normalized()
+	var steering_velocity := (target_velocity - horizontal_velocity).normalized() * air_steering_power
 	horizontal_velocity += steering_velocity
 	horizontal_velocity += steering_velocity
 
 
 	owner.velocity = horizontal_velocity
 	owner.velocity = horizontal_velocity
 	owner.move_and_slide()
 	owner.move_and_slide()
 
 
 
 
-func animate_jump_height(delta):
+func animate_jump_height(delta: float) -> void:
 	vertical_speed -= gravity * delta
 	vertical_speed -= gravity * delta
 	height += vertical_speed * delta
 	height += vertical_speed * delta
 	height = max(0.0, height)
 	height = max(0.0, height)

+ 4 - 5
2d/finite_state_machine/player/states/motion/motion.gd

@@ -1,19 +1,18 @@
 extends "res://state_machine/state.gd"
 extends "res://state_machine/state.gd"
 # Collection of important methods to handle direction and animation.
 # Collection of important methods to handle direction and animation.
 
 
-func handle_input(event):
+func handle_input(event: InputEvent) -> void:
 	if event.is_action_pressed("simulate_damage"):
 	if event.is_action_pressed("simulate_damage"):
 		finished.emit("stagger")
 		finished.emit("stagger")
 
 
 
 
-func get_input_direction():
-	var input_direction = Vector2(
+func get_input_direction() -> Vector2:
+	return Vector2(
 			Input.get_axis(&"move_left", &"move_right"),
 			Input.get_axis(&"move_left", &"move_right"),
 			Input.get_axis(&"move_up", &"move_down")
 			Input.get_axis(&"move_up", &"move_down")
 	)
 	)
-	return input_direction
 
 
 
 
-func update_look_direction(direction):
+func update_look_direction(direction: Vector2) -> void:
 	if direction and owner.look_direction != direction:
 	if direction and owner.look_direction != direction:
 		owner.look_direction = direction
 		owner.look_direction = direction

+ 4 - 4
2d/finite_state_machine/player/states/motion/on_ground/idle.gd

@@ -1,14 +1,14 @@
 extends "on_ground.gd"
 extends "on_ground.gd"
 
 
-func enter():
+func enter() -> void:
 	owner.get_node(^"AnimationPlayer").play("idle")
 	owner.get_node(^"AnimationPlayer").play("idle")
 
 
 
 
-func handle_input(event):
+func handle_input(event: InputEvent) -> void:
 	return super.handle_input(event)
 	return super.handle_input(event)
 
 
 
 
-func update(_delta):
-	var input_direction = get_input_direction()
+func update(_delta: float) -> void:
+	var input_direction: Vector2 = get_input_direction()
 	if input_direction:
 	if input_direction:
 		finished.emit("move")
 		finished.emit("move")

+ 13 - 12
2d/finite_state_machine/player/states/motion/on_ground/move.gd

@@ -1,23 +1,23 @@
 extends "on_ground.gd"
 extends "on_ground.gd"
 
 
-@export var max_walk_speed: float = 450
-@export var max_run_speed: float = 700
+@export var max_walk_speed := 450.0
+@export var max_run_speed := 700.0
 
 
-func enter():
+func enter() -> void:
 	speed = 0.0
 	speed = 0.0
 	velocity = Vector2()
 	velocity = Vector2()
 
 
-	var input_direction = get_input_direction()
+	var input_direction := get_input_direction()
 	update_look_direction(input_direction)
 	update_look_direction(input_direction)
 	owner.get_node(^"AnimationPlayer").play("walk")
 	owner.get_node(^"AnimationPlayer").play("walk")
 
 
 
 
-func handle_input(event):
+func handle_input(event: InputEvent) -> void:
 	return super.handle_input(event)
 	return super.handle_input(event)
 
 
 
 
-func update(_delta):
-	var input_direction = get_input_direction()
+func update(_delta: float) -> void:
+	var input_direction := get_input_direction()
 	if input_direction.is_zero_approx():
 	if input_direction.is_zero_approx():
 		finished.emit("idle")
 		finished.emit("idle")
 	update_look_direction(input_direction)
 	update_look_direction(input_direction)
@@ -27,16 +27,17 @@ func update(_delta):
 	else:
 	else:
 		speed = max_walk_speed
 		speed = max_walk_speed
 
 
-	var collision_info = move(speed, input_direction)
+	var collision_info := move(speed, input_direction)
 	if not collision_info:
 	if not collision_info:
 		return
 		return
 	if speed == max_run_speed and collision_info.collider.is_in_group("environment"):
 	if speed == max_run_speed and collision_info.collider.is_in_group("environment"):
-		return null
+		return
 
 
 
 
-func move(speed, direction):
-	owner.velocity = direction.normalized() * speed
+func move(p_speed: float, direction: Vector2) -> KinematicCollision2D:
+	owner.velocity = direction.normalized() * p_speed
 	owner.move_and_slide()
 	owner.move_and_slide()
 	if owner.get_slide_collision_count() == 0:
 	if owner.get_slide_collision_count() == 0:
-		return
+		return null
+
 	return owner.get_slide_collision(0)
 	return owner.get_slide_collision(0)

+ 3 - 3
2d/finite_state_machine/player/states/motion/on_ground/on_ground.gd

@@ -1,10 +1,10 @@
 extends "../motion.gd"
 extends "../motion.gd"
 
 
 # warning-ignore-all:unused_class_variable
 # warning-ignore-all:unused_class_variable
-var speed = 0.0
-var velocity = Vector2()
+var speed := 0.0
+var velocity := Vector2()
 
 
-func handle_input(event):
+func handle_input(event: InputEvent) -> void:
 	if event.is_action_pressed("jump"):
 	if event.is_action_pressed("jump"):
 		finished.emit("jump")
 		finished.emit("jump")
 	return super.handle_input(event)
 	return super.handle_input(event)

+ 34 - 24
2d/finite_state_machine/player/weapon/sword.gd

@@ -2,41 +2,50 @@ extends Area2D
 
 
 signal attack_finished
 signal attack_finished
 
 
-enum States { IDLE, ATTACK }
-var state = null
-
-enum AttackInputStates { IDLE, LISTENING, REGISTERED }
-var attack_input_state = AttackInputStates.IDLE
-var ready_for_next_attack = false
+enum States {
+	IDLE,
+	ATTACK,
+}
+
+enum AttackInputStates {
+	IDLE,
+	LISTENING,
+	REGISTERED,
+}
+
+var state: States = States.IDLE
+var attack_input_state := AttackInputStates.IDLE
+var ready_for_next_attack := false
 const MAX_COMBO_COUNT = 3
 const MAX_COMBO_COUNT = 3
-var combo_count = 0
+var combo_count := 0
 
 
-var attack_current = {}
-var combo = [{
+var attack_current := {}
+var combo := [{
 		"damage": 1,
 		"damage": 1,
 		"animation": "attack_fast",
 		"animation": "attack_fast",
-		"effect": null
+		"effect": null,
 	},
 	},
 	{
 	{
 		"damage": 1,
 		"damage": 1,
 		"animation": "attack_fast",
 		"animation": "attack_fast",
-		"effect": null
+		"effect": null,
 	},
 	},
 	{
 	{
 		"damage": 3,
 		"damage": 3,
 		"animation": "attack_medium",
 		"animation": "attack_medium",
-		"effect": null
-	}]
+		"effect": null,
+	}
+]
 
 
-var hit_objects = []
+var hit_objects := []
 
 
-func _ready():
+func _ready() -> void:
 	$AnimationPlayer.animation_finished.connect(_on_animation_finished)
 	$AnimationPlayer.animation_finished.connect(_on_animation_finished)
 	body_entered.connect(_on_body_entered)
 	body_entered.connect(_on_body_entered)
 	_change_state(States.IDLE)
 	_change_state(States.IDLE)
 
 
 
 
-func _change_state(new_state):
+func _change_state(new_state: States) -> void:
 	match state:
 	match state:
 		States.ATTACK:
 		States.ATTACK:
 			hit_objects = []
 			hit_objects = []
@@ -57,7 +66,7 @@ func _change_state(new_state):
 	state = new_state
 	state = new_state
 
 
 
 
-func _unhandled_input(event):
+func _unhandled_input(event: InputEvent) -> void:
 	if not state == States.ATTACK:
 	if not state == States.ATTACK:
 		return
 		return
 	if attack_input_state != AttackInputStates.LISTENING:
 	if attack_input_state != AttackInputStates.LISTENING:
@@ -66,36 +75,37 @@ func _unhandled_input(event):
 		attack_input_state = AttackInputStates.REGISTERED
 		attack_input_state = AttackInputStates.REGISTERED
 
 
 
 
-func _physics_process(_delta):
+func _physics_process(_delta: float) -> void:
 	if attack_input_state == AttackInputStates.REGISTERED and ready_for_next_attack:
 	if attack_input_state == AttackInputStates.REGISTERED and ready_for_next_attack:
 		attack()
 		attack()
 
 
 
 
-func attack():
+func attack() -> void:
 	combo_count += 1
 	combo_count += 1
 	_change_state(States.ATTACK)
 	_change_state(States.ATTACK)
 
 
 
 
 # Use with AnimationPlayer func track.
 # Use with AnimationPlayer func track.
-func set_attack_input_listening():
+func set_attack_input_listening() -> void:
 	attack_input_state = AttackInputStates.LISTENING
 	attack_input_state = AttackInputStates.LISTENING
 
 
 
 
 # Use with AnimationPlayer func track.
 # Use with AnimationPlayer func track.
-func set_ready_for_next_attack():
+func set_ready_for_next_attack() -> void:
 	ready_for_next_attack = true
 	ready_for_next_attack = true
 
 
 
 
-func _on_body_entered(body):
+func _on_body_entered(body: Node2D) -> void:
 	if not body.has_node("Health"):
 	if not body.has_node("Health"):
 		return
 		return
 	if body.get_rid().get_id() in hit_objects:
 	if body.get_rid().get_id() in hit_objects:
 		return
 		return
+
 	hit_objects.append(body.get_rid().get_id())
 	hit_objects.append(body.get_rid().get_id())
 	body.take_damage(self, attack_current["damage"], attack_current["effect"])
 	body.take_damage(self, attack_current["damage"], attack_current["effect"])
 
 
 
 
-func _on_animation_finished(_name):
+func _on_animation_finished(_name: String) -> void:
 	if attack_current.is_empty():
 	if attack_current.is_empty():
 		return
 		return
 
 
@@ -106,6 +116,6 @@ func _on_animation_finished(_name):
 		attack_finished.emit()
 		attack_finished.emit()
 
 
 
 
-func _on_StateMachine_state_changed(current_state):
+func _on_StateMachine_state_changed(current_state: Node) -> void:
 	if current_state.name == "Attack":
 	if current_state.name == "Attack":
 		attack()
 		attack()

+ 3 - 3
2d/finite_state_machine/player/weapon/weapon_pivot.gd

@@ -1,13 +1,13 @@
 extends Marker2D
 extends Marker2D
 
 
-var z_index_start = 0
+var z_index_start := 0
 
 
-func _ready():
+func _ready() -> void:
 	owner.direction_changed.connect(_on_Parent_direction_changed)
 	owner.direction_changed.connect(_on_Parent_direction_changed)
 	z_index_start = z_index
 	z_index_start = z_index
 
 
 
 
-func _on_Parent_direction_changed(direction):
+func _on_Parent_direction_changed(direction: Vector2) -> void:
 	rotation = direction.angle()
 	rotation = direction.angle()
 	match direction:
 	match direction:
 		Vector2.UP:
 		Vector2.UP:

+ 4 - 0
2d/finite_state_machine/project.godot

@@ -19,6 +19,10 @@ run/main_scene="res://Demo.tscn"
 config/features=PackedStringArray("4.2")
 config/features=PackedStringArray("4.2")
 config/icon="res://icon.webp"
 config/icon="res://icon.webp"
 
 
+[debug]
+
+gdscript/warnings/untyped_declaration=1
+
 [display]
 [display]
 
 
 window/size/viewport_width=1280
 window/size/viewport_width=1280

+ 6 - 6
2d/finite_state_machine/state_machine/state.gd

@@ -4,25 +4,25 @@ extends Node
 # and makes sure every State object had all of these methods.
 # and makes sure every State object had all of these methods.
 
 
 # warning-ignore:unused_signal
 # warning-ignore:unused_signal
-signal finished(next_state_name)
+signal finished(next_state_name: String)
 
 
 # Initialize the state. E.g. change the animation.
 # Initialize the state. E.g. change the animation.
-func enter():
+func enter() -> void:
 	pass
 	pass
 
 
 
 
 # Clean up the state. Reinitialize values like a timer.
 # Clean up the state. Reinitialize values like a timer.
-func exit():
+func exit() -> void:
 	pass
 	pass
 
 
 
 
-func handle_input(_event):
+func handle_input(_event: InputEvent) -> void:
 	pass
 	pass
 
 
 
 
-func update(_delta):
+func update(_delta: float) -> void:
 	pass
 	pass
 
 
 
 
-func _on_animation_finished(_anim_name):
+func _on_animation_finished(_anim_name: String) -> void:
 	pass
 	pass

+ 14 - 13
2d/finite_state_machine/state_machine/state_machine.gd

@@ -5,39 +5,39 @@ extends Node
 # and changing the current/active state.
 # and changing the current/active state.
 # See the PlayerV2 scene for an example on how to use it.
 # See the PlayerV2 scene for an example on how to use it.
 
 
-signal state_changed(current_state)
+signal state_changed(current_state: Node)
 
 
 # You should set a starting node from the inspector or on the node that inherits
 # You should set a starting node from the inspector or on the node that inherits
 # from this state machine interface. If you don't, the game will default to
 # from this state machine interface. If you don't, the game will default to
 # the first state in the state machine's children.
 # the first state in the state machine's children.
 @export var start_state: NodePath
 @export var start_state: NodePath
-var states_map = {}
+var states_map := {}
 
 
-var states_stack = []
-var current_state = null
-var _active = false:
+var states_stack := []
+var current_state: Node = null
+var _active := false:
 	set(value):
 	set(value):
 		_active = value
 		_active = value
 		set_active(value)
 		set_active(value)
 
 
-func _enter_tree():
+func _enter_tree() -> void:
 	if start_state.is_empty():
 	if start_state.is_empty():
 		start_state = get_child(0).get_path()
 		start_state = get_child(0).get_path()
 	for child in get_children():
 	for child in get_children():
-		var err = child.finished.connect(_change_state)
+		var err: bool = child.finished.connect(_change_state)
 		if err:
 		if err:
 			printerr(err)
 			printerr(err)
 	initialize(start_state)
 	initialize(start_state)
 
 
 
 
-func initialize(initial_state):
+func initialize(initial_state: NodePath) -> void:
 	_active = true
 	_active = true
 	states_stack.push_front(get_node(initial_state))
 	states_stack.push_front(get_node(initial_state))
 	current_state = states_stack[0]
 	current_state = states_stack[0]
 	current_state.enter()
 	current_state.enter()
 
 
 
 
-func set_active(value):
+func set_active(value: bool) -> void:
 	set_physics_process(value)
 	set_physics_process(value)
 	set_process_input(value)
 	set_process_input(value)
 	if not _active:
 	if not _active:
@@ -45,21 +45,22 @@ func set_active(value):
 		current_state = null
 		current_state = null
 
 
 
 
-func _unhandled_input(event):
+func _unhandled_input(event: InputEvent) -> void:
 	current_state.handle_input(event)
 	current_state.handle_input(event)
 
 
 
 
-func _physics_process(delta):
+func _physics_process(delta: float) -> void:
 	current_state.update(delta)
 	current_state.update(delta)
 
 
 
 
-func _on_animation_finished(anim_name):
+func _on_animation_finished(anim_name: String) -> void:
 	if not _active:
 	if not _active:
 		return
 		return
+
 	current_state._on_animation_finished(anim_name)
 	current_state._on_animation_finished(anim_name)
 
 
 
 
-func _change_state(state_name):
+func _change_state(state_name: String) -> void:
 	if not _active:
 	if not _active:
 		return
 		return
 	current_state.exit()
 	current_state.exit()

+ 3 - 3
2d/glow/beach_cave.gd

@@ -2,11 +2,11 @@ extends Node2D
 
 
 const CAVE_LIMIT = 1000
 const CAVE_LIMIT = 1000
 
 
-var glow_map = preload("res://glow_map.webp")
+var glow_map := preload("res://glow_map.webp")
 
 
-@onready var cave = $Cave
+@onready var cave: Node2D = $Cave
 
 
-func _unhandled_input(event):
+func _unhandled_input(event: InputEvent) -> void:
 	if event is InputEventMouseMotion and event.button_mask > 0:
 	if event is InputEventMouseMotion and event.button_mask > 0:
 		cave.position.x = clampf(cave.position.x + event.relative.x, -CAVE_LIMIT, 0)
 		cave.position.x = clampf(cave.position.x + event.relative.x, -CAVE_LIMIT, 0)
 
 

+ 0 - 1
2d/glow/beach_cave.tscn

@@ -37,7 +37,6 @@ environment = SubResource("1")
 
 
 [node name="Camera2D" type="Camera2D" parent="."]
 [node name="Camera2D" type="Camera2D" parent="."]
 offset = Vector2(540, 360)
 offset = Vector2(540, 360)
-current = true
 
 
 [node name="Label" type="Label" parent="."]
 [node name="Label" type="Label" parent="."]
 visible = false
 visible = false

+ 4 - 0
2d/glow/project.godot

@@ -20,6 +20,10 @@ config/features=PackedStringArray("4.2")
 config/icon="res://icon.webp"
 config/icon="res://icon.webp"
 run/name=""
 run/name=""
 
 
+[debug]
+
+gdscript/warnings/untyped_declaration=1
+
 [display]
 [display]
 
 
 window/size/viewport_width=1080
 window/size/viewport_width=1080

File diff suppressed because it is too large
+ 0 - 0
2d/hexagonal_map/map.tscn


+ 4 - 0
2d/hexagonal_map/project.godot

@@ -17,6 +17,10 @@ run/main_scene="res://map.tscn"
 config/features=PackedStringArray("4.2")
 config/features=PackedStringArray("4.2")
 config/icon="res://icon.webp"
 config/icon="res://icon.webp"
 
 
+[debug]
+
+gdscript/warnings/untyped_declaration=1
+
 [display]
 [display]
 
 
 window/stretch/mode="canvas_items"
 window/stretch/mode="canvas_items"

+ 2 - 2
2d/hexagonal_map/troll.gd

@@ -4,8 +4,8 @@ const MOTION_SPEED = 30
 const FRICTION_FACTOR = 0.89
 const FRICTION_FACTOR = 0.89
 const TAN30DEG = tan(deg_to_rad(30))
 const TAN30DEG = tan(deg_to_rad(30))
 
 
-func _physics_process(_delta):
-	var motion = Vector2()
+func _physics_process(_delta: float) -> void:
+	var motion := Vector2()
 	motion.x = Input.get_axis(&"move_left", &"move_right")
 	motion.x = Input.get_axis(&"move_left", &"move_right")
 	motion.y = Input.get_axis(&"move_up", &"move_down")
 	motion.y = Input.get_axis(&"move_up", &"move_down")
 	# Make diagonal movement fit for hexagonal tiles.
 	# Make diagonal movement fit for hexagonal tiles.

+ 3 - 2
2d/hexagonal_map/troll.tscn

@@ -15,7 +15,9 @@ texture = ExtResource("2")
 [node name="Shadow" type="Sprite2D" parent="."]
 [node name="Shadow" type="Sprite2D" parent="."]
 modulate = Color(0, 0, 0, 0.501961)
 modulate = Color(0, 0, 0, 0.501961)
 show_behind_parent = true
 show_behind_parent = true
-position = Vector2(3, 3)
+position = Vector2(16.4422, 4.89438)
+scale = Vector2(0.794259, 1.04505)
+skew = 0.523599
 texture = ExtResource("2")
 texture = ExtResource("2")
 
 
 [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
 [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
@@ -23,4 +25,3 @@ position = Vector2(3.24216, 19.453)
 shape = SubResource("1")
 shape = SubResource("1")
 
 
 [node name="Camera2D" type="Camera2D" parent="."]
 [node name="Camera2D" type="Camera2D" parent="."]
-current = true

+ 8 - 8
2d/instancing/ball.tscn

@@ -1,18 +1,18 @@
-[gd_scene load_steps=4 format=2]
+[gd_scene load_steps=4 format=3 uid="uid://cgx884jv27maj"]
 
 
-[ext_resource path="res://bowling_ball.png" type="Texture2D" id=1]
+[ext_resource type="Texture2D" uid="uid://cyqshsjd3qwo0" path="res://bowling_ball.png" id="1"]
 
 
-[sub_resource type="PhysicsMaterial" id=1]
+[sub_resource type="PhysicsMaterial" id="1"]
 bounce = 0.4
 bounce = 0.4
 
 
-[sub_resource type="CircleShape2D" id=2]
+[sub_resource type="CircleShape2D" id="2"]
 radius = 30.0
 radius = 30.0
 
 
-[node name="Ball" type="RigidDynamicBody2D"]
-physics_material_override = SubResource( 1 )
+[node name="Ball" type="RigidBody2D"]
+physics_material_override = SubResource("1")
 
 
 [node name="Sprite2D" type="Sprite2D" parent="."]
 [node name="Sprite2D" type="Sprite2D" parent="."]
-texture = ExtResource( 1 )
+texture = ExtResource("1")
 
 
 [node name="Collision" type="CollisionShape2D" parent="."]
 [node name="Collision" type="CollisionShape2D" parent="."]
-shape = SubResource( 2 )
+shape = SubResource("2")

+ 4 - 3
2d/instancing/ball_factory.gd

@@ -2,15 +2,16 @@ extends Node2D
 
 
 @export var ball_scene: PackedScene = preload("res://ball.tscn")
 @export var ball_scene: PackedScene = preload("res://ball.tscn")
 
 
-func _unhandled_input(event):
+func _unhandled_input(event: InputEvent) -> void:
 	if event.is_echo():
 	if event.is_echo():
 		return
 		return
+
 	if event is InputEventMouseButton and event.is_pressed():
 	if event is InputEventMouseButton and event.is_pressed():
 		if event.button_index == MOUSE_BUTTON_LEFT:
 		if event.button_index == MOUSE_BUTTON_LEFT:
 			spawn(get_global_mouse_position())
 			spawn(get_global_mouse_position())
 
 
 
 
-func spawn(spawn_global_position):
-	var instance = ball_scene.instantiate()
+func spawn(spawn_global_position: Vector2) -> void:
+	var instance: Node2D = ball_scene.instantiate()
 	instance.global_position = spawn_global_position
 	instance.global_position = spawn_global_position
 	add_child(instance)
 	add_child(instance)

+ 5 - 0
2d/instancing/project.godot

@@ -18,6 +18,10 @@ run/main_scene="res://scene_instancing.tscn"
 config/features=PackedStringArray("4.2")
 config/features=PackedStringArray("4.2")
 config/icon="res://icon.webp"
 config/icon="res://icon.webp"
 
 
+[debug]
+
+gdscript/warnings/untyped_declaration=1
+
 [display]
 [display]
 
 
 window/stretch/mode="canvas_items"
 window/stretch/mode="canvas_items"
@@ -25,6 +29,7 @@ window/stretch/aspect="expand"
 
 
 [physics]
 [physics]
 
 
+common/physics_ticks_per_second=120
 2d/default_gravity=300
 2d/default_gravity=300
 
 
 [rendering]
 [rendering]

+ 4 - 2
2d/instancing/scene_instancing.tscn

@@ -1,7 +1,7 @@
 [gd_scene load_steps=13 format=3 uid="uid://rcsr8t4nw526"]
 [gd_scene load_steps=13 format=3 uid="uid://rcsr8t4nw526"]
 
 
 [ext_resource type="Script" path="res://ball_factory.gd" id="1"]
 [ext_resource type="Script" path="res://ball_factory.gd" id="1"]
-[ext_resource type="PackedScene" path="res://ball.tscn" id="2"]
+[ext_resource type="PackedScene" uid="uid://cgx884jv27maj" path="res://ball.tscn" id="2"]
 
 
 [sub_resource type="PhysicsMaterial" id="1"]
 [sub_resource type="PhysicsMaterial" id="1"]
 bounce = 0.4
 bounce = 0.4
@@ -35,7 +35,9 @@ bounce = 0.4
 
 
 [node name="SceneInstancing" type="Node2D"]
 [node name="SceneInstancing" type="Node2D"]
 
 
-[node name="InfoLabel" type="Label" parent="."]
+[node name="CanvasLayer" type="CanvasLayer" parent="."]
+
+[node name="InfoLabel" type="Label" parent="CanvasLayer"]
 offset_left = 16.0
 offset_left = 16.0
 offset_top = 16.0
 offset_top = 16.0
 offset_right = 370.0
 offset_right = 370.0

+ 1 - 1
2d/kinematic_character/level/princess.gd

@@ -1,5 +1,5 @@
 extends Node
 extends Node
 
 
-func _on_body_entered(body):
+func _on_body_entered(body: Node2D) -> void:
 	if body.name == "Player":
 	if body.name == "Player":
 		$"../WinText".show()
 		$"../WinText".show()

+ 3 - 3
2d/kinematic_character/player/player.gd

@@ -5,11 +5,11 @@ const WALK_MAX_SPEED = 200
 const STOP_FORCE = 1300
 const STOP_FORCE = 1300
 const JUMP_SPEED = 200
 const JUMP_SPEED = 200
 
 
-@onready var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
+@onready var gravity := float(ProjectSettings.get_setting("physics/2d/default_gravity"))
 
 
-func _physics_process(delta):
+func _physics_process(delta: float) -> void:
 	# Horizontal movement code. First, get the player's input.
 	# Horizontal movement code. First, get the player's input.
-	var walk = WALK_FORCE * (Input.get_axis(&"move_left", &"move_right"))
+	var walk := WALK_FORCE * (Input.get_axis(&"move_left", &"move_right"))
 	# Slow down the player if they're not trying to move.
 	# Slow down the player if they're not trying to move.
 	if abs(walk) < WALK_FORCE * 0.2:
 	if abs(walk) < WALK_FORCE * 0.2:
 		# The velocity, slowed down a bit, and then reassigned.
 		# The velocity, slowed down a bit, and then reassigned.

+ 4 - 0
2d/kinematic_character/project.godot

@@ -19,6 +19,10 @@ run/main_scene="res://world.tscn"
 config/features=PackedStringArray("4.2")
 config/features=PackedStringArray("4.2")
 config/icon="res://icon.webp"
 config/icon="res://icon.webp"
 
 
+[debug]
+
+gdscript/warnings/untyped_declaration=1
+
 [display]
 [display]
 
 
 window/size/viewport_width=530
 window/size/viewport_width=530

+ 4 - 0
2d/light2d_as_mask/project.godot

@@ -17,6 +17,10 @@ run/main_scene="res://lightmask.tscn"
 config/features=PackedStringArray("4.2")
 config/features=PackedStringArray("4.2")
 config/icon="res://icon.webp"
 config/icon="res://icon.webp"
 
 
+[debug]
+
+gdscript/warnings/untyped_declaration=1
+
 [display]
 [display]
 
 
 window/stretch/mode="canvas_items"
 window/stretch/mode="canvas_items"

+ 1 - 1
2d/lights_and_shadows/light_shadows.gd

@@ -1,7 +1,7 @@
 extends Node2D
 extends Node2D
 
 
 
 
-func _input(event):
+func _input(event: InputEvent) -> void:
 	if event.is_action_pressed("toggle_directional_light"):
 	if event.is_action_pressed("toggle_directional_light"):
 		$DirectionalLight2D.visible = not $DirectionalLight2D.visible
 		$DirectionalLight2D.visible = not $DirectionalLight2D.visible
 
 

+ 4 - 0
2d/lights_and_shadows/project.godot

@@ -18,6 +18,10 @@ run/main_scene="res://light_shadows.tscn"
 config/features=PackedStringArray("4.2")
 config/features=PackedStringArray("4.2")
 config/icon="res://icon.webp"
 config/icon="res://icon.webp"
 
 
+[debug]
+
+gdscript/warnings/untyped_declaration=1
+
 [display]
 [display]
 
 
 window/size/viewport_width=800
 window/size/viewport_width=800

+ 6 - 6
2d/navigation/character.gd

@@ -1,11 +1,10 @@
 extends CharacterBody2D
 extends CharacterBody2D
 
 
+var movement_speed := 200.0
 
 
-var movement_speed: float = 200.0
 @onready var navigation_agent: NavigationAgent2D = $NavigationAgent2D
 @onready var navigation_agent: NavigationAgent2D = $NavigationAgent2D
 
 
-
-func _ready():
+func _ready() -> void:
 	# These values need to be adjusted for the actor's speed
 	# These values need to be adjusted for the actor's speed
 	# and the navigation layout.
 	# and the navigation layout.
 	navigation_agent.path_desired_distance = 2.0
 	navigation_agent.path_desired_distance = 2.0
@@ -15,17 +14,18 @@ func _ready():
 
 
 # The "click" event is a custom input action defined in
 # The "click" event is a custom input action defined in
 # Project > Project Settings > Input Map tab.
 # Project > Project Settings > Input Map tab.
-func _unhandled_input(event):
+func _unhandled_input(event: InputEvent) -> void:
 	if not event.is_action_pressed("click"):
 	if not event.is_action_pressed("click"):
 		return
 		return
+
 	set_movement_target(get_global_mouse_position())
 	set_movement_target(get_global_mouse_position())
 
 
 
 
-func set_movement_target(movement_target: Vector2):
+func set_movement_target(movement_target: Vector2) -> void:
 	navigation_agent.target_position = movement_target
 	navigation_agent.target_position = movement_target
 
 
 
 
-func _physics_process(_delta):
+func _physics_process(_delta: float) -> void:
 	if navigation_agent.is_navigation_finished():
 	if navigation_agent.is_navigation_finished():
 		return
 		return
 
 

+ 8 - 0
2d/navigation/project.godot

@@ -19,6 +19,10 @@ run/main_scene="res://navigation.tscn"
 config/features=PackedStringArray("4.2")
 config/features=PackedStringArray("4.2")
 config/icon="res://icon.webp"
 config/icon="res://icon.webp"
 
 
+[debug]
+
+gdscript/warnings/untyped_declaration=1
+
 [display]
 [display]
 
 
 window/size/viewport_width=800
 window/size/viewport_width=800
@@ -33,6 +37,10 @@ click={
 ]
 ]
 }
 }
 
 
+[physics]
+
+common/physics_ticks_per_second=120
+
 [rendering]
 [rendering]
 
 
 renderer/rendering_method="gl_compatibility"
 renderer/rendering_method="gl_compatibility"

+ 20 - 16
2d/navigation_astar/character.gd

@@ -1,29 +1,33 @@
 extends Node2D
 extends Node2D
 
 
-enum State { IDLE, FOLLOW }
+enum State {
+	IDLE,
+	FOLLOW,
+}
 
 
 const MASS = 10.0
 const MASS = 10.0
 const ARRIVE_DISTANCE = 10.0
 const ARRIVE_DISTANCE = 10.0
 
 
-@export var speed: float = 200.0
+@export_range(10, 500, 0.1, "or_greater") var speed := 200.0
 
 
-var _state = State.IDLE
-var _velocity = Vector2()
+var _state := State.IDLE
+var _velocity := Vector2()
 
 
-@onready var _tile_map = $"../TileMap"
+var _click_position := Vector2()
+var _path := PackedVector2Array()
+var _next_point := Vector2()
 
 
-var _click_position = Vector2()
-var _path = PackedVector2Array()
-var _next_point = Vector2()
+@onready var _tile_map: TileMap = $"../TileMap"
 
 
-func _ready():
+func _ready() -> void:
 	_change_state(State.IDLE)
 	_change_state(State.IDLE)
 
 
 
 
-func _process(_delta):
+func _process(_delta: float) -> void:
 	if _state != State.FOLLOW:
 	if _state != State.FOLLOW:
 		return
 		return
-	var arrived_to_next_point = _move_to(_next_point)
+
+	var arrived_to_next_point := _move_to(_next_point)
 	if arrived_to_next_point:
 	if arrived_to_next_point:
 		_path.remove_at(0)
 		_path.remove_at(0)
 		if _path.is_empty():
 		if _path.is_empty():
@@ -32,7 +36,7 @@ func _process(_delta):
 		_next_point = _path[0]
 		_next_point = _path[0]
 
 
 
 
-func _unhandled_input(event):
+func _unhandled_input(event: InputEvent) -> void:
 	_click_position = get_global_mouse_position()
 	_click_position = get_global_mouse_position()
 	if _tile_map.is_point_walkable(_click_position):
 	if _tile_map.is_point_walkable(_click_position):
 		if event.is_action_pressed(&"teleport_to", false, true):
 		if event.is_action_pressed(&"teleport_to", false, true):
@@ -42,16 +46,16 @@ func _unhandled_input(event):
 			_change_state(State.FOLLOW)
 			_change_state(State.FOLLOW)
 
 
 
 
-func _move_to(local_position):
-	var desired_velocity = (local_position - position).normalized() * speed
-	var steering = desired_velocity - _velocity
+func _move_to(local_position: Vector2) -> float:
+	var desired_velocity := (local_position - position).normalized() * speed
+	var steering := desired_velocity - _velocity
 	_velocity += steering / MASS
 	_velocity += steering / MASS
 	position += _velocity * get_process_delta_time()
 	position += _velocity * get_process_delta_time()
 	rotation = _velocity.angle()
 	rotation = _velocity.angle()
 	return position.distance_to(local_position) < ARRIVE_DISTANCE
 	return position.distance_to(local_position) < ARRIVE_DISTANCE
 
 
 
 
-func _change_state(new_state):
+func _change_state(new_state: State) -> void:
 	if new_state == State.IDLE:
 	if new_state == State.IDLE:
 		_tile_map.clear_path()
 		_tile_map.clear_path()
 	elif new_state == State.FOLLOW:
 	elif new_state == State.FOLLOW:

+ 19 - 15
2d/navigation_astar/pathfind_astar.gd

@@ -1,19 +1,23 @@
 extends TileMap
 extends TileMap
 
 
-enum Tile { OBSTACLE, START_POINT, END_POINT }
+enum Tile {
+	OBSTACLE,
+	START_POINT,
+	END_POINT,
+}
 
 
 const CELL_SIZE = Vector2i(64, 64)
 const CELL_SIZE = Vector2i(64, 64)
 const BASE_LINE_WIDTH = 3.0
 const BASE_LINE_WIDTH = 3.0
 const DRAW_COLOR = Color.WHITE * Color(1, 1, 1, 0.5)
 const DRAW_COLOR = Color.WHITE * Color(1, 1, 1, 0.5)
 
 
 # The object for pathfinding on 2D grids.
 # The object for pathfinding on 2D grids.
-var _astar = AStarGrid2D.new()
+var _astar := AStarGrid2D.new()
 
 
-var _start_point = Vector2i()
-var _end_point = Vector2i()
-var _path = PackedVector2Array()
+var _start_point := Vector2i()
+var _end_point := Vector2i()
+var _path := PackedVector2Array()
 
 
-func _ready():
+func _ready() -> void:
 	# Region should match the size of the playable area plus one (in tiles).
 	# Region should match the size of the playable area plus one (in tiles).
 	# In this demo, the playable area is 17×9 tiles, so the rect size is 18×10.
 	# In this demo, the playable area is 17×9 tiles, so the rect size is 18×10.
 	_astar.region = Rect2i(0, 0, 18, 10)
 	_astar.region = Rect2i(0, 0, 18, 10)
@@ -26,35 +30,35 @@ func _ready():
 
 
 	for i in range(_astar.region.position.x, _astar.region.end.x):
 	for i in range(_astar.region.position.x, _astar.region.end.x):
 		for j in range(_astar.region.position.y, _astar.region.end.y):
 		for j in range(_astar.region.position.y, _astar.region.end.y):
-			var pos = Vector2i(i, j)
+			var pos := Vector2i(i, j)
 			if get_cell_source_id(0, pos) == Tile.OBSTACLE:
 			if get_cell_source_id(0, pos) == Tile.OBSTACLE:
 				_astar.set_point_solid(pos)
 				_astar.set_point_solid(pos)
 
 
 
 
-func _draw():
+func _draw() -> void:
 	if _path.is_empty():
 	if _path.is_empty():
 		return
 		return
 
 
-	var last_point = _path[0]
+	var last_point := _path[0]
 	for index in range(1, len(_path)):
 	for index in range(1, len(_path)):
-		var current_point = _path[index]
+		var current_point := _path[index]
 		draw_line(last_point, current_point, DRAW_COLOR, BASE_LINE_WIDTH, true)
 		draw_line(last_point, current_point, DRAW_COLOR, BASE_LINE_WIDTH, true)
 		draw_circle(current_point, BASE_LINE_WIDTH * 2.0, DRAW_COLOR)
 		draw_circle(current_point, BASE_LINE_WIDTH * 2.0, DRAW_COLOR)
 		last_point = current_point
 		last_point = current_point
 
 
 
 
-func round_local_position(local_position):
+func round_local_position(local_position: Vector2i) -> Vector2i:
 	return map_to_local(local_to_map(local_position))
 	return map_to_local(local_to_map(local_position))
 
 
 
 
-func is_point_walkable(local_position):
-	var map_position = local_to_map(local_position)
+func is_point_walkable(local_position: Vector2i) -> bool:
+	var map_position := local_to_map(local_position)
 	if _astar.is_in_boundsv(map_position):
 	if _astar.is_in_boundsv(map_position):
 		return not _astar.is_point_solid(map_position)
 		return not _astar.is_point_solid(map_position)
 	return false
 	return false
 
 
 
 
-func clear_path():
+func clear_path() -> void:
 	if not _path.is_empty():
 	if not _path.is_empty():
 		_path.clear()
 		_path.clear()
 		erase_cell(0, _start_point)
 		erase_cell(0, _start_point)
@@ -63,7 +67,7 @@ func clear_path():
 		queue_redraw()
 		queue_redraw()
 
 
 
 
-func find_path(local_start_point, local_end_point):
+func find_path(local_start_point: Vector2i, local_end_point: Vector2i) -> PackedVector2Array:
 	clear_path()
 	clear_path()
 
 
 	_start_point = local_to_map(local_start_point)
 	_start_point = local_to_map(local_start_point)

+ 4 - 0
2d/navigation_astar/project.godot

@@ -18,6 +18,10 @@ run/main_scene="res://game.tscn"
 config/features=PackedStringArray("4.2")
 config/features=PackedStringArray("4.2")
 config/icon="res://icon.webp"
 config/icon="res://icon.webp"
 
 
+[debug]
+
+gdscript/warnings/untyped_declaration=1
+
 [display]
 [display]
 
 
 window/stretch/mode="canvas_items"
 window/stretch/mode="canvas_items"

File diff suppressed because it is too large
+ 5 - 7
2d/particles/particles.tscn


+ 1 - 1
2d/particles/pause.gd

@@ -1,7 +1,7 @@
 extends Label
 extends Label
 
 
 
 
-func _input(event):
+func _input(event: InputEvent) -> void:
 	if event.is_action_pressed("toggle_pause"):
 	if event.is_action_pressed("toggle_pause"):
 		get_tree().paused = not get_tree().paused
 		get_tree().paused = not get_tree().paused
 
 

+ 4 - 0
2d/particles/project.godot

@@ -17,6 +17,10 @@ run/main_scene="res://particles.tscn"
 config/features=PackedStringArray("4.2")
 config/features=PackedStringArray("4.2")
 config/icon="res://icon.webp"
 config/icon="res://icon.webp"
 
 
+[debug]
+
+gdscript/warnings/untyped_declaration=1
+
 [display]
 [display]
 
 
 window/stretch/mode="canvas_items"
 window/stretch/mode="canvas_items"

+ 2 - 2
2d/physics_platformer/coin/coin.gd

@@ -1,8 +1,8 @@
 class_name Coin
 class_name Coin
 extends Area2D
 extends Area2D
 
 
-var taken = false
+var taken := false
 
 
-func _on_body_enter(body):
+func _on_body_enter(body: Node2D) -> void:
 	if not taken and body is Player:
 	if not taken and body is Player:
 		($AnimationPlayer as AnimationPlayer).play("taken")
 		($AnimationPlayer as AnimationPlayer).play("taken")

+ 0 - 1
2d/physics_platformer/enemy/enemy.gd

@@ -1,7 +1,6 @@
 class_name Enemy
 class_name Enemy
 extends RigidBody2D
 extends RigidBody2D
 
 
-
 const WALK_SPEED = 50
 const WALK_SPEED = 50
 
 
 enum State {
 enum State {

+ 1 - 1
2d/physics_platformer/enemy/enemy.tscn

@@ -48,7 +48,7 @@ tracks/0/loop_wrap = true
 tracks/0/keys = {
 tracks/0/keys = {
 "times": PackedFloat32Array(0),
 "times": PackedFloat32Array(0),
 "transitions": PackedFloat32Array(1),
 "transitions": PackedFloat32Array(1),
-"update": 0,
+"update": 1,
 "values": [4]
 "values": [4]
 }
 }
 tracks/1/type = "value"
 tracks/1/type = "value"

+ 3 - 3
2d/physics_platformer/player/bullet.gd

@@ -1,13 +1,13 @@
 class_name Bullet
 class_name Bullet
 extends RigidBody2D
 extends RigidBody2D
 
 
-var disabled = false
+var disabled := false
 
 
-func _ready():
+func _ready() -> void:
 	($Timer as Timer).start()
 	($Timer as Timer).start()
 
 
 
 
-func disable():
+func disable() -> void:
 	if disabled:
 	if disabled:
 		return
 		return
 
 

+ 2 - 2
2d/physics_platformer/player/player.gd

@@ -50,7 +50,7 @@ func _integrate_forces(state: PhysicsDirectBodyState2D) -> void:
 	if spawn:
 	if spawn:
 		_spawn_enemy_above.call_deferred()
 		_spawn_enemy_above.call_deferred()
 
 
-	# Deapply prev floor velocity.
+	# Deapply previous floor velocity.
 	velocity.x -= floor_h_velocity
 	velocity.x -= floor_h_velocity
 	floor_h_velocity = 0.0
 	floor_h_velocity = 0.0
 
 
@@ -59,7 +59,7 @@ func _integrate_forces(state: PhysicsDirectBodyState2D) -> void:
 	var floor_index := -1
 	var floor_index := -1
 
 
 	for contact_index in state.get_contact_count():
 	for contact_index in state.get_contact_count():
-		var collision_normal = state.get_contact_local_normal(contact_index)
+		var collision_normal := state.get_contact_local_normal(contact_index)
 
 
 		if collision_normal.dot(Vector2(0, -1)) > 0.6:
 		if collision_normal.dot(Vector2(0, -1)) > 0.6:
 			found_floor = true
 			found_floor = true

+ 4 - 0
2d/physics_platformer/project.godot

@@ -20,6 +20,10 @@ run/main_scene="res://stage.tscn"
 config/features=PackedStringArray("4.2")
 config/features=PackedStringArray("4.2")
 config/icon="res://icon.webp"
 config/icon="res://icon.webp"
 
 
+[debug]
+
+gdscript/warnings/untyped_declaration=1
+
 [display]
 [display]
 
 
 window/size/viewport_width=800
 window/size/viewport_width=800

+ 2 - 2
2d/physics_tests/assets/tileset/tileset.tres

@@ -3,7 +3,7 @@
 [ext_resource type="Texture2D" uid="uid://1nmxl2dgdqro" path="res://assets/tileset/tiles_demo.png" id="1"]
 [ext_resource type="Texture2D" uid="uid://1nmxl2dgdqro" path="res://assets/tileset/tiles_demo.png" id="1"]
 
 
 [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_4jjf0"]
 [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_4jjf0"]
-texture = ExtResource( "1" )
+texture = ExtResource("1")
 0:0/next_alternative_id = 8
 0:0/next_alternative_id = 8
 0:0/0 = 0
 0:0/0 = 0
 0:0/0/modulate = Color(0, 0, 1, 1)
 0:0/0/modulate = Color(0, 0, 1, 1)
@@ -18,4 +18,4 @@ texture = ExtResource( "1" )
 
 
 [resource]
 [resource]
 physics_layer_0/collision_layer = 1
 physics_layer_0/collision_layer = 1
-sources/0 = SubResource( "TileSetAtlasSource_4jjf0" )
+sources/0 = SubResource("TileSetAtlasSource_4jjf0")

+ 16 - 8
2d/physics_tests/main.tscn

@@ -51,6 +51,8 @@ offset_top = -19.0
 offset_right = 50.0
 offset_right = 50.0
 offset_bottom = -5.0
 offset_bottom = -5.0
 grow_vertical = 0
 grow_vertical = 0
+theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
+theme_override_constants/outline_size = 4
 text = "FPS: 0"
 text = "FPS: 0"
 script = ExtResource("1")
 script = ExtResource("1")
 
 
@@ -60,10 +62,12 @@ anchors_preset = 2
 anchor_top = 1.0
 anchor_top = 1.0
 anchor_bottom = 1.0
 anchor_bottom = 1.0
 offset_left = 10.0
 offset_left = 10.0
-offset_top = -39.0
-offset_right = 50.0
-offset_bottom = -25.0
+offset_top = -56.0
+offset_right = 128.0
+offset_bottom = -33.0
 grow_vertical = 0
 grow_vertical = 0
+theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
+theme_override_constants/outline_size = 4
 text = "Physics engine:"
 text = "Physics engine:"
 script = ExtResource("3")
 script = ExtResource("3")
 
 
@@ -73,10 +77,12 @@ anchors_preset = 2
 anchor_top = 1.0
 anchor_top = 1.0
 anchor_bottom = 1.0
 anchor_bottom = 1.0
 offset_left = 10.0
 offset_left = 10.0
-offset_top = -59.0
-offset_right = 50.0
-offset_bottom = -45.0
+offset_top = -84.0
+offset_right = 125.0
+offset_bottom = -61.0
 grow_vertical = 0
 grow_vertical = 0
+theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
+theme_override_constants/outline_size = 4
 text = "Godot Version:"
 text = "Godot Version:"
 script = ExtResource("2")
 script = ExtResource("2")
 
 
@@ -86,10 +92,12 @@ anchors_preset = 2
 anchor_top = 1.0
 anchor_top = 1.0
 anchor_bottom = 1.0
 anchor_bottom = 1.0
 offset_left = 10.0
 offset_left = 10.0
-offset_top = -79.0
+offset_top = -112.0
 offset_right = 50.0
 offset_right = 50.0
-offset_bottom = -65.0
+offset_bottom = -89.0
 grow_vertical = 0
 grow_vertical = 0
+theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
+theme_override_constants/outline_size = 4
 text = "Test:"
 text = "Test:"
 script = ExtResource("5")
 script = ExtResource("5")
 
 

+ 12 - 7
2d/physics_tests/project.godot

@@ -21,6 +21,10 @@ config/icon="res://icon.webp"
 Log="*res://utils/system_log.gd"
 Log="*res://utils/system_log.gd"
 System="*res://utils/system.gd"
 System="*res://utils/system.gd"
 
 
+[debug]
+
+gdscript/warnings/untyped_declaration=1
+
 [display]
 [display]
 
 
 window/stretch/mode="canvas_items"
 window/stretch/mode="canvas_items"
@@ -51,7 +55,7 @@ toggle_full_screen={
 }
 }
 exit={
 exit={
 "deadzone": 0.2,
 "deadzone": 0.2,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":16777217,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
+"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194305,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
 ]
 ]
 }
 }
 toggle_debug_collision={
 toggle_debug_collision={
@@ -71,20 +75,21 @@ toggle_pause={
 }
 }
 character_left={
 character_left={
 "deadzone": 0.2,
 "deadzone": 0.2,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":16777231,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
-, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":65,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
+"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":113,"echo":false,"script":null)
+, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
 ]
 ]
 }
 }
 character_right={
 character_right={
 "deadzone": 0.2,
 "deadzone": 0.2,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":16777233,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
-, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":68,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
+"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null)
+, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
 ]
 ]
 }
 }
 character_jump={
 character_jump={
 "deadzone": 0.2,
 "deadzone": 0.2,
-"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":16777232,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
-, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":87,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
+"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":122,"echo":false,"script":null)
+, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
+, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null)
 ]
 ]
 }
 }
 
 

+ 36 - 37
2d/physics_tests/test.gd

@@ -1,42 +1,40 @@
 class_name Test
 class_name Test
 extends Node2D
 extends Node2D
 
 
-
 signal wait_done()
 signal wait_done()
 
 
-@export var _enable_debug_collision = true
+@export var _enable_debug_collision := true
 
 
-var _timer
-var _timer_started = false
+var _timer: Timer
+var _timer_started := false
 
 
-var _wait_physics_ticks_counter = 0
+var _wait_physics_ticks_counter := 0
 
 
 class Circle2D:
 class Circle2D:
 	extends Node2D
 	extends Node2D
-	var center
-	var radius
-	var color
+	var center := Vector2()
+	var radius := 0.0
+	var color := Color()
 
 
-	func _draw():
+	func _draw() -> void:
 		draw_circle(center, radius, color)
 		draw_circle(center, radius, color)
 
 
-var _drawn_nodes = []
-
+var _drawn_nodes := []
 
 
-func _enter_tree():
+func _enter_tree() -> void:
 	if not _enable_debug_collision:
 	if not _enable_debug_collision:
 		get_tree().debug_collisions_hint = false
 		get_tree().debug_collisions_hint = false
 
 
 
 
-func _physics_process(_delta):
+func _physics_process(_delta: float) -> void:
 	if _wait_physics_ticks_counter > 0:
 	if _wait_physics_ticks_counter > 0:
 		_wait_physics_ticks_counter -= 1
 		_wait_physics_ticks_counter -= 1
 		if _wait_physics_ticks_counter == 0:
 		if _wait_physics_ticks_counter == 0:
 			wait_done.emit()
 			wait_done.emit()
 
 
 
 
-func add_line(pos_start, pos_end, color):
-	var line = Line2D.new()
+func add_line(pos_start: Vector2, pos_end: Vector2, color: Color) -> void:
+	var line := Line2D.new()
 	line.points = [pos_start, pos_end]
 	line.points = [pos_start, pos_end]
 	line.width = 1.5
 	line.width = 1.5
 	line.default_color = color
 	line.default_color = color
@@ -44,8 +42,8 @@ func add_line(pos_start, pos_end, color):
 	add_child(line)
 	add_child(line)
 
 
 
 
-func add_circle(pos, radius, color):
-	var circle = Circle2D.new()
+func add_circle(pos: Vector2, radius: float, color: Color) -> void:
+	var circle := Circle2D.new()
 	circle.center = pos
 	circle.center = pos
 	circle.radius = radius
 	circle.radius = radius
 	circle.color = color
 	circle.color = color
@@ -53,8 +51,8 @@ func add_circle(pos, radius, color):
 	add_child(circle)
 	add_child(circle)
 
 
 
 
-func add_shape(shape, shape_transform, color):
-	var collision = CollisionShape2D.new()
+func add_shape(shape: Shape2D, shape_transform: Transform2D, color: Color) -> void:
+	var collision := CollisionShape2D.new()
 	collision.shape = shape
 	collision.shape = shape
 	collision.transform = shape_transform
 	collision.transform = shape_transform
 	collision.modulate = color
 	collision.modulate = color
@@ -62,36 +60,36 @@ func add_shape(shape, shape_transform, color):
 	add_child(collision)
 	add_child(collision)
 
 
 
 
-func clear_drawn_nodes():
-	for node in _drawn_nodes:
+func clear_drawn_nodes() -> void:
+	for node: Node in _drawn_nodes:
 		node.queue_free()
 		node.queue_free()
 	_drawn_nodes.clear()
 	_drawn_nodes.clear()
 
 
 
 
-func create_rigidbody(shape, pickable = false, shape_transform = Transform2D.IDENTITY):
-	var collision = CollisionShape2D.new()
+func create_rigidbody(shape: Shape2D, pickable: bool = false, shape_transform: Transform2D = Transform2D.IDENTITY) -> RigidBody2D:
+	var collision := CollisionShape2D.new()
 	collision.shape = shape
 	collision.shape = shape
 	collision.transform = shape_transform
 	collision.transform = shape_transform
 
 
-	var body = RigidBody2D.new()
+	var body := RigidBody2D.new()
 	body.add_child(collision)
 	body.add_child(collision)
 
 
 	if pickable:
 	if pickable:
-		var script = load("res://utils/rigidbody_pick.gd")
+		var script := load("res://utils/rigidbody_pick.gd")
 		body.set_script(script)
 		body.set_script(script)
 
 
 	return body
 	return body
 
 
 
 
-func create_rigidbody_box(size, pickable = false, use_icon = false, shape_transform = Transform2D.IDENTITY):
-	var shape = RectangleShape2D.new()
+func create_rigidbody_box(size: Vector2, pickable: bool = false, use_icon: bool = false, shape_transform: Transform2D = Transform2D.IDENTITY) -> RigidBody2D:
+	var shape := RectangleShape2D.new()
 	shape.size = size
 	shape.size = size
 
 
-	var body = create_rigidbody(shape, pickable, shape_transform)
+	var body := create_rigidbody(shape, pickable, shape_transform)
 
 
 	if use_icon:
 	if use_icon:
-		var texture = load("res://icon.webp")
-		var icon = Sprite2D.new()
+		var texture := load("res://icon.webp")
+		var icon := Sprite2D.new()
 		icon.texture = texture
 		icon.texture = texture
 		icon.scale = size / texture.get_size()
 		icon.scale = size / texture.get_size()
 		body.add_child(icon)
 		body.add_child(icon)
@@ -99,14 +97,15 @@ func create_rigidbody_box(size, pickable = false, use_icon = false, shape_transf
 	return body
 	return body
 
 
 
 
-func find_node(node_name):
-	var nodes = find_children(node_name)
+func find_node(node_name: String) -> Node:
+	var nodes := find_children(node_name)
 	if nodes.size() > 0:
 	if nodes.size() > 0:
 		return nodes[0]
 		return nodes[0]
+
 	return null
 	return null
 
 
 
 
-func start_timer(timeout):
+func start_timer(timeout: float) -> Timer:
 	if _timer == null:
 	if _timer == null:
 		_timer = Timer.new()
 		_timer = Timer.new()
 		_timer.one_shot = true
 		_timer.one_shot = true
@@ -121,21 +120,21 @@ func start_timer(timeout):
 	return _timer
 	return _timer
 
 
 
 
-func cancel_timer():
+func cancel_timer() -> void:
 	if _timer_started:
 	if _timer_started:
 		_timer.paused = true
 		_timer.paused = true
 		_timer.timeout.emit()
 		_timer.timeout.emit()
 		_timer.paused = false
 		_timer.paused = false
 
 
 
 
-func is_timer_canceled():
+func is_timer_canceled() -> bool:
 	return _timer and _timer.paused
 	return _timer and _timer.paused
 
 
 
 
-func wait_for_physics_ticks(tick_count):
+func wait_for_physics_ticks(tick_count: int) -> Test:
 	_wait_physics_ticks_counter = tick_count
 	_wait_physics_ticks_counter = tick_count
 	return self
 	return self
 
 
 
 
-func _on_timer_done():
+func _on_timer_done() -> void:
 	_timer_started = false
 	_timer_started = false

+ 4 - 5
2d/physics_tests/tests.gd

@@ -1,7 +1,6 @@
 extends Node
 extends Node
 
 
-
-var _tests = [
+var _tests := [
 	{
 	{
 		"id": "Functional Tests/Shapes",
 		"id": "Functional Tests/Shapes",
 		"path": "res://tests/functional/test_shapes.tscn",
 		"path": "res://tests/functional/test_shapes.tscn",
@@ -57,7 +56,7 @@ var _tests = [
 ]
 ]
 
 
 
 
-func _ready():
-	var test_menu = $TestsMenu
-	for test in _tests:
+func _ready() -> void:
+	var test_menu: OptionMenu = $TestsMenu
+	for test: Variant in _tests:
 		test_menu.add_test(test.id, test.path)
 		test_menu.add_test(test.id, test.path)

+ 46 - 48
2d/physics_tests/tests/functional/test_character.gd

@@ -1,8 +1,7 @@
-extends Test
-class_name TestCharacter
+class_name Test
+extends TestCharacter
 
 
-
-enum E_BodyType {
+enum BodyType {
 	CHARACTER_BODY,
 	CHARACTER_BODY,
 	CHARACTER_BODY_RAY,
 	CHARACTER_BODY_RAY,
 	RIGID_BODY,
 	RIGID_BODY,
@@ -19,31 +18,31 @@ const OPTION_MOVE_CHARACTER_STOP_ON_SLOPE = "Move Options/Use stop on slope (Cha
 const OPTION_MOVE_CHARACTER_FLOOR_ONLY = "Move Options/Move on floor only (Character only)"
 const OPTION_MOVE_CHARACTER_FLOOR_ONLY = "Move Options/Move on floor only (Character only)"
 const OPTION_MOVE_CHARACTER_CONSTANT_SPEED = "Move Options/Use constant speed (Character only)"
 const OPTION_MOVE_CHARACTER_CONSTANT_SPEED = "Move Options/Use constant speed (Character only)"
 
 
-@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 _body_type: E_BodyType = 0
+@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 _body_type := BodyType.CHARACTER_BODY
 
 
-@onready var options = $Options
+@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 := true
+var _use_stop_on_slope := true
+var _use_floor_only := true
+var _use_constant_speed := false
 
 
 var _body_parent: Node = null
 var _body_parent: Node = null
-var _character_body_template = null
-var _character_body_ray_template = null
-var _rigid_body_template = null
-var _rigid_body_ray_template = null
+var _character_body_template: CharacterBody2D = null
+var _character_body_ray_template: CharacterBody2D = null
+var _rigid_body_template: RigidBody2D = null
+var _rigid_body_ray_template: RigidBody2D = null
 var _moving_body: PhysicsBody2D = null
 var _moving_body: PhysicsBody2D = null
 
 
 
 
-func _ready():
+func _ready() -> void:
 	options.option_selected.connect(_on_option_selected)
 	options.option_selected.connect(_on_option_selected)
 	options.option_changed.connect(_on_option_changed)
 	options.option_changed.connect(_on_option_changed)
 
 
@@ -51,28 +50,28 @@ func _ready():
 	if _character_body_template:
 	if _character_body_template:
 		_body_parent = _character_body_template.get_parent()
 		_body_parent = _character_body_template.get_parent()
 		_body_parent.remove_child(_character_body_template)
 		_body_parent.remove_child(_character_body_template)
-		var enabled = _body_type == E_BodyType.CHARACTER_BODY
+		var enabled := _body_type == BodyType.CHARACTER_BODY
 		options.add_menu_item(OPTION_OBJECT_TYPE_CHARACTER, true, enabled, true)
 		options.add_menu_item(OPTION_OBJECT_TYPE_CHARACTER, true, enabled, true)
 
 
 	_character_body_ray_template = find_child("CharacterBodyRay2D")
 	_character_body_ray_template = find_child("CharacterBodyRay2D")
 	if _character_body_ray_template:
 	if _character_body_ray_template:
 		_body_parent = _character_body_ray_template.get_parent()
 		_body_parent = _character_body_ray_template.get_parent()
 		_body_parent.remove_child(_character_body_ray_template)
 		_body_parent.remove_child(_character_body_ray_template)
-		var enabled = _body_type == E_BodyType.CHARACTER_BODY_RAY
+		var enabled := _body_type == BodyType.CHARACTER_BODY_RAY
 		options.add_menu_item(OPTION_OBJECT_TYPE_CHARACTER_RAY, true, enabled, true)
 		options.add_menu_item(OPTION_OBJECT_TYPE_CHARACTER_RAY, true, enabled, true)
 
 
 	_rigid_body_template = find_child("RigidBody2D")
 	_rigid_body_template = find_child("RigidBody2D")
 	if _rigid_body_template:
 	if _rigid_body_template:
 		_body_parent = _rigid_body_template.get_parent()
 		_body_parent = _rigid_body_template.get_parent()
 		_body_parent.remove_child(_rigid_body_template)
 		_body_parent.remove_child(_rigid_body_template)
-		var enabled = _body_type == E_BodyType.RIGID_BODY
+		var enabled := _body_type == BodyType.RIGID_BODY
 		options.add_menu_item(OPTION_OBJECT_TYPE_RIGID_BODY, true, enabled, true)
 		options.add_menu_item(OPTION_OBJECT_TYPE_RIGID_BODY, true, enabled, true)
 
 
 	_rigid_body_ray_template = find_child("RigidBodyRay2D")
 	_rigid_body_ray_template = find_child("RigidBodyRay2D")
 	if _rigid_body_ray_template:
 	if _rigid_body_ray_template:
 		_body_parent = _rigid_body_ray_template.get_parent()
 		_body_parent = _rigid_body_ray_template.get_parent()
 		_body_parent.remove_child(_rigid_body_ray_template)
 		_body_parent.remove_child(_rigid_body_ray_template)
-		var enabled = _body_type == E_BodyType.RIGID_BODY_RAY
+		var enabled := _body_type == BodyType.RIGID_BODY_RAY
 		options.add_menu_item(OPTION_OBJECT_TYPE_RIGID_BODY_RAY, true, enabled, true)
 		options.add_menu_item(OPTION_OBJECT_TYPE_RIGID_BODY_RAY, true, enabled, true)
 
 
 	options.add_menu_item(OPTION_MOVE_CHARACTER_SNAP, true, _use_snap)
 	options.add_menu_item(OPTION_MOVE_CHARACTER_SNAP, true, _use_snap)
@@ -80,15 +79,15 @@ func _ready():
 	options.add_menu_item(OPTION_MOVE_CHARACTER_FLOOR_ONLY, true, _use_floor_only)
 	options.add_menu_item(OPTION_MOVE_CHARACTER_FLOOR_ONLY, true, _use_floor_only)
 	options.add_menu_item(OPTION_MOVE_CHARACTER_CONSTANT_SPEED, true, _use_constant_speed)
 	options.add_menu_item(OPTION_MOVE_CHARACTER_CONSTANT_SPEED, true, _use_constant_speed)
 
 
-	var floor_slider = find_child("FloorMaxAngle")
+	var floor_slider: Control = find_child("FloorMaxAngle")
 	if floor_slider:
 	if floor_slider:
 		floor_slider.get_node("HSlider").value = _floor_max_angle
 		floor_slider.get_node("HSlider").value = _floor_max_angle
 
 
 	_start_test()
 	_start_test()
 
 
 
 
-func _process(_delta):
-	var label_floor = $LabelFloor
+func _process(_delta: float) -> void:
+	var label_floor: Label = $LabelFloor
 	if _moving_body:
 	if _moving_body:
 		if _moving_body.is_on_floor():
 		if _moving_body.is_on_floor():
 			label_floor.text = "ON FLOOR"
 			label_floor.text = "ON FLOOR"
@@ -100,8 +99,8 @@ func _process(_delta):
 		label_floor.visible = false
 		label_floor.visible = false
 
 
 
 
-func _input(event):
-	var key_event = event as InputEventKey
+func _input(event: InputEvent) -> void:
+	var key_event := event as InputEventKey
 	if key_event and not key_event.pressed:
 	if key_event and not key_event.pressed:
 		if key_event.keycode == KEY_1:
 		if key_event.keycode == KEY_1:
 			if _character_body_template:
 			if _character_body_template:
@@ -117,7 +116,7 @@ func _input(event):
 				_on_option_selected(OPTION_OBJECT_TYPE_RIGID_BODY_RAY)
 				_on_option_selected(OPTION_OBJECT_TYPE_RIGID_BODY_RAY)
 
 
 
 
-func _exit_tree():
+func _exit_tree() -> void:
 	if _character_body_template:
 	if _character_body_template:
 		_character_body_template.free()
 		_character_body_template.free()
 	if _character_body_ray_template:
 	if _character_body_ray_template:
@@ -128,23 +127,23 @@ func _exit_tree():
 		_rigid_body_ray_template.free()
 		_rigid_body_ray_template.free()
 
 
 
 
-func _on_option_selected(option):
+func _on_option_selected(option: String) -> void:
 	match option:
 	match option:
 		OPTION_OBJECT_TYPE_CHARACTER:
 		OPTION_OBJECT_TYPE_CHARACTER:
-			_body_type = E_BodyType.CHARACTER_BODY
+			_body_type = BodyType.CHARACTER_BODY
 			_start_test()
 			_start_test()
 		OPTION_OBJECT_TYPE_CHARACTER_RAY:
 		OPTION_OBJECT_TYPE_CHARACTER_RAY:
-			_body_type = E_BodyType.CHARACTER_BODY_RAY
+			_body_type = BodyType.CHARACTER_BODY_RAY
 			_start_test()
 			_start_test()
 		OPTION_OBJECT_TYPE_RIGID_BODY:
 		OPTION_OBJECT_TYPE_RIGID_BODY:
-			_body_type = E_BodyType.RIGID_BODY
+			_body_type = BodyType.RIGID_BODY
 			_start_test()
 			_start_test()
 		OPTION_OBJECT_TYPE_RIGID_BODY_RAY:
 		OPTION_OBJECT_TYPE_RIGID_BODY_RAY:
-			_body_type = E_BodyType.RIGID_BODY_RAY
+			_body_type = BodyType.RIGID_BODY_RAY
 			_start_test()
 			_start_test()
 
 
 
 
-func _on_option_changed(option, checked):
+func _on_option_changed(option: String, checked: bool) -> void:
 	match option:
 	match option:
 		OPTION_MOVE_CHARACTER_SNAP:
 		OPTION_MOVE_CHARACTER_SNAP:
 			_use_snap = checked
 			_use_snap = checked
@@ -164,8 +163,8 @@ func _on_option_changed(option, checked):
 				_moving_body._constant_speed = _use_constant_speed
 				_moving_body._constant_speed = _use_constant_speed
 
 
 
 
-func _update_floor_max_angle(value):
-	if (value == _floor_max_angle):
+func _update_floor_max_angle(value: float) -> void:
+	if value == _floor_max_angle:
 		return
 		return
 
 
 	_floor_max_angle = value
 	_floor_max_angle = value
@@ -173,7 +172,7 @@ func _update_floor_max_angle(value):
 		_moving_body._floor_max_angle = _floor_max_angle
 		_moving_body._floor_max_angle = _floor_max_angle
 
 
 
 
-func _start_test():
+func _start_test() -> void:
 	cancel_timer()
 	cancel_timer()
 
 
 	if _moving_body:
 	if _moving_body:
@@ -181,20 +180,19 @@ func _start_test():
 		_moving_body.queue_free()
 		_moving_body.queue_free()
 		_moving_body = null
 		_moving_body = null
 
 
-	var test_label = "Testing: "
+	var test_label := "Testing: "
 
 
-	var template = null
+	var template: PhysicsBody2D = null
 	match _body_type:
 	match _body_type:
-		E_BodyType.CHARACTER_BODY:
+		BodyType.CHARACTER_BODY:
 			template = _character_body_template
 			template = _character_body_template
-		E_BodyType.CHARACTER_BODY_RAY:
+		BodyType.CHARACTER_BODY_RAY:
 			template = _character_body_ray_template
 			template = _character_body_ray_template
-		E_BodyType.RIGID_BODY:
+		BodyType.RIGID_BODY:
 			template = _rigid_body_template
 			template = _rigid_body_template
-		E_BodyType.RIGID_BODY_RAY:
+		BodyType.RIGID_BODY_RAY:
 			template = _rigid_body_ray_template
 			template = _rigid_body_ray_template
 
 
-	test_label += String(template.name)
 	_moving_body = template.duplicate()
 	_moving_body = template.duplicate()
 	_body_parent.add_child(_moving_body)
 	_body_parent.add_child(_moving_body)
 
 

+ 24 - 26
2d/physics_tests/tests/functional/test_character_pixels.gd

@@ -1,29 +1,28 @@
 extends TestCharacter
 extends TestCharacter
 
 
-
 const OPTION_TEST_CASE_ALL = "Test Cases/TEST ALL (0)"
 const OPTION_TEST_CASE_ALL = "Test Cases/TEST ALL (0)"
 const OPTION_TEST_CASE_DETECT_FLOOR_NO_SNAP = "Test Cases/Floor detection (Character Body)"
 const OPTION_TEST_CASE_DETECT_FLOOR_NO_SNAP = "Test Cases/Floor detection (Character Body)"
 const OPTION_TEST_CASE_DETECT_FLOOR_MOTION_CHANGES = "Test Cases/Floor detection with motion changes (Character Body)"
 const OPTION_TEST_CASE_DETECT_FLOOR_MOTION_CHANGES = "Test Cases/Floor detection with motion changes (Character Body)"
 
 
 const MOTION_CHANGES_DIR = Vector2(1.0, 1.0)
 const MOTION_CHANGES_DIR = Vector2(1.0, 1.0)
-const MOTION_CHANGES_SPEEDS = [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
+const MOTION_CHANGES_SPEEDS: Array[float] = [0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0]
 
 
-var _failed_reason = ""
+var _test_floor_detection := false
+var _test_motion_changes := false
+var _floor_detected := false
+var _floor_lost := false
 
 
+var _failed_reason := ""
 
 
-func _ready():
+func _ready() -> void:
 	super._ready()
 	super._ready()
 
 
 	options.add_menu_item(OPTION_TEST_CASE_ALL)
 	options.add_menu_item(OPTION_TEST_CASE_ALL)
 	options.add_menu_item(OPTION_TEST_CASE_DETECT_FLOOR_NO_SNAP)
 	options.add_menu_item(OPTION_TEST_CASE_DETECT_FLOOR_NO_SNAP)
 	options.add_menu_item(OPTION_TEST_CASE_DETECT_FLOOR_MOTION_CHANGES)
 	options.add_menu_item(OPTION_TEST_CASE_DETECT_FLOOR_MOTION_CHANGES)
 
 
-func _physics_process(delta):
+
+func _physics_process(delta: float) -> void:
 	super._physics_process(delta)
 	super._physics_process(delta)
 
 
 	if _moving_body:
 	if _moving_body:
@@ -35,24 +34,23 @@ func _physics_process(delta):
 				Log.print_log("Floor lost.")
 				Log.print_log("Floor lost.")
 
 
 		if _test_motion_changes:
 		if _test_motion_changes:
-			var speed_count = MOTION_CHANGES_SPEEDS.size()
-			var speed_index = randi() % speed_count
-			var speed = MOTION_CHANGES_SPEEDS[speed_index]
-			var velocity = speed * MOTION_CHANGES_DIR
+			var speed_count := MOTION_CHANGES_SPEEDS.size()
+			var speed_index := randi() % speed_count
+			var speed := MOTION_CHANGES_SPEEDS[speed_index]
+			var velocity := speed * MOTION_CHANGES_DIR
 			_moving_body._constant_velocity = velocity
 			_moving_body._constant_velocity = velocity
 			#Log.print_log("Velocity: %s" % velocity)
 			#Log.print_log("Velocity: %s" % velocity)
 
 
 
 
-func _input(event):
+func _input(event: InputEvent) -> void:
 	super._input(event)
 	super._input(event)
 
 
-	var key_event = event as InputEventKey
-	if key_event and not key_event.pressed:
-		if key_event.keycode == KEY_0:
+	if event is InputEventKey and not event.pressed:
+		if event.keycode == KEY_0:
 			await _on_option_selected(OPTION_TEST_CASE_ALL)
 			await _on_option_selected(OPTION_TEST_CASE_ALL)
 
 
 
 
-func _on_option_selected(option):
+func _on_option_selected(option: String) -> void:
 	match option:
 	match option:
 		OPTION_TEST_CASE_ALL:
 		OPTION_TEST_CASE_ALL:
 			await _test_all()
 			await _test_all()
@@ -66,7 +64,7 @@ func _on_option_selected(option):
 	super._on_option_selected(option)
 	super._on_option_selected(option)
 
 
 
 
-func _start_test_case(option):
+func _start_test_case(option: String) -> void:
 	Log.print_log("* Starting " + option)
 	Log.print_log("* Starting " + option)
 
 
 	match option:
 	match option:
@@ -74,7 +72,7 @@ func _start_test_case(option):
 			_test_floor_detection = true
 			_test_floor_detection = true
 			_test_motion_changes = false
 			_test_motion_changes = false
 			_use_snap = false
 			_use_snap = false
-			_body_type = E_BodyType.CHARACTER_BODY
+			_body_type = BodyType.CHARACTER_BODY
 			_start_test()
 			_start_test()
 
 
 			await start_timer(1.0).timeout
 			await start_timer(1.0).timeout
@@ -86,7 +84,7 @@ func _start_test_case(option):
 			_test_floor_detection = true
 			_test_floor_detection = true
 			_test_motion_changes = true
 			_test_motion_changes = true
 			_use_snap = false
 			_use_snap = false
-			_body_type = E_BodyType.CHARACTER_BODY
+			_body_type = BodyType.CHARACTER_BODY
 			_start_test()
 			_start_test()
 
 
 			await start_timer(4.0).timeout
 			await start_timer(4.0).timeout
@@ -102,7 +100,7 @@ func _start_test_case(option):
 			Log.print_error("Invalid test case.")
 			Log.print_error("Invalid test case.")
 
 
 
 
-func _test_all():
+func _test_all() -> void:
 	Log.print_log("* TESTING ALL...")
 	Log.print_log("* TESTING ALL...")
 
 
 	# Test floor detection with no snapping.
 	# Test floor detection with no snapping.
@@ -119,8 +117,8 @@ func _test_all():
 	Log.print_log("* Done.")
 	Log.print_log("* Done.")
 
 
 
 
-func _set_result(test_passed):
-	var result = ""
+func _set_result(test_passed: bool) -> void:
+	var result := ""
 	if test_passed:
 	if test_passed:
 		result = "PASSED"
 		result = "PASSED"
 	else:
 	else:
@@ -134,7 +132,7 @@ func _set_result(test_passed):
 	Log.print_log("Test %s" % result)
 	Log.print_log("Test %s" % result)
 
 
 
 
-func _start_test():
+func _start_test() -> void:
 	super._start_test()
 	super._start_test()
 
 
 	_failed_reason = ""
 	_failed_reason = ""

+ 25 - 28
2d/physics_tests/tests/functional/test_character_tilemap.gd

@@ -1,6 +1,5 @@
 extends TestCharacter
 extends TestCharacter
 
 
-
 const OPTION_TEST_CASE_ALL = "Test Cases/TEST ALL (0)"
 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_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)"
 const OPTION_TEST_CASE_JUMP_ONE_WAY_CHARACTER = "Test Cases/Jump through one-way tiles (Character Body)"
@@ -8,16 +7,15 @@ 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_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)"
 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 := false
+var _test_jump_one_way_corner := false
+var _test_fall_one_way := false
 
 
 var _extra_body: PhysicsBody2D = null
 var _extra_body: PhysicsBody2D = null
 
 
-var _failed_reason = ""
-
+var _failed_reason := ""
 
 
-func _ready():
+func _ready() -> void:
 	super._ready()
 	super._ready()
 
 
 	options.add_menu_item(OPTION_TEST_CASE_ALL)
 	options.add_menu_item(OPTION_TEST_CASE_ALL)
@@ -28,16 +26,15 @@ func _ready():
 	options.add_menu_item(OPTION_TEST_CASE_FALL_ONE_WAY_CHARACTER)
 	options.add_menu_item(OPTION_TEST_CASE_FALL_ONE_WAY_CHARACTER)
 
 
 
 
-func _input(event):
+func _input(event: InputEvent) -> void:
 	super._input(event)
 	super._input(event)
 
 
-	var key_event = event as InputEventKey
-	if key_event and not key_event.pressed:
-		if key_event.keycode == KEY_0:
+	if event is InputEventKey and not event.pressed:
+		if event.keycode == KEY_0:
 			await _on_option_selected(OPTION_TEST_CASE_ALL)
 			await _on_option_selected(OPTION_TEST_CASE_ALL)
 
 
 
 
-func _on_option_selected(option):
+func _on_option_selected(option: String) -> void:
 	match option:
 	match option:
 		OPTION_TEST_CASE_ALL:
 		OPTION_TEST_CASE_ALL:
 			await _test_all()
 			await _test_all()
@@ -60,34 +57,34 @@ func _on_option_selected(option):
 	super._on_option_selected(option)
 	super._on_option_selected(option)
 
 
 
 
-func _start_test_case(option):
+func _start_test_case(option: String) -> void:
 	Log.print_log("* Starting " + option)
 	Log.print_log("* Starting " + option)
 
 
 	match option:
 	match option:
 		OPTION_TEST_CASE_JUMP_ONE_WAY_RIGID:
 		OPTION_TEST_CASE_JUMP_ONE_WAY_RIGID:
-			_body_type = E_BodyType.RIGID_BODY
+			_body_type = BodyType.RIGID_BODY
 			_test_jump_one_way_corner = false
 			_test_jump_one_way_corner = false
 			await _start_jump_one_way()
 			await _start_jump_one_way()
 		OPTION_TEST_CASE_JUMP_ONE_WAY_CHARACTER:
 		OPTION_TEST_CASE_JUMP_ONE_WAY_CHARACTER:
-			_body_type = E_BodyType.CHARACTER_BODY
+			_body_type = BodyType.CHARACTER_BODY
 			_test_jump_one_way_corner = false
 			_test_jump_one_way_corner = false
 			await _start_jump_one_way()
 			await _start_jump_one_way()
 		OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_RIGID:
 		OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_RIGID:
-			_body_type = E_BodyType.RIGID_BODY
+			_body_type = BodyType.RIGID_BODY
 			_test_jump_one_way_corner = true
 			_test_jump_one_way_corner = true
 			await _start_jump_one_way()
 			await _start_jump_one_way()
 		OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_CHARACTER:
 		OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_CHARACTER:
-			_body_type = E_BodyType.CHARACTER_BODY
+			_body_type = BodyType.CHARACTER_BODY
 			_test_jump_one_way_corner = true
 			_test_jump_one_way_corner = true
 			await _start_jump_one_way()
 			await _start_jump_one_way()
 		OPTION_TEST_CASE_FALL_ONE_WAY_CHARACTER:
 		OPTION_TEST_CASE_FALL_ONE_WAY_CHARACTER:
-			_body_type = E_BodyType.CHARACTER_BODY
+			_body_type = BodyType.CHARACTER_BODY
 			await _start_fall_one_way()
 			await _start_fall_one_way()
 		_:
 		_:
 			Log.print_error("Invalid test case.")
 			Log.print_error("Invalid test case.")
 
 
 
 
-func _test_all():
+func _test_all() -> void:
 	Log.print_log("* TESTING ALL...")
 	Log.print_log("* TESTING ALL...")
 
 
 	# RigidBody tests.
 	# RigidBody tests.
@@ -115,8 +112,8 @@ func _test_all():
 	Log.print_log("* Done.")
 	Log.print_log("* Done.")
 
 
 
 
-func _set_result(test_passed):
-	var result = ""
+func _set_result(test_passed: bool) -> void:
+	var result := ""
 	if test_passed:
 	if test_passed:
 		result = "PASSED"
 		result = "PASSED"
 	else:
 	else:
@@ -130,7 +127,7 @@ func _set_result(test_passed):
 	Log.print_log("Test %s" % result)
 	Log.print_log("Test %s" % result)
 
 
 
 
-func _start_test():
+func _start_test() -> void:
 	if _extra_body:
 	if _extra_body:
 		_body_parent.remove_child(_extra_body)
 		_body_parent.remove_child(_extra_body)
 		_extra_body.queue_free()
 		_extra_body.queue_free()
@@ -167,7 +164,7 @@ func _start_test():
 		$FallTargetArea2D/CollisionShape2D.disabled = false
 		$FallTargetArea2D/CollisionShape2D.disabled = false
 
 
 
 
-func _start_jump_one_way():
+func _start_jump_one_way() -> void:
 	_test_jump_one_way = true
 	_test_jump_one_way = true
 	_start_test()
 	_start_test()
 
 
@@ -178,7 +175,7 @@ func _start_jump_one_way():
 	_finalize_jump_one_way()
 	_finalize_jump_one_way()
 
 
 
 
-func _start_fall_one_way():
+func _start_fall_one_way() -> void:
 	_test_fall_one_way = true
 	_test_fall_one_way = true
 	_start_test()
 	_start_test()
 
 
@@ -189,8 +186,8 @@ func _start_fall_one_way():
 	_finalize_fall_one_way()
 	_finalize_fall_one_way()
 
 
 
 
-func _finalize_jump_one_way():
-	var passed = true
+func _finalize_jump_one_way() -> void:
+	var passed := true
 	if not $JumpTargetArea2D.overlaps_body(_moving_body):
 	if not $JumpTargetArea2D.overlaps_body(_moving_body):
 		passed = false
 		passed = false
 		_failed_reason = ": the body wasn't able to jump all the way through."
 		_failed_reason = ": the body wasn't able to jump all the way through."
@@ -201,8 +198,8 @@ func _finalize_jump_one_way():
 	$JumpTargetArea2D/CollisionShape2D.disabled = true
 	$JumpTargetArea2D/CollisionShape2D.disabled = true
 
 
 
 
-func _finalize_fall_one_way():
-	var passed = true
+func _finalize_fall_one_way() -> void:
+	var passed := true
 	if $FallTargetArea2D.overlaps_body(_moving_body):
 	if $FallTargetArea2D.overlaps_body(_moving_body):
 		passed = false
 		passed = false
 		_failed_reason = ": the body was pushed through the one-way collision."
 		_failed_reason = ": the body was pushed through the one-way collision."

+ 27 - 37
2d/physics_tests/tests/functional/test_character_tilemap.tscn

@@ -23,7 +23,7 @@ friction = 0.0
 radius = 16.0
 radius = 16.0
 
 
 [node name="Test" type="Node2D"]
 [node name="Test" type="Node2D"]
-script = ExtResource( "1" )
+script = ExtResource("1")
 
 
 [node name="LabelTestType" type="Label" parent="."]
 [node name="LabelTestType" type="Label" parent="."]
 offset_left = 14.0
 offset_left = 14.0
@@ -31,11 +31,8 @@ offset_top = 79.0
 offset_right = 145.0
 offset_right = 145.0
 offset_bottom = 93.0
 offset_bottom = 93.0
 text = "Testing: "
 text = "Testing: "
-__meta__ = {
-"_edit_use_anchors_": false
-}
 
 
-[node name="Options" parent="." instance=ExtResource( "3" )]
+[node name="Options" parent="." instance=ExtResource("3")]
 
 
 [node name="LabelFloor" type="Label" parent="."]
 [node name="LabelFloor" type="Label" parent="."]
 offset_left = 14.0
 offset_left = 14.0
@@ -43,9 +40,6 @@ offset_top = 237.929
 offset_right = 145.0
 offset_right = 145.0
 offset_bottom = 251.929
 offset_bottom = 251.929
 text = "ON FLOOR"
 text = "ON FLOOR"
-__meta__ = {
-"_edit_use_anchors_": false
-}
 
 
 [node name="LabelControls" type="Label" parent="."]
 [node name="LabelControls" type="Label" parent="."]
 offset_left = 14.0
 offset_left = 14.0
@@ -54,82 +48,77 @@ offset_right = 145.0
 offset_bottom = 277.291
 offset_bottom = 277.291
 text = "LEFT/RIGHT - MOVE
 text = "LEFT/RIGHT - MOVE
 UP - JUMP"
 UP - JUMP"
-__meta__ = {
-"_edit_use_anchors_": false
-}
 
 
 [node name="CharacterBody2D" type="CharacterBody2D" parent="."]
 [node name="CharacterBody2D" type="CharacterBody2D" parent="."]
 position = Vector2(250, 460)
 position = Vector2(250, 460)
 collision_mask = 2147483649
 collision_mask = 2147483649
-script = ExtResource( "7" )
+script = ExtResource("7")
 
 
 [node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
 [node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
-shape = SubResource( "2" )
+shape = SubResource("2")
 
 
 [node name="CharacterBodyRay2D" type="CharacterBody2D" parent="."]
 [node name="CharacterBodyRay2D" type="CharacterBody2D" parent="."]
 position = Vector2(250, 460)
 position = Vector2(250, 460)
 collision_mask = 2147483649
 collision_mask = 2147483649
-script = ExtResource( "7" )
+script = ExtResource("7")
 
 
 [node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBodyRay2D"]
 [node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBodyRay2D"]
 position = Vector2(0, -8)
 position = Vector2(0, -8)
-shape = SubResource( "RectangleShape2D_jx2e1" )
+shape = SubResource("RectangleShape2D_jx2e1")
 
 
 [node name="CollisionShapeRay2D" type="CollisionShape2D" parent="CharacterBodyRay2D"]
 [node name="CollisionShapeRay2D" type="CollisionShape2D" parent="CharacterBodyRay2D"]
 position = Vector2(0, 8)
 position = Vector2(0, 8)
-shape = SubResource( "RayShape2D_206f5" )
+shape = SubResource("RayShape2D_206f5")
 
 
 [node name="CollisionShapeRay2DLeft" type="CollisionShape2D" parent="CharacterBodyRay2D"]
 [node name="CollisionShapeRay2DLeft" type="CollisionShape2D" parent="CharacterBodyRay2D"]
 position = Vector2(-12, 8)
 position = Vector2(-12, 8)
-shape = SubResource( "RayShape2D_206f5" )
+shape = SubResource("RayShape2D_206f5")
 
 
 [node name="CollisionShapeRay2DRight" type="CollisionShape2D" parent="CharacterBodyRay2D"]
 [node name="CollisionShapeRay2DRight" type="CollisionShape2D" parent="CharacterBodyRay2D"]
 position = Vector2(12, 8)
 position = Vector2(12, 8)
-shape = SubResource( "RayShape2D_206f5" )
+shape = SubResource("RayShape2D_206f5")
 
 
-[node name="RigidDynamicBody2D" type="RigidDynamicBody2D" parent="."]
+[node name="RigidDynamicBody2D" type="RigidBody2D" parent="."]
 position = Vector2(250, 460)
 position = Vector2(250, 460)
 collision_mask = 2147483649
 collision_mask = 2147483649
-physics_material_override = SubResource( "1" )
-contacts_reported = 4
-contact_monitor = true
+physics_material_override = SubResource("1")
 lock_rotation = true
 lock_rotation = true
-script = ExtResource( "6" )
+contact_monitor = true
+script = ExtResource("6")
 
 
 [node name="CollisionShape2D" type="CollisionShape2D" parent="RigidDynamicBody2D"]
 [node name="CollisionShape2D" type="CollisionShape2D" parent="RigidDynamicBody2D"]
-shape = SubResource( "2" )
+shape = SubResource("2")
 
 
-[node name="RigidBodyRay2D" type="RigidDynamicBody2D" parent="."]
+[node name="RigidBodyRay2D" type="RigidBody2D" parent="."]
 position = Vector2(250, 460)
 position = Vector2(250, 460)
 collision_mask = 2147483649
 collision_mask = 2147483649
-physics_material_override = SubResource( "1" )
-contacts_reported = 4
-contact_monitor = true
+physics_material_override = SubResource("1")
 lock_rotation = true
 lock_rotation = true
-script = ExtResource( "6" )
+contact_monitor = true
+script = ExtResource("6")
 
 
 [node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBodyRay2D"]
 [node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBodyRay2D"]
 position = Vector2(0, -8)
 position = Vector2(0, -8)
-shape = SubResource( "RectangleShape2D_jx2e1" )
+shape = SubResource("RectangleShape2D_jx2e1")
 
 
 [node name="CollisionShapeRay2D" type="CollisionShape2D" parent="RigidBodyRay2D"]
 [node name="CollisionShapeRay2D" type="CollisionShape2D" parent="RigidBodyRay2D"]
 position = Vector2(0, 8)
 position = Vector2(0, 8)
-shape = SubResource( "RayShape2D_206f5" )
+shape = SubResource("RayShape2D_206f5")
 
 
 [node name="CollisionShapeRay2DLeft" type="CollisionShape2D" parent="RigidBodyRay2D"]
 [node name="CollisionShapeRay2DLeft" type="CollisionShape2D" parent="RigidBodyRay2D"]
 position = Vector2(-12, 8)
 position = Vector2(-12, 8)
-shape = SubResource( "RayShape2D_206f5" )
+shape = SubResource("RayShape2D_206f5")
 
 
 [node name="CollisionShapeRay2DRight" type="CollisionShape2D" parent="RigidBodyRay2D"]
 [node name="CollisionShapeRay2DRight" type="CollisionShape2D" parent="RigidBodyRay2D"]
 position = Vector2(12, 8)
 position = Vector2(12, 8)
-shape = SubResource( "RayShape2D_206f5" )
+shape = SubResource("RayShape2D_206f5")
 
 
 [node name="JumpTargetArea2D" type="Area2D" parent="."]
 [node name="JumpTargetArea2D" type="Area2D" parent="."]
 visible = false
 visible = false
 position = Vector2(810, 390)
 position = Vector2(810, 390)
 
 
 [node name="CollisionShape2D" type="CollisionShape2D" parent="JumpTargetArea2D"]
 [node name="CollisionShape2D" type="CollisionShape2D" parent="JumpTargetArea2D"]
-shape = SubResource( "5" )
+shape = SubResource("5")
 disabled = true
 disabled = true
 
 
 [node name="FallTargetArea2D" type="Area2D" parent="."]
 [node name="FallTargetArea2D" type="Area2D" parent="."]
@@ -137,15 +126,16 @@ visible = false
 position = Vector2(250, 480)
 position = Vector2(250, 480)
 
 
 [node name="CollisionShape2D" type="CollisionShape2D" parent="FallTargetArea2D"]
 [node name="CollisionShape2D" type="CollisionShape2D" parent="FallTargetArea2D"]
-shape = SubResource( "5" )
+shape = SubResource("5")
 disabled = true
 disabled = true
 
 
-[node name="StaticSceneFlat" parent="." instance=ExtResource( "4" )]
+[node name="StaticSceneFlat" parent="." instance=ExtResource("4")]
 position = Vector2(0, 12)
 position = Vector2(0, 12)
 
 
 [node name="TileMap" type="TileMap" parent="."]
 [node name="TileMap" type="TileMap" parent="."]
+texture_filter = 1
 scale = Vector2(2, 2)
 scale = Vector2(2, 2)
-tile_set = ExtResource( "5" )
+tile_set = ExtResource("5")
 collision_visibility_mode = 1
 collision_visibility_mode = 1
 format = 2
 format = 2
 layer_0/tile_data = PackedInt32Array(786438, 65536, 0, 786439, 65536, 0, 786440, 65536, 0, 786441, 65536, 0, 458764, 65536, 0, 524300, 65536, 0, 589836, 65536, 0, 655372, 65536, 0, 720908, 65536, 0, 786444, 65536, 0, 851980, 65536, 0, 917516, 65536, 0, 983052, 65536, 0, 458765, 65536, 0, 524301, 65536, 0, 589837, 65536, 0, 655373, 65536, 0, 720909, 65536, 0, 786445, 65536, 0, 851981, 65536, 0, 917517, 65536, 0, 983053, 65536, 0, 458766, 65536, 0, 524302, 65536, 0, 589838, 65536, 0, 655374, 65536, 0, 720910, 65536, 0, 786446, 65536, 0, 851982, 65536, 0, 917518, 65536, 0, 983054, 65536, 0, 458767, 65536, 0, 524303, 65536, 0, 589839, 65536, 0, 655375, 65536, 0, 720911, 65536, 0, 786447, 65536, 0, 851983, 65536, 0, 917519, 65536, 0, 983055, 65536, 0, 458768, 65536, 0, 524304, 65536, 0, 589840, 65536, 0, 655376, 65536, 0, 720912, 65536, 0, 786448, 65536, 0, 851984, 65536, 0, 917520, 65536, 0, 983056, 65536, 0, 458769, 65536, 0, 524305, 65536, 0, 589841, 65536, 0, 655377, 65536, 0, 720913, 65536, 0, 786449, 65536, 0, 851985, 65536, 0, 917521, 65536, 0, 983057, 65536, 0, 458770, 65536, 0, 524306, 65536, 0, 589842, 65536, 0, 655378, 65536, 0, 720914, 65536, 0, 786450, 65536, 0, 851986, 65536, 0, 917522, 65536, 0, 983058, 65536, 0, 458771, 65536, 0, 524307, 65536, 0, 589843, 65536, 0, 655379, 65536, 0, 720915, 65536, 0, 786451, 65536, 0, 851987, 65536, 0, 917523, 65536, 0, 983059, 65536, 0, 851992, 0, 0, 851993, 0, 0, 720922, 0, 0, 851994, 0, 0, 720923, 0, 0, 851995, 0, 0, 720924, 0, 0, 720925, 0, 0)
 layer_0/tile_data = PackedInt32Array(786438, 65536, 0, 786439, 65536, 0, 786440, 65536, 0, 786441, 65536, 0, 458764, 65536, 0, 524300, 65536, 0, 589836, 65536, 0, 655372, 65536, 0, 720908, 65536, 0, 786444, 65536, 0, 851980, 65536, 0, 917516, 65536, 0, 983052, 65536, 0, 458765, 65536, 0, 524301, 65536, 0, 589837, 65536, 0, 655373, 65536, 0, 720909, 65536, 0, 786445, 65536, 0, 851981, 65536, 0, 917517, 65536, 0, 983053, 65536, 0, 458766, 65536, 0, 524302, 65536, 0, 589838, 65536, 0, 655374, 65536, 0, 720910, 65536, 0, 786446, 65536, 0, 851982, 65536, 0, 917518, 65536, 0, 983054, 65536, 0, 458767, 65536, 0, 524303, 65536, 0, 589839, 65536, 0, 655375, 65536, 0, 720911, 65536, 0, 786447, 65536, 0, 851983, 65536, 0, 917519, 65536, 0, 983055, 65536, 0, 458768, 65536, 0, 524304, 65536, 0, 589840, 65536, 0, 655376, 65536, 0, 720912, 65536, 0, 786448, 65536, 0, 851984, 65536, 0, 917520, 65536, 0, 983056, 65536, 0, 458769, 65536, 0, 524305, 65536, 0, 589841, 65536, 0, 655377, 65536, 0, 720913, 65536, 0, 786449, 65536, 0, 851985, 65536, 0, 917521, 65536, 0, 983057, 65536, 0, 458770, 65536, 0, 524306, 65536, 0, 589842, 65536, 0, 655378, 65536, 0, 720914, 65536, 0, 786450, 65536, 0, 851986, 65536, 0, 917522, 65536, 0, 983058, 65536, 0, 458771, 65536, 0, 524307, 65536, 0, 589843, 65536, 0, 655379, 65536, 0, 720915, 65536, 0, 786451, 65536, 0, 851987, 65536, 0, 917523, 65536, 0, 983059, 65536, 0, 851992, 0, 0, 851993, 0, 0, 720922, 0, 0, 851994, 0, 0, 720923, 0, 0, 851995, 0, 0, 720924, 0, 0, 720925, 0, 0)

+ 34 - 38
2d/physics_tests/tests/functional/test_collision_pairs.gd

@@ -1,6 +1,5 @@
 extends Test
 extends Test
 
 
-
 const OPTION_TYPE_RECTANGLE = "Collision type/Rectangle (1)"
 const OPTION_TYPE_RECTANGLE = "Collision type/Rectangle (1)"
 const OPTION_TYPE_SPHERE = "Collision type/Sphere (2)"
 const OPTION_TYPE_SPHERE = "Collision type/Sphere (2)"
 const OPTION_TYPE_CAPSULE = "Collision type/Capsule (3)"
 const OPTION_TYPE_CAPSULE = "Collision type/Capsule (3)"
@@ -16,17 +15,16 @@ const OPTION_SHAPE_CONCAVE_SEGMENTS = "Shape type/Concave Segments"
 
 
 const OFFSET_RANGE = 120.0
 const OFFSET_RANGE = 120.0
 
 
-@export var offset = Vector2.ZERO
+@export var offset := Vector2.ZERO
 
 
-@onready var options = $Options
+@onready var options: OptionMenu = $Options
 
 
-var _update_collision = false
-var _collision_test_index = 0
-var _current_offset = Vector2.ZERO
-var _collision_shapes = []
+var _update_collision := false
+var _collision_test_index := 0
+var _collision_shapes: Array[Shape2D] = []
 
 
 
 
-func _ready():
+func _ready() -> void:
 	_initialize_collision_shapes()
 	_initialize_collision_shapes()
 
 
 	options.add_menu_item(OPTION_TYPE_RECTANGLE)
 	options.add_menu_item(OPTION_TYPE_RECTANGLE)
@@ -52,8 +50,8 @@ func _ready():
 	_update_collision = true
 	_update_collision = true
 
 
 
 
-func _input(event):
-	var key_event = event as InputEventKey
+func _input(event: InputEvent) -> void:
+	var key_event := event as InputEventKey
 	if key_event and not key_event.pressed:
 	if key_event and not key_event.pressed:
 		if key_event.keycode == KEY_1:
 		if key_event.keycode == KEY_1:
 			_on_option_selected(OPTION_TYPE_RECTANGLE)
 			_on_option_selected(OPTION_TYPE_RECTANGLE)
@@ -67,7 +65,7 @@ func _input(event):
 			_on_option_selected(OPTION_TYPE_CONCAVE_SEGMENTS)
 			_on_option_selected(OPTION_TYPE_CONCAVE_SEGMENTS)
 
 
 
 
-func _physics_process(delta):
+func _physics_process(delta: float) -> void:
 	super._physics_process(delta)
 	super._physics_process(delta)
 
 
 	if not _update_collision:
 	if not _update_collision:
@@ -78,66 +76,64 @@ func _physics_process(delta):
 	_do_collision_test()
 	_do_collision_test()
 
 
 
 
-func set_h_offset(value):
+func set_h_offset(value: float) -> void:
 	offset.x = value * OFFSET_RANGE
 	offset.x = value * OFFSET_RANGE
 	_update_collision = true
 	_update_collision = true
 
 
 
 
-func set_v_offset(value):
+func set_v_offset(value: float) -> void:
 	offset.y = -value * OFFSET_RANGE
 	offset.y = -value * OFFSET_RANGE
 	_update_collision = true
 	_update_collision = true
 
 
 
 
-func _initialize_collision_shapes():
+func _initialize_collision_shapes() -> void:
 	_collision_shapes.clear()
 	_collision_shapes.clear()
 
 
-	for node in $Shapes.get_children():
-		var body = node as PhysicsBody2D
-		var shape = body.shape_owner_get_shape(0, 0)
+	for node: PhysicsBody2D in $Shapes.get_children():
+		var body: PhysicsBody2D = node
+		var shape := body.shape_owner_get_shape(0, 0)
 		shape.resource_name = String(node.name).substr("RigidBody".length())
 		shape.resource_name = String(node.name).substr("RigidBody".length())
 
 
 		_collision_shapes.push_back(shape)
 		_collision_shapes.push_back(shape)
 
 
 
 
-func _do_collision_test():
+func _do_collision_test() -> void:
 	clear_drawn_nodes()
 	clear_drawn_nodes()
 
 
-	var shape = _collision_shapes[_collision_test_index]
+	var shape := _collision_shapes[_collision_test_index]
 
 
 	Log.print_log("* Start %s collision tests..." % shape.resource_name)
 	Log.print_log("* Start %s collision tests..." % shape.resource_name)
 
 
-	var shape_query = PhysicsShapeQueryParameters2D.new()
+	var shape_query := PhysicsShapeQueryParameters2D.new()
 	shape_query.set_shape(shape)
 	shape_query.set_shape(shape)
-	var shape_scale = Vector2(0.5, 0.5)
+	var shape_scale := Vector2(0.5, 0.5)
 	shape_query.transform = Transform2D.IDENTITY.scaled(shape_scale)
 	shape_query.transform = Transform2D.IDENTITY.scaled(shape_scale)
 
 
-	for node in $Shapes.get_children():
+	for node: PhysicsBody2D in $Shapes.get_children():
 		if not node.visible:
 		if not node.visible:
 			continue
 			continue
 
 
-		var body = node as PhysicsBody2D
-		var space_state = body.get_world_2d().direct_space_state
+		var body: PhysicsBody2D = node
+		var space_state := body.get_world_2d().direct_space_state
 
 
 		Log.print_log("* Testing: %s" % String(body.name))
 		Log.print_log("* Testing: %s" % String(body.name))
 
 
-		var center = body.position
+		var center := body.position
 
 
 		# Collision at the center inside.
 		# Collision at the center inside.
-		var res = _add_collision(space_state, center, shape, shape_query)
+		var res := _add_collision(space_state, center, shape, shape_query)
 		Log.print_log("Collision center inside: %s" % ("NO HIT" if res.is_empty() else "HIT"))
 		Log.print_log("Collision center inside: %s" % ("NO HIT" if res.is_empty() else "HIT"))
 
 
 	Log.print_log("* Done.")
 	Log.print_log("* Done.")
 
 
 
 
-func _add_collision(space_state, pos, shape, shape_query):
+func _add_collision(space_state: PhysicsDirectSpaceState2D, pos: Vector2, shape: Shape2D, shape_query: PhysicsShapeQueryParameters2D) -> Array[Vector2]:
 	shape_query.transform.origin = pos + offset
 	shape_query.transform.origin = pos + offset
-	var results = space_state.collide_shape(shape_query)
+	var results: Array[Vector2] = space_state.collide_shape(shape_query)
 
 
-	var color
+	var color := Color.GREEN
 	if results.is_empty():
 	if results.is_empty():
 		color = Color.WHITE.darkened(0.5)
 		color = Color.WHITE.darkened(0.5)
-	else:
-		color = Color.GREEN
 
 
 	# Draw collision query shape.
 	# Draw collision query shape.
 	add_shape(shape, shape_query.transform, color)
 	add_shape(shape, shape_query.transform, color)
@@ -149,7 +145,7 @@ func _add_collision(space_state, pos, shape, shape_query):
 	return results
 	return results
 
 
 
 
-func _on_option_selected(option):
+func _on_option_selected(option: String) -> void:
 	match option:
 	match option:
 		OPTION_TYPE_RECTANGLE:
 		OPTION_TYPE_RECTANGLE:
 			_collision_test_index = _find_type_index("Rectangle")
 			_collision_test_index = _find_type_index("Rectangle")
@@ -168,9 +164,9 @@ func _on_option_selected(option):
 			_update_collision = true
 			_update_collision = true
 
 
 
 
-func _find_type_index(type_name):
+func _find_type_index(type_name: String) -> int:
 	for type_index in range(_collision_shapes.size()):
 	for type_index in range(_collision_shapes.size()):
-		var type_shape = _collision_shapes[type_index]
+		var type_shape := _collision_shapes[type_index]
 		if type_shape.resource_name.find(type_name) > -1:
 		if type_shape.resource_name.find(type_name) > -1:
 			return type_index
 			return type_index
 
 
@@ -178,8 +174,8 @@ func _find_type_index(type_name):
 	return -1
 	return -1
 
 
 
 
-func _on_option_changed(option, checked):
-	var node
+func _on_option_changed(option: String, checked: bool) -> void:
+	var node: Node2D
 
 
 	match option:
 	match option:
 		OPTION_SHAPE_RECTANGLE:
 		OPTION_SHAPE_RECTANGLE:
@@ -201,8 +197,8 @@ func _on_option_changed(option, checked):
 		_update_collision = true
 		_update_collision = true
 
 
 
 
-func _find_shape_node(type_name):
-	var node = $Shapes.find_child("RigidBody%s" % type_name)
+func _find_shape_node(type_name: String) -> Node2D:
+	var node: Node2D = $Shapes.find_child("RigidBody%s" % type_name)
 
 
 	if not node:
 	if not node:
 		Log.print_error("Invalid shape type: " + type_name)
 		Log.print_error("Invalid shape type: " + type_name)

+ 29 - 33
2d/physics_tests/tests/functional/test_joints.gd

@@ -1,6 +1,5 @@
 extends Test
 extends Test
 
 
-
 const OPTION_JOINT_TYPE = "Joint Type/%s Joint (%d)"
 const OPTION_JOINT_TYPE = "Joint Type/%s Joint (%d)"
 
 
 const OPTION_TEST_CASE_BODIES_COLLIDE = "Test case/Attached bodies collide"
 const OPTION_TEST_CASE_BODIES_COLLIDE = "Test case/Attached bodies collide"
@@ -11,29 +10,27 @@ const OPTION_TEST_CASE_CHANGE_POSITIONS = "Test case/Set body positions after ad
 
 
 const BOX_SIZE = Vector2(64, 64)
 const BOX_SIZE = Vector2(64, 64)
 
 
-var _update_joint = false
-var _selected_joint = null
-
-var _joint_type = PinJoint2D
-var _bodies_collide = false
-var _world_attachement = false
-var _dynamic_attachement = false
-var _destroy_body = false
-var _change_positions = false
+var _update_joint := false
+var _selected_joint: Joint2D = null
 
 
-var _joint_types = {}
+var _bodies_collide := false
+var _world_attachement := false
+var _dynamic_attachement := false
+var _destroy_body := false
+var _change_positions := false
 
 
+var _joint_types := {}
 
 
-func _ready():
-	var options = $Options
+func _ready() -> void:
+	var options: OptionMenu = $Options
 
 
-	var joints = $Joints
-	for joint_index in range(joints.get_child_count()):
-		var joint_node = joints.get_child(joint_index)
+	var joints: Node2D = $Joints
+	for joint_index in joints.get_child_count():
+		var joint_node := joints.get_child(joint_index)
 		joint_node.visible = false
 		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_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]
 		options.add_menu_item(option_name)
 		options.add_menu_item(option_name)
 		_joint_types[option_name] = joint_node
 		_joint_types[option_name] = joint_node
 
 
@@ -50,29 +47,28 @@ func _ready():
 	_update_joint = true
 	_update_joint = true
 
 
 
 
-func _process(_delta):
+func _process(_delta: float) -> void:
 	if _update_joint:
 	if _update_joint:
 		_update_joint = false
 		_update_joint = false
 		await _create_joint()
 		await _create_joint()
 		$LabelJointType.text = "Joint Type: " + String(_selected_joint.name)
 		$LabelJointType.text = "Joint Type: " + String(_selected_joint.name)
 
 
 
 
-func _input(event):
-	var key_event = event as InputEventKey
-	if key_event and not key_event.pressed:
-		var joint_index = key_event.keycode - KEY_1
+func _input(event: InputEvent) -> void:
+	if event is InputEventKey and not event.pressed:
+		var joint_index: int = event.keycode - KEY_1
 		if joint_index >= 0 and joint_index < _joint_types.size():
 		if joint_index >= 0 and joint_index < _joint_types.size():
 			_selected_joint = _joint_types.values()[joint_index]
 			_selected_joint = _joint_types.values()[joint_index]
 			_update_joint = true
 			_update_joint = true
 
 
 
 
-func _on_option_selected(option):
+func _on_option_selected(option: String) -> void:
 	if _joint_types.has(option):
 	if _joint_types.has(option):
 		_selected_joint = _joint_types[option]
 		_selected_joint = _joint_types[option]
 		_update_joint = true
 		_update_joint = true
 
 
 
 
-func _on_option_changed(option, checked):
+func _on_option_changed(option: String, checked: bool) -> void:
 	match option:
 	match option:
 		OPTION_TEST_CASE_BODIES_COLLIDE:
 		OPTION_TEST_CASE_BODIES_COLLIDE:
 			_bodies_collide = checked
 			_bodies_collide = checked
@@ -91,18 +87,18 @@ func _on_option_changed(option, checked):
 			_update_joint = true
 			_update_joint = true
 
 
 
 
-func _create_joint():
+func _create_joint() -> void:
 	cancel_timer()
 	cancel_timer()
 
 
-	var root = $Objects
+	var root: Node2D = $Objects
 
 
 	while root.get_child_count():
 	while root.get_child_count():
-		var last_child_index = root.get_child_count() - 1
-		var last_child = root.get_child(last_child_index)
+		var last_child_index := root.get_child_count() - 1
+		var last_child := root.get_child(last_child_index)
 		root.remove_child(last_child)
 		root.remove_child(last_child)
 		last_child.queue_free()
 		last_child.queue_free()
 
 
-	var child_body = create_rigidbody_box(BOX_SIZE, true, true)
+	var child_body := create_rigidbody_box(BOX_SIZE, true, true)
 	if _change_positions:
 	if _change_positions:
 		root.add_child(child_body)
 		root.add_child(child_body)
 		child_body.position = Vector2(0.0, 40)
 		child_body.position = Vector2(0.0, 40)
@@ -110,7 +106,7 @@ func _create_joint():
 		child_body.position = Vector2(0.0, 40)
 		child_body.position = Vector2(0.0, 40)
 		root.add_child(child_body)
 		root.add_child(child_body)
 
 
-	var parent_body = null
+	var parent_body: PhysicsBody2D = null
 	if not _world_attachement:
 	if not _world_attachement:
 		parent_body = create_rigidbody_box(BOX_SIZE, true, true)
 		parent_body = create_rigidbody_box(BOX_SIZE, true, true)
 		if _dynamic_attachement:
 		if _dynamic_attachement:
@@ -125,7 +121,7 @@ func _create_joint():
 			parent_body.position = Vector2(0.0, -40)
 			parent_body.position = Vector2(0.0, -40)
 			root.add_child(parent_body)
 			root.add_child(parent_body)
 
 
-	var joint = _selected_joint.duplicate()
+	var joint := _selected_joint.duplicate()
 	joint.visible = true
 	joint.visible = true
 	joint.disable_collision = not _bodies_collide
 	joint.disable_collision = not _bodies_collide
 	root.add_child(joint)
 	root.add_child(joint)

+ 2 - 5
2d/physics_tests/tests/functional/test_joints.tscn

@@ -4,7 +4,7 @@
 [ext_resource type="PackedScene" uid="uid://blh3twy74kbkv" path="res://tests/test_options.tscn" id="4"]
 [ext_resource type="PackedScene" uid="uid://blh3twy74kbkv" path="res://tests/test_options.tscn" id="4"]
 
 
 [node name="JointTest2D" type="Node2D"]
 [node name="JointTest2D" type="Node2D"]
-script = ExtResource( "2" )
+script = ExtResource("2")
 
 
 [node name="LabelJointType" type="Label" parent="."]
 [node name="LabelJointType" type="Label" parent="."]
 offset_left = 14.0
 offset_left = 14.0
@@ -12,11 +12,8 @@ offset_top = 79.0
 offset_right = 145.0
 offset_right = 145.0
 offset_bottom = 93.0
 offset_bottom = 93.0
 text = "Joint Type: "
 text = "Joint Type: "
-__meta__ = {
-"_edit_use_anchors_": false
-}
 
 
-[node name="Options" parent="." instance=ExtResource( "4" )]
+[node name="Options" parent="." instance=ExtResource("4")]
 
 
 [node name="Joints" type="Node2D" parent="."]
 [node name="Joints" type="Node2D" parent="."]
 position = Vector2(512, 200)
 position = Vector2(512, 200)

+ 62 - 64
2d/physics_tests/tests/functional/test_one_way_collision.gd

@@ -1,7 +1,6 @@
 @tool
 @tool
 extends Test
 extends Test
 
 
-
 signal all_tests_done()
 signal all_tests_done()
 signal test_done()
 signal test_done()
 
 
@@ -19,56 +18,56 @@ const OPTION_TEST_CASE_MOVING_PLATFORM_CHARACTER = "Test Cases/Moving Platform (
 const TEST_ALL_ANGLES_STEP = 15.0
 const TEST_ALL_ANGLES_STEP = 15.0
 const TEST_ALL_ANGLES_MAX = 344.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 := 128.0:
 	set(value):
 	set(value):
 		if value == _platform_size:
 		if value == _platform_size:
 			return
 			return
 		_platform_size = value
 		_platform_size = value
 		_update_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 := 0.0:
 	set(value):
 	set(value):
 		if value == _platform_angle:
 		if value == _platform_angle:
 			return
 			return
 		_platform_angle = value
 		_platform_angle = value
 		_update_platform_angle(value)
 		_update_platform_angle(value)
 
 
-@export var _platform_speed = 0.0
+@export var _platform_speed := 0.0
 
 
-@export_range(0, 360, 0.1) var _body_angle = 0.0:
+@export_range(0, 360, 0.1) var _body_angle := 0.0:
 	set(value):
 	set(value):
 		if value == _body_angle:
 		if value == _body_angle:
 			return
 			return
 		_body_angle = value
 		_body_angle = value
 		_update_rigidbody_angle(value)
 		_update_rigidbody_angle(value)
 
 
-@export var _body_velocity = Vector2(400.0, 0.0)
-@export var _use_character_body = false
+@export var _body_velocity := Vector2(400.0, 0.0)
+@export var _use_character_body := false
 
 
-@onready var options = $Options
+@onready var options: OptionMenu = $Options
 
 
-var _rigid_body_template = null
-var _character_body_template = null
+var _rigid_body_template: RigidBody2D = null
+var _character_body_template: CharacterBody2D = null
 var _moving_body: PhysicsBody2D = null
 var _moving_body: PhysicsBody2D = null
 
 
-var _platform_template = null
+var _platform_template: StaticBody2D = null
 var _platform_body: PhysicsBody2D = null
 var _platform_body: PhysicsBody2D = null
-var _platform_velocity = Vector2.ZERO
+var _platform_velocity := Vector2.ZERO
 
 
-@onready var _target_area = $TargetArea2D
+@onready var _target_area: Area2D = $TargetArea2D
 
 
-var _contact_detected = false
-var _target_entered = false
-var _test_passed = false
-var _test_step = 0
+var _contact_detected := false
+var _target_entered := false
+var _test_passed := false
+var _test_step := 0
 
 
-var _test_all_angles = false
-var _lock_controls = false
+var _test_all_angles := false
+var _lock_controls := false
 
 
-var _test_canceled = false
+var _test_canceled := false
 
 
 
 
-func _ready():
+func _ready() -> void:
 	if not Engine.is_editor_hint():
 	if not Engine.is_editor_hint():
 		options.add_menu_item(OPTION_OBJECT_TYPE_RIGIDBODY, true, not _use_character_body, true)
 		options.add_menu_item(OPTION_OBJECT_TYPE_RIGIDBODY, true, not _use_character_body, true)
 		options.add_menu_item(OPTION_OBJECT_TYPE_CHARACTER, true, _use_character_body, true)
 		options.add_menu_item(OPTION_OBJECT_TYPE_CHARACTER, true, _use_character_body, true)
@@ -103,47 +102,46 @@ func _ready():
 		_start_test()
 		_start_test()
 
 
 
 
-func _process(_delta):
+func _process(_delta: float) -> void:
 	if not Engine.is_editor_hint():
 	if not Engine.is_editor_hint():
 		if Input.is_action_just_pressed(&"ui_accept"):
 		if Input.is_action_just_pressed(&"ui_accept"):
 			await _reset_test(false)
 			await _reset_test(false)
 
 
 
 
-func _physics_process(delta):
+func _physics_process(delta: float) -> void:
 	super._physics_process(delta)
 	super._physics_process(delta)
 
 
 	if not Engine.is_editor_hint():
 	if not Engine.is_editor_hint():
 		if _moving_body and not _contact_detected:
 		if _moving_body and not _contact_detected:
 			if _use_character_body:
 			if _use_character_body:
-				var collision = _moving_body.move_and_collide(_body_velocity * delta, false)
+				var collision := _moving_body.move_and_collide(_body_velocity * delta, false)
 				if collision:
 				if collision:
-					var colliding_body = collision.get_collider()
+					var colliding_body := collision.get_collider()
 					await _on_contact_detected(colliding_body)
 					await _on_contact_detected(colliding_body)
 
 
 			if _platform_body and _platform_velocity != Vector2.ZERO:
 			if _platform_body and _platform_velocity != Vector2.ZERO:
-				var motion = _platform_velocity * delta
+				var motion := _platform_velocity * delta
 				_platform_body.global_position += motion
 				_platform_body.global_position += motion
 
 
 
 
-func _input(event):
-	var key_event = event as InputEventKey
-	if key_event and not key_event.pressed:
-		if key_event.keycode == KEY_0:
+func _input(event: InputEvent) -> void:
+	if event is InputEventKey and not event.pressed:
+		if event.keycode == KEY_0:
 			await _on_option_selected(OPTION_TEST_CASE_ALL)
 			await _on_option_selected(OPTION_TEST_CASE_ALL)
-		if key_event.keycode == KEY_1:
+		if event.keycode == KEY_1:
 			await _on_option_selected(OPTION_OBJECT_TYPE_RIGIDBODY)
 			await _on_option_selected(OPTION_OBJECT_TYPE_RIGIDBODY)
-		elif key_event.keycode == KEY_2:
+		elif event.keycode == KEY_2:
 			await _on_option_selected(OPTION_OBJECT_TYPE_CHARACTER)
 			await _on_option_selected(OPTION_OBJECT_TYPE_CHARACTER)
 
 
 
 
-func _exit_tree():
+func _exit_tree() -> void:
 	if not Engine.is_editor_hint():
 	if not Engine.is_editor_hint():
 		_rigid_body_template.free()
 		_rigid_body_template.free()
 		_character_body_template.free()
 		_character_body_template.free()
 		_platform_template.free()
 		_platform_template.free()
 
 
 
 
-func _update_platform_size(value, reset = true):
+func _update_platform_size(value: float, reset: bool = true) -> void:
 	if _lock_controls:
 	if _lock_controls:
 		return
 		return
 	if value == _platform_size:
 	if value == _platform_size:
@@ -153,11 +151,11 @@ func _update_platform_size(value, reset = true):
 		if Engine.is_editor_hint():
 		if Engine.is_editor_hint():
 			$OneWayStaticBody2D/CollisionShape2D.shape.size.x = value
 			$OneWayStaticBody2D/CollisionShape2D.shape.size.x = value
 		else:
 		else:
-			var platform_collision = _platform_template.get_child(0)
+			var platform_collision := _platform_template.get_child(0)
 			platform_collision.shape.size.x = value
 			platform_collision.shape.size.x = value
 			if _platform_body:
 			if _platform_body:
 				# Bug: need to re-add when changing shape.
 				# Bug: need to re-add when changing shape.
-				var child_index = _platform_body.get_index()
+				var child_index := _platform_body.get_index()
 				remove_child(_platform_body)
 				remove_child(_platform_body)
 				add_child(_platform_body)
 				add_child(_platform_body)
 				move_child(_platform_body, child_index)
 				move_child(_platform_body, child_index)
@@ -165,7 +163,7 @@ func _update_platform_size(value, reset = true):
 				await _reset_test()
 				await _reset_test()
 
 
 
 
-func _update_platform_angle(value, reset = true):
+func _update_platform_angle(value: float, reset: bool = true) -> void:
 	if _lock_controls:
 	if _lock_controls:
 		return
 		return
 	if value == _platform_angle:
 	if value == _platform_angle:
@@ -182,7 +180,7 @@ func _update_platform_angle(value, reset = true):
 				await _reset_test()
 				await _reset_test()
 
 
 
 
-func _update_rigidbody_angle(value, reset = true):
+func _update_rigidbody_angle(value: float, reset: bool = true) -> void:
 	if _lock_controls:
 	if _lock_controls:
 		return
 		return
 	if value == _body_angle:
 	if value == _body_angle:
@@ -201,7 +199,7 @@ func _update_rigidbody_angle(value, reset = true):
 				await _reset_test()
 				await _reset_test()
 
 
 
 
-func _on_option_selected(option):
+func _on_option_selected(option: String) -> void:
 	match option:
 	match option:
 		OPTION_OBJECT_TYPE_CHARACTER:
 		OPTION_OBJECT_TYPE_CHARACTER:
 			_use_character_body = true
 			_use_character_body = true
@@ -231,7 +229,7 @@ func _on_option_selected(option):
 			await _test_moving_platform()
 			await _test_moving_platform()
 
 
 
 
-func _start_test_case(option):
+func _start_test_case(option: String) -> void:
 	Log.print_log("* Starting " + option)
 	Log.print_log("* Starting " + option)
 
 
 	await _on_option_selected(option)
 	await _on_option_selected(option)
@@ -239,13 +237,13 @@ func _start_test_case(option):
 	await all_tests_done
 	await all_tests_done
 
 
 
 
-func _wait_for_test():
+func _wait_for_test() -> void:
 	await _reset_test()
 	await _reset_test()
 
 
 	await test_done
 	await test_done
 
 
 
 
-func _test_all_rigid_body():
+func _test_all_rigid_body() -> void:
 	Log.print_log("* All RigidBody test cases...")
 	Log.print_log("* All RigidBody test cases...")
 
 
 	await _update_platform_size(128.0, false)
 	await _update_platform_size(128.0, false)
@@ -271,7 +269,7 @@ func _test_all_rigid_body():
 		return
 		return
 
 
 
 
-func _test_all_character_body():
+func _test_all_character_body() -> void:
 	Log.print_log("* All CharacterBody test cases...")
 	Log.print_log("* All CharacterBody test cases...")
 
 
 	await _update_platform_size(128.0, false)
 	await _update_platform_size(128.0, false)
@@ -297,7 +295,7 @@ func _test_all_character_body():
 		return
 		return
 
 
 
 
-func _test_moving_platform():
+func _test_moving_platform() -> void:
 	Log.print_log("* Start moving platform tests")
 	Log.print_log("* Start moving platform tests")
 
 
 	Log.print_log("* Platform moving away from body...")
 	Log.print_log("* Platform moving away from body...")
@@ -334,7 +332,7 @@ func _test_moving_platform():
 	all_tests_done.emit()
 	all_tests_done.emit()
 
 
 
 
-func _test_all():
+func _test_all() -> void:
 	Log.print_log("* TESTING ALL...")
 	Log.print_log("* TESTING ALL...")
 
 
 	await _test_all_rigid_body()
 	await _test_all_rigid_body()
@@ -348,10 +346,10 @@ func _test_all():
 	Log.print_log("* Done.")
 	Log.print_log("* Done.")
 
 
 
 
-func _start_test():
-	var test_label = "Testing: "
+func _start_test() -> void:
+	var test_label := "Testing: "
 
 
-	var platform_angle = _platform_template.rotation
+	var platform_angle := _platform_template.rotation
 	if _platform_body:
 	if _platform_body:
 		platform_angle = _platform_body.rotation
 		platform_angle = _platform_body.rotation
 		_platform_body.remove_child(_target_area)
 		_platform_body.remove_child(_target_area)
@@ -377,9 +375,9 @@ func _start_test():
 	add_child(_moving_body)
 	add_child(_moving_body)
 
 
 	if _platform_speed != 0.0:
 	if _platform_speed != 0.0:
-		var platform_pos = _platform_body.global_position
-		var body_pos = _moving_body.global_position
-		var dir = (platform_pos - body_pos).normalized()
+		var platform_pos := _platform_body.global_position
+		var body_pos := _moving_body.global_position
+		var dir := (platform_pos - body_pos).normalized()
 		_platform_velocity = dir * _platform_speed
 		_platform_velocity = dir * _platform_speed
 	else:
 	else:
 		_platform_velocity = Vector2.ZERO
 		_platform_velocity = Vector2.ZERO
@@ -400,7 +398,7 @@ func _start_test():
 	$LabelResult.self_modulate = Color.WHITE
 	$LabelResult.self_modulate = Color.WHITE
 
 
 
 
-func _reset_test(cancel_test = true):
+func _reset_test(cancel_test: bool = true) -> void:
 	_test_canceled = true
 	_test_canceled = true
 	await _on_timeout()
 	await _on_timeout()
 	_test_canceled = false
 	_test_canceled = false
@@ -422,14 +420,14 @@ func _reset_test(cancel_test = true):
 	_next_test(true)
 	_next_test(true)
 
 
 
 
-func _next_test(force_start = false):
+func _next_test(force_start: bool = false) -> void:
 	if _moving_body:
 	if _moving_body:
 		remove_child(_moving_body)
 		remove_child(_moving_body)
 		_moving_body.queue_free()
 		_moving_body.queue_free()
 		_moving_body = null
 		_moving_body = null
 
 
 	if _test_all_angles:
 	if _test_all_angles:
-		var angle = rad_to_deg(_platform_body.rotation)
+		var angle := rad_to_deg(_platform_body.rotation)
 		if angle >= _platform_angle + TEST_ALL_ANGLES_MAX:
 		if angle >= _platform_angle + TEST_ALL_ANGLES_MAX:
 			_platform_body.rotation = deg_to_rad(_platform_angle)
 			_platform_body.rotation = deg_to_rad(_platform_angle)
 			_lock_controls = true
 			_lock_controls = true
@@ -448,7 +446,7 @@ func _next_test(force_start = false):
 		_start_test()
 		_start_test()
 
 
 
 
-func _on_contact_detected(_body):
+func _on_contact_detected(_body: PhysicsBody2D) -> void:
 	if _contact_detected or _target_entered:
 	if _contact_detected or _target_entered:
 		return
 		return
 
 
@@ -458,7 +456,7 @@ func _on_contact_detected(_body):
 	await _on_timeout()
 	await _on_timeout()
 
 
 
 
-func _on_target_entered(_body):
+func _on_target_entered(_body: PhysicsBody2D) -> void:
 	if _body != _moving_body:
 	if _body != _moving_body:
 		return
 		return
 
 
@@ -471,14 +469,14 @@ func _on_target_entered(_body):
 	await _on_timeout()
 	await _on_timeout()
 
 
 
 
-func _should_collide():
-	var platform_rotation = round(rad_to_deg(_platform_body.rotation))
+func _should_collide() -> bool:
+	var platform_rotation := roundf(rad_to_deg(_platform_body.rotation))
 
 
-	var angle = fposmod(platform_rotation, 360)
+	var angle := fposmod(platform_rotation, 360)
 	return angle > 180
 	return angle > 180
 
 
 
 
-func _on_timeout():
+func _on_timeout() -> void:
 	cancel_timer()
 	cancel_timer()
 
 
 	if $Timer.is_stopped():
 	if $Timer.is_stopped():
@@ -501,7 +499,7 @@ func _on_timeout():
 		all_tests_done.emit()
 		all_tests_done.emit()
 		return
 		return
 
 
-	var was_all_angles = _test_all_angles
+	var was_all_angles := _test_all_angles
 
 
 	_next_test()
 	_next_test()
 
 
@@ -511,8 +509,8 @@ func _on_timeout():
 		all_tests_done.emit()
 		all_tests_done.emit()
 
 
 
 
-func _set_result():
-	var result = ""
+func _set_result() -> void:
+	var result := ""
 	if _test_passed:
 	if _test_passed:
 		result = "PASSED"
 		result = "PASSED"
 		$LabelResult.self_modulate = Color.GREEN
 		$LabelResult.self_modulate = Color.GREEN
@@ -522,7 +520,7 @@ func _set_result():
 
 
 	$LabelResult.text = result
 	$LabelResult.text = result
 
 
-	var platform_angle = rad_to_deg(_platform_body.rotation)
+	var platform_angle := rad_to_deg(_platform_body.rotation)
 
 
 	result += ": size=%.1f, angle=%.1f, body angle=%.1f" % [_platform_size, platform_angle, _body_angle]
 	result += ": size=%.1f, angle=%.1f, body angle=%.1f" % [_platform_size, platform_angle, _body_angle]
 	Log.print_log("Test %s" % result)
 	Log.print_log("Test %s" % result)

+ 14 - 16
2d/physics_tests/tests/functional/test_pyramid.gd

@@ -1,35 +1,33 @@
 extends Test
 extends Test
 
 
+@export_range(1, 100) var height := 10
+@export var box_size := Vector2(40.0, 40.0)
+@export var box_spacing := Vector2(0.0, 0.0)
 
 
-@export_range(1, 100) var height = 10
-@export var box_size = Vector2(40.0, 40.0)
-@export var box_spacing =  Vector2(0.0, 0.0)
-
-
-func _ready():
+func _ready() -> void:
 	_create_pyramid()
 	_create_pyramid()
 
 
 
 
-func _create_pyramid():
-	var root_node = $Pyramid
+func _create_pyramid() -> void:
+	var root_node: Node2D = $Pyramid
 
 
-	var template_body = create_rigidbody_box(box_size, true)
+	var template_body := create_rigidbody_box(box_size, true)
 
 
-	var pos_y = -0.5 * box_size.y - box_spacing.y
+	var pos_y := -0.5 * box_size.y - box_spacing.y
 
 
 	for level in height:
 	for level in height:
-		var level_index = height - level - 1
-		var num_boxes = 2 * level_index + 1
+		var level_index := height - level - 1
+		var num_boxes := 2 * level_index + 1
 
 
-		var row_node = Node2D.new()
+		var row_node := Node2D.new()
 		row_node.position = Vector2(0.0, pos_y)
 		row_node.position = Vector2(0.0, pos_y)
 		row_node.name = "Row%02d" % (level + 1)
 		row_node.name = "Row%02d" % (level + 1)
 		root_node.add_child(row_node)
 		root_node.add_child(row_node)
 
 
-		var pos_x = -0.5 * (num_boxes - 1) * (box_size.x + box_spacing.x)
+		var pos_x := -0.5 * (num_boxes - 1) * (box_size.x + box_spacing.x)
 
 
-		for box_index in range(num_boxes):
-			var box = template_body.duplicate()
+		for box_index in num_boxes:
+			var box := template_body.duplicate()
 			box.position = Vector2(pos_x, 0.0)
 			box.position = Vector2(pos_x, 0.0)
 			box.name = "Box%02d" % (box_index + 1)
 			box.name = "Box%02d" % (box_index + 1)
 			row_node.add_child(box)
 			row_node.add_child(box)

+ 2 - 2
2d/physics_tests/tests/functional/test_pyramid.tscn

@@ -4,9 +4,9 @@
 [ext_resource type="PackedScene" uid="uid://cx2q80okt25o1" path="res://tests/static_scene_flat.tscn" id="2"]
 [ext_resource type="PackedScene" uid="uid://cx2q80okt25o1" path="res://tests/static_scene_flat.tscn" id="2"]
 
 
 [node name="Test" type="Node2D"]
 [node name="Test" type="Node2D"]
-script = ExtResource( "1" )
+script = ExtResource("1")
 
 
 [node name="Pyramid" type="Node2D" parent="."]
 [node name="Pyramid" type="Node2D" parent="."]
 position = Vector2(512, 500)
 position = Vector2(512, 500)
 
 
-[node name="StaticSceneFlat" parent="." instance=ExtResource( "2" )]
+[node name="StaticSceneFlat" parent="." instance=ExtResource("2")]

+ 17 - 21
2d/physics_tests/tests/functional/test_raycasting.gd

@@ -1,14 +1,12 @@
 extends Test
 extends Test
 
 
-
 const OPTION_TEST_CASE_HIT_FROM_INSIDE = "Test case/Hit from inside"
 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 := false
+var _do_raycasts := false
 
 
-func _ready():
-	var options = $Options
+func _ready() -> void:
+	var options: OptionMenu = $Options
 
 
 	options.add_menu_item(OPTION_TEST_CASE_HIT_FROM_INSIDE, true, false)
 	options.add_menu_item(OPTION_TEST_CASE_HIT_FROM_INSIDE, true, false)
 
 
@@ -21,7 +19,7 @@ func _ready():
 	_do_raycasts = true
 	_do_raycasts = true
 
 
 
 
-func _physics_process(delta):
+func _physics_process(delta: float) -> void:
 	super._physics_process(delta)
 	super._physics_process(delta)
 
 
 	if not _do_raycasts:
 	if not _do_raycasts:
@@ -34,16 +32,16 @@ func _physics_process(delta):
 	clear_drawn_nodes()
 	clear_drawn_nodes()
 
 
 	for node in $Shapes.get_children():
 	for node in $Shapes.get_children():
-		var body = node as PhysicsBody2D
-		var space_state = body.get_world_2d().direct_space_state
-		var body_name = String(body.name).substr("RigidBody".length())
+		var body: PhysicsBody2D = node
+		var space_state := body.get_world_2d().direct_space_state
+		var body_name := String(body.name).substr("RigidBody".length())
 
 
 		Log.print_log("* Testing: %s" % body_name)
 		Log.print_log("* Testing: %s" % body_name)
 
 
-		var center = body.position
+		var center := body.position
 
 
 		# Raycast entering from the top.
 		# Raycast entering from the top.
-		var res = _add_raycast(space_state, center - Vector2(0, 100), center)
+		var res: Dictionary = _add_raycast(space_state, center - Vector2(0, 100), center)
 		Log.print_log("Raycast in: %s" % ("HIT" if res else "NO HIT"))
 		Log.print_log("Raycast in: %s" % ("HIT" if res else "NO HIT"))
 
 
 		# Raycast exiting from inside.
 		# Raycast exiting from inside.
@@ -63,25 +61,23 @@ func _physics_process(delta):
 			Log.print_log("Raycast inside face: %s" % ("HIT" if res else "NO HIT"))
 			Log.print_log("Raycast inside face: %s" % ("HIT" if res else "NO HIT"))
 
 
 
 
-func _on_option_changed(option, checked):
+func _on_option_changed(option: String, checked: bool) -> void:
 	match option:
 	match option:
 		OPTION_TEST_CASE_HIT_FROM_INSIDE:
 		OPTION_TEST_CASE_HIT_FROM_INSIDE:
 			_hit_from_inside = checked
 			_hit_from_inside = checked
 			_do_raycasts = true
 			_do_raycasts = true
 
 
 
 
-func _add_raycast(space_state, pos_start, pos_end):
-	var params = PhysicsRayQueryParameters2D.new()
+func _add_raycast(space_state: PhysicsDirectSpaceState2D, pos_start: Vector2, pos_end: Vector2) -> Dictionary:
+	var params := PhysicsRayQueryParameters2D.new()
 	params.from = pos_start
 	params.from = pos_start
 	params.to = pos_end
 	params.to = pos_end
 	params.hit_from_inside = _hit_from_inside
 	params.hit_from_inside = _hit_from_inside
 
 
-	var result = space_state.intersect_ray(params)
-	var color
+	var result: Dictionary = space_state.intersect_ray(params)
+	var color := Color.RED.darkened(0.5)
 	if result:
 	if result:
 		color = Color.GREEN.darkened(0.2)
 		color = Color.GREEN.darkened(0.2)
-	else:
-		color = Color.RED.darkened(0.5)
 
 
 	# Draw raycast line.
 	# Draw raycast line.
 	add_line(pos_start, pos_end, color)
 	add_line(pos_start, pos_end, color)
@@ -91,8 +87,8 @@ func _add_raycast(space_state, pos_start, pos_end):
 	add_line(pos_end, pos_end + Vector2(5, -10), color)
 	add_line(pos_end, pos_end + Vector2(5, -10), color)
 
 
 	if result:
 	if result:
-		# Draw raycast hit pos.
-		var hit_pos = result.position
+		# Draw raycast hit position.
+		var hit_pos: Vector2 = result.position
 		add_circle(hit_pos, 4.0, Color.YELLOW)
 		add_circle(hit_pos, 4.0, Color.YELLOW)
 
 
 		# Draw raycast hit normal.
 		# Draw raycast hit normal.

+ 14 - 16
2d/physics_tests/tests/functional/test_stack.gd

@@ -1,33 +1,31 @@
 extends Test
 extends Test
 
 
+@export var height := 10
+@export var width := 1
+@export var box_size := Vector2(40.0, 40.0)
+@export var box_spacing := Vector2(0.0, 0.0)
 
 
-@export var height = 10
-@export var width = 1
-@export var box_size = Vector2(40.0, 40.0)
-@export var box_spacing =  Vector2(0.0, 0.0)
-
-
-func _ready():
+func _ready() -> void:
 	_create_stack()
 	_create_stack()
 
 
 
 
-func _create_stack():
-	var root_node = $Stack
+func _create_stack() -> void:
+	var root_node := $Stack
 
 
-	var template_body = create_rigidbody_box(box_size, true)
+	var template_body := create_rigidbody_box(box_size, true)
 
 
-	var pos_y = -0.5 * box_size.y - box_spacing.y
+	var pos_y := -0.5 * box_size.y - box_spacing.y
 
 
-	for level in height:
-		var row_node = Node2D.new()
+	for level: int in height:
+		var row_node := Node2D.new()
 		row_node.position = Vector2(0.0, pos_y)
 		row_node.position = Vector2(0.0, pos_y)
 		row_node.name = "Row%02d" % (level + 1)
 		row_node.name = "Row%02d" % (level + 1)
 		root_node.add_child(row_node)
 		root_node.add_child(row_node)
 
 
-		var pos_x = -0.5 * (width - 1) * (box_size.x + box_spacing.x)
+		var pos_x := -0.5 * (width - 1) * (box_size.x + box_spacing.x)
 
 
-		for box_index in range(width):
-			var box = template_body.duplicate()
+		for box_index in width:
+			var box := template_body.duplicate()
 			box.position = Vector2(pos_x, 0.0)
 			box.position = Vector2(pos_x, 0.0)
 			box.name = "Box%02d" % (box_index + 1)
 			box.name = "Box%02d" % (box_index + 1)
 			row_node.add_child(box)
 			row_node.add_child(box)

+ 29 - 31
2d/physics_tests/tests/performance/test_perf_broadphase.gd

@@ -1,20 +1,18 @@
 extends Test
 extends Test
 
 
-
 const BOX_SIZE = Vector2(40, 40)
 const BOX_SIZE = Vector2(40, 40)
 const BOX_SPACE = Vector2(50, 50)
 const BOX_SPACE = Vector2(50, 50)
 
 
-@export_range(1, 1000) var row_size = 100
-@export_range(1, 1000) var column_size = 100
-
-var _objects = []
+@export_range(1, 1000) var row_size := 100
+@export_range(1, 1000) var column_size := 100
 
 
-var _log_physics = false
-var _log_physics_time = 0
-var _log_physics_time_start = 0
+var _objects: Array[Node2D] = []
 
 
+var _log_physics := false
+var _log_physics_time := 0
+var _log_physics_time_start := 0
 
 
-func _ready():
+func _ready() -> void:
 	await start_timer(1.0).timeout
 	await start_timer(1.0).timeout
 	if is_timer_canceled():
 	if is_timer_canceled():
 		return
 		return
@@ -66,46 +64,46 @@ func _ready():
 	Log.print_log("* Done.")
 	Log.print_log("* Done.")
 
 
 
 
-func _exit_tree():
+func _exit_tree() -> void:
 	for object in _objects:
 	for object in _objects:
 		object.free()
 		object.free()
 
 
 
 
-func _physics_process(delta):
+func _physics_process(delta: float) -> void:
 	super._physics_process(delta)
 	super._physics_process(delta)
 
 
 	if _log_physics:
 	if _log_physics:
-		var time = Time.get_ticks_usec()
-		var time_delta = time - _log_physics_time
-		var time_total = time - _log_physics_time_start
+		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
 		_log_physics_time = time
 		Log.print_log("  Physics Tick: %.3f ms (total = %.3f ms)" % [0.001 * time_delta, 0.001 * time_total])
 		Log.print_log("  Physics Tick: %.3f ms (total = %.3f ms)" % [0.001 * time_delta, 0.001 * time_total])
 
 
 
 
-func _log_physics_start():
+func _log_physics_start() -> void:
 	_log_physics = true
 	_log_physics = true
 	_log_physics_time_start = Time.get_ticks_usec()
 	_log_physics_time_start = Time.get_ticks_usec()
 	_log_physics_time = _log_physics_time_start
 	_log_physics_time = _log_physics_time_start
 
 
 
 
-func _log_physics_stop():
+func _log_physics_stop() -> void:
 	_log_physics = false
 	_log_physics = false
 
 
 
 
-func _create_objects():
+func _create_objects() -> void:
 	_objects.clear()
 	_objects.clear()
 
 
 	Log.print_log("* Creating objects...")
 	Log.print_log("* Creating objects...")
-	var timer = Time.get_ticks_usec()
+	var timer := Time.get_ticks_usec()
 
 
-	var pos_x = -0.5 * (row_size - 1) * BOX_SPACE.x
+	var pos_x := -0.5 * (row_size - 1) * BOX_SPACE.x
 
 
 	for row in row_size:
 	for row in row_size:
-		var pos_y = -0.5 * (column_size - 1) * BOX_SPACE.y
+		var pos_y := -0.5 * (column_size - 1) * BOX_SPACE.y
 
 
 		for column in column_size:
 		for column in column_size:
 			# Create a new object and shape every time to avoid the overhead of connecting many bodies to the same shape.
 			# Create a new object and shape every time to avoid the overhead of connecting many bodies to the same shape.
-			var box = create_rigidbody_box(BOX_SIZE)
+			var box := create_rigidbody_box(BOX_SIZE)
 			box.gravity_scale = 0.0
 			box.gravity_scale = 0.0
 			box.position = Vector2(pos_x, pos_y)
 			box.position = Vector2(pos_x, pos_y)
 			_objects.push_back(box)
 			_objects.push_back(box)
@@ -118,11 +116,11 @@ func _create_objects():
 	Log.print_log("  Create Time: %.3f ms" % (0.001 * timer))
 	Log.print_log("  Create Time: %.3f ms" % (0.001 * timer))
 
 
 
 
-func _add_objects():
-	var root_node = $Objects
+func _add_objects() -> void:
+	var root_node: Node2D = $Objects
 
 
 	Log.print_log("* Adding objects...")
 	Log.print_log("* Adding objects...")
-	var timer = Time.get_ticks_usec()
+	var timer := Time.get_ticks_usec()
 
 
 	for object in _objects:
 	for object in _objects:
 		root_node.add_child(object)
 		root_node.add_child(object)
@@ -131,9 +129,9 @@ func _add_objects():
 	Log.print_log("  Add Time: %.3f ms" % (0.001 * timer))
 	Log.print_log("  Add Time: %.3f ms" % (0.001 * timer))
 
 
 
 
-func _move_objects():
+func _move_objects() -> void:
 	Log.print_log("* Moving objects...")
 	Log.print_log("* Moving objects...")
-	var timer = Time.get_ticks_usec()
+	var timer := Time.get_ticks_usec()
 
 
 	for object in _objects:
 	for object in _objects:
 		object.position += BOX_SPACE
 		object.position += BOX_SPACE
@@ -142,15 +140,15 @@ func _move_objects():
 	Log.print_log("  Move Time: %.3f ms" % (0.001 * timer))
 	Log.print_log("  Move Time: %.3f ms" % (0.001 * timer))
 
 
 
 
-func _remove_objects():
-	var root_node = $Objects
+func _remove_objects() -> void:
+	var root_node: Node2D = $Objects
 
 
 	Log.print_log("* Removing objects...")
 	Log.print_log("* Removing objects...")
-	var timer = Time.get_ticks_usec()
+	var timer := Time.get_ticks_usec()
 
 
 	# Remove objects in reversed order to avoid the overhead of changing children index in parent.
 	# Remove objects in reversed order to avoid the overhead of changing children index in parent.
-	var object_count = _objects.size()
-	for object_index in range(object_count):
+	var object_count := _objects.size()
+	for object_index in object_count:
 		root_node.remove_child(_objects[object_count - object_index - 1])
 		root_node.remove_child(_objects[object_count - object_index - 1])
 
 
 	timer = Time.get_ticks_usec() - timer
 	timer = Time.get_ticks_usec() - timer

+ 2 - 2
2d/physics_tests/tests/performance/test_perf_broadphase.tscn

@@ -3,10 +3,10 @@
 [ext_resource type="Script" path="res://tests/performance/test_perf_broadphase.gd" id="1"]
 [ext_resource type="Script" path="res://tests/performance/test_perf_broadphase.gd" id="1"]
 
 
 [node name="Test" type="Node2D"]
 [node name="Test" type="Node2D"]
-script = ExtResource( "1" )
-_enable_debug_collision = false
+script = ExtResource("1")
 row_size = 300
 row_size = 300
 column_size = 300
 column_size = 300
+_enable_debug_collision = false
 
 
 [node name="Objects" type="Node2D" parent="."]
 [node name="Objects" type="Node2D" parent="."]
 position = Vector2(512, 300)
 position = Vector2(512, 300)

+ 37 - 38
2d/physics_tests/tests/performance/test_perf_contacts.gd

@@ -1,6 +1,5 @@
 extends Test
 extends Test
 
 
-
 const OPTION_TYPE_ALL = "Shape type/All"
 const OPTION_TYPE_ALL = "Shape type/All"
 const OPTION_TYPE_RECTANGLE = "Shape type/Rectangle"
 const OPTION_TYPE_RECTANGLE = "Shape type/Rectangle"
 const OPTION_TYPE_SPHERE = "Shape type/Sphere"
 const OPTION_TYPE_SPHERE = "Shape type/Sphere"
@@ -8,27 +7,27 @@ const OPTION_TYPE_CAPSULE = "Shape type/Capsule"
 const OPTION_TYPE_CONVEX_POLYGON = "Shape type/Convex Polygon"
 const OPTION_TYPE_CONVEX_POLYGON = "Shape type/Convex Polygon"
 const OPTION_TYPE_CONCAVE_POLYGON = "Shape type/Concave Polygon"
 const OPTION_TYPE_CONCAVE_POLYGON = "Shape type/Concave Polygon"
 
 
-@export var spawns = []
-@export var spawn_count = 100
-@export var spawn_randomize = Vector2.ZERO
+@export var spawns: Array[NodePath] = []
+@export var spawn_count := 100
+@export var spawn_randomize := Vector2.ZERO
 
 
-@onready var options = $Options
+@onready var options: OptionMenu = $Options
 
 
-var _object_templates = []
+var _object_templates: Array[Node2D] = []
 
 
-var _log_physics = false
-var _log_physics_time = 0
-var _log_physics_time_start = 0
+var _log_physics := false
+var _log_physics_time := 0
+var _log_physics_time_start := 0
 
 
 
 
-func _ready():
+func _ready() -> void:
 	await start_timer(0.5).timeout
 	await start_timer(0.5).timeout
 	if is_timer_canceled():
 	if is_timer_canceled():
 		return
 		return
 
 
-	var dynamic_shapes = $DynamicShapes
+	var dynamic_shapes: Node2D = $DynamicShapes
 	while dynamic_shapes.get_child_count():
 	while dynamic_shapes.get_child_count():
-		var type_node = dynamic_shapes.get_child(0)
+		var type_node: RigidBody2D = dynamic_shapes.get_child(0)
 		type_node.position = Vector2.ZERO
 		type_node.position = Vector2.ZERO
 		_object_templates.push_back(type_node)
 		_object_templates.push_back(type_node)
 		dynamic_shapes.remove_child(type_node)
 		dynamic_shapes.remove_child(type_node)
@@ -44,33 +43,33 @@ func _ready():
 	await _start_all_types()
 	await _start_all_types()
 
 
 
 
-func _physics_process(delta):
+func _physics_process(delta: float) -> void:
 	super._physics_process(delta)
 	super._physics_process(delta)
 
 
 	if _log_physics:
 	if _log_physics:
-		var time = Time.get_ticks_usec()
-		var time_delta = time - _log_physics_time
-		var time_total = time - _log_physics_time_start
+		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
 		_log_physics_time = time
 		Log.print_log("  Physics Tick: %.3f ms (total = %.3f ms)" % [0.001 * time_delta, 0.001 * time_total])
 		Log.print_log("  Physics Tick: %.3f ms (total = %.3f ms)" % [0.001 * time_delta, 0.001 * time_total])
 
 
 
 
-func _log_physics_start():
+func _log_physics_start() -> void:
 	_log_physics = true
 	_log_physics = true
 	_log_physics_time_start = Time.get_ticks_usec()
 	_log_physics_time_start = Time.get_ticks_usec()
 	_log_physics_time = _log_physics_time_start
 	_log_physics_time = _log_physics_time_start
 
 
 
 
-func _log_physics_stop():
+func _log_physics_stop() -> void:
 	_log_physics = false
 	_log_physics = false
 
 
 
 
-func _exit_tree():
+func _exit_tree() -> void:
 	for object_template in _object_templates:
 	for object_template in _object_templates:
 		object_template.free()
 		object_template.free()
 
 
 
 
-func _on_option_selected(option):
+func _on_option_selected(option: String) -> void:
 	cancel_timer()
 	cancel_timer()
 
 
 	_despawn_objects()
 	_despawn_objects()
@@ -90,9 +89,9 @@ func _on_option_selected(option):
 			await _start_type(_find_type_index("ConcavePolygon"))
 			await _start_type(_find_type_index("ConcavePolygon"))
 
 
 
 
-func _find_type_index(type_name):
+func _find_type_index(type_name: String) -> int:
 	for type_index in range(_object_templates.size()):
 	for type_index in range(_object_templates.size()):
-		var type_node = _object_templates[type_index]
+		var type_node := _object_templates[type_index]
 		if String(type_node.name).find(type_name) > -1:
 		if String(type_node.name).find(type_name) > -1:
 			return type_index
 			return type_index
 
 
@@ -100,7 +99,7 @@ func _find_type_index(type_name):
 	return -1
 	return -1
 
 
 
 
-func _start_type(type_index):
+func _start_type(type_index: int) -> void:
 	if type_index < 0:
 	if type_index < 0:
 		return
 		return
 	if type_index >= _object_templates.size():
 	if type_index >= _object_templates.size():
@@ -142,7 +141,7 @@ func _start_type(type_index):
 	await start_timer(1.0).timeout
 	await start_timer(1.0).timeout
 
 
 
 
-func _start_all_types():
+func _start_all_types() -> void:
 	Log.print_log("* Start all types.")
 	Log.print_log("* Start all types.")
 
 
 	for type_index in range(_object_templates.size()):
 	for type_index in range(_object_templates.size()):
@@ -153,25 +152,25 @@ func _start_all_types():
 	Log.print_log("* Done all types.")
 	Log.print_log("* Done all types.")
 
 
 
 
-func _spawn_objects(type_index):
-	var template_node = _object_templates[type_index]
+func _spawn_objects(type_index: int) -> void:
+	var template_node: RigidBody2D = _object_templates[type_index]
 
 
 	Log.print_log("* Spawning: " + String(template_node.name))
 	Log.print_log("* Spawning: " + String(template_node.name))
 
 
 	for spawn in spawns:
 	for spawn in spawns:
-		var spawn_parent = get_node(spawn)
+		var spawn_parent := get_node(spawn)
 
 
 		for _node_index in range(spawn_count):
 		for _node_index in range(spawn_count):
 			# Create a new object and shape every time to avoid the overhead of connecting many bodies to the same shape.
 			# Create a new object and shape every time to avoid the overhead of connecting many bodies to the same shape.
-			var collision = template_node.get_child(0).duplicate()
+			var collision: Node2D = template_node.get_child(0).duplicate()
 			if collision is CollisionShape2D:
 			if collision is CollisionShape2D:
 				collision.shape = collision.shape.duplicate()
 				collision.shape = collision.shape.duplicate()
-			var body = template_node.duplicate()
+			var body: Node2D = template_node.duplicate()
 			body.transform = Transform2D.IDENTITY
 			body.transform = Transform2D.IDENTITY
 			if spawn_randomize != Vector2.ZERO:
 			if spawn_randomize != Vector2.ZERO:
 				body.position.x = randf() * spawn_randomize.x
 				body.position.x = randf() * spawn_randomize.x
 				body.position.y = randf() * spawn_randomize.y
 				body.position.y = randf() * spawn_randomize.y
-			var prev_collision = body.get_child(0)
+			var prev_collision: Node2D = body.get_child(0)
 			body.remove_child(prev_collision)
 			body.remove_child(prev_collision)
 			prev_collision.queue_free()
 			prev_collision.queue_free()
 			body.add_child(collision)
 			body.add_child(collision)
@@ -179,29 +178,29 @@ func _spawn_objects(type_index):
 			spawn_parent.add_child(body)
 			spawn_parent.add_child(body)
 
 
 
 
-func _activate_objects():
+func _activate_objects() -> void:
 	Log.print_log("* Activating")
 	Log.print_log("* Activating")
 
 
 	for spawn in spawns:
 	for spawn in spawns:
-		var spawn_parent = get_node(spawn)
+		var spawn_parent := get_node(spawn)
 
 
-		for node_index in range(spawn_parent.get_child_count()):
-			var node = spawn_parent.get_child(node_index) as RigidBody2D
+		for node_index in spawn_parent.get_child_count():
+			var node := spawn_parent.get_child(node_index) as RigidBody2D
 			node.set_sleeping(false)
 			node.set_sleeping(false)
 
 
 
 
-func _despawn_objects():
+func _despawn_objects() -> void:
 	Log.print_log("* Despawning")
 	Log.print_log("* Despawning")
 
 
 	for spawn in spawns:
 	for spawn in spawns:
-		var spawn_parent = get_node(spawn)
+		var spawn_parent: Node2D = get_node(spawn)
 
 
-		var object_count = spawn_parent.get_child_count()
+		var object_count := spawn_parent.get_child_count()
 		if object_count == 0:
 		if object_count == 0:
 			continue
 			continue
 
 
 		# Remove objects in reversed order to avoid the overhead of changing children index in parent.
 		# Remove objects in reversed order to avoid the overhead of changing children index in parent.
 		for object_index in range(object_count):
 		for object_index in range(object_count):
-			var node = spawn_parent.get_child(object_count - object_index - 1)
+			var node: Node2D = spawn_parent.get_child(object_count - object_index - 1)
 			spawn_parent.remove_child(node)
 			spawn_parent.remove_child(node)
 			node.queue_free()
 			node.queue_free()

+ 15 - 15
2d/physics_tests/tests/performance/test_perf_contacts.tscn

@@ -15,41 +15,41 @@ radius = 15.0
 height = 35.0
 height = 35.0
 
 
 [node name="Test" type="Node2D"]
 [node name="Test" type="Node2D"]
-script = ExtResource( "2" )
-_enable_debug_collision = false
-spawns = [NodePath("SpawnTarget1")]
+script = ExtResource("2")
+spawns = Array[NodePath]([NodePath("SpawnTarget1")])
 spawn_count = 500
 spawn_count = 500
 spawn_randomize = Vector2(10, 10)
 spawn_randomize = Vector2(10, 10)
+_enable_debug_collision = false
 
 
-[node name="Options" parent="." instance=ExtResource( "4" )]
+[node name="Options" parent="." instance=ExtResource("4")]
 
 
 [node name="SpawnTarget1" type="Node2D" parent="."]
 [node name="SpawnTarget1" type="Node2D" parent="."]
 position = Vector2(512, 400)
 position = Vector2(512, 400)
 
 
-[node name="StaticScene" parent="." instance=ExtResource( "1" )]
+[node name="StaticScene" parent="." instance=ExtResource("1")]
 position = Vector2(0, 125.017)
 position = Vector2(0, 125.017)
 
 
 [node name="DynamicShapes" type="Node2D" parent="."]
 [node name="DynamicShapes" type="Node2D" parent="."]
 
 
-[node name="RigidBodyRectangle" type="RigidDynamicBody2D" parent="DynamicShapes"]
+[node name="RigidBodyRectangle" type="RigidBody2D" parent="DynamicShapes"]
 position = Vector2(0, 1024)
 position = Vector2(0, 1024)
 
 
 [node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyRectangle"]
 [node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyRectangle"]
-shape = SubResource( "1" )
+shape = SubResource("1")
 
 
-[node name="RigidBodySphere" type="RigidDynamicBody2D" parent="DynamicShapes"]
+[node name="RigidBodySphere" type="RigidBody2D" parent="DynamicShapes"]
 position = Vector2(100, 1024)
 position = Vector2(100, 1024)
 
 
 [node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodySphere"]
 [node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodySphere"]
-shape = SubResource( "2" )
+shape = SubResource("2")
 
 
-[node name="RigidBodyCapsule" type="RigidDynamicBody2D" parent="DynamicShapes"]
+[node name="RigidBodyCapsule" type="RigidBody2D" parent="DynamicShapes"]
 position = Vector2(200, 1024)
 position = Vector2(200, 1024)
 
 
 [node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyCapsule"]
 [node name="CollisionShape2D" type="CollisionShape2D" parent="DynamicShapes/RigidBodyCapsule"]
-shape = SubResource( "3" )
+shape = SubResource("3")
 
 
-[node name="RigidBodyConvexPolygon" type="RigidDynamicBody2D" parent="DynamicShapes"]
+[node name="RigidBodyConvexPolygon" type="RigidBody2D" parent="DynamicShapes"]
 position = Vector2(300, 1024)
 position = Vector2(300, 1024)
 
 
 [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConvexPolygon"]
 [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConvexPolygon"]
@@ -59,9 +59,9 @@ polygon = PackedVector2Array(10.7, -54.5, 28.3596, -49.4067, 47.6282, -34.3806,
 [node name="GodotIcon" type="Sprite2D" parent="DynamicShapes/RigidBodyConvexPolygon"]
 [node name="GodotIcon" type="Sprite2D" parent="DynamicShapes/RigidBodyConvexPolygon"]
 self_modulate = Color(1, 1, 1, 0.392157)
 self_modulate = Color(1, 1, 1, 0.392157)
 scale = Vector2(0.25, 0.25)
 scale = Vector2(0.25, 0.25)
-texture = ExtResource( "3" )
+texture = ExtResource("3")
 
 
-[node name="RigidBodyConcavePolygon" type="RigidDynamicBody2D" parent="DynamicShapes"]
+[node name="RigidBodyConcavePolygon" type="RigidBody2D" parent="DynamicShapes"]
 position = Vector2(400, 1024)
 position = Vector2(400, 1024)
 
 
 [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConcavePolygon"]
 [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="DynamicShapes/RigidBodyConcavePolygon"]
@@ -71,4 +71,4 @@ polygon = PackedVector2Array(-5.93512, -43.2195, 6.44476, -42.9695, 11.127, -54.
 [node name="GodotIcon" type="Sprite2D" parent="DynamicShapes/RigidBodyConcavePolygon"]
 [node name="GodotIcon" type="Sprite2D" parent="DynamicShapes/RigidBodyConcavePolygon"]
 self_modulate = Color(1, 1, 1, 0.392157)
 self_modulate = Color(1, 1, 1, 0.392157)
 scale = Vector2(0.25, 0.25)
 scale = Vector2(0.25, 0.25)
-texture = ExtResource( "3" )
+texture = ExtResource("3")

+ 13 - 14
2d/physics_tests/tests_menu.gd

@@ -2,28 +2,27 @@ extends OptionMenu
 
 
 
 
 class TestData:
 class TestData:
-	var id
-	var scene_path
+	var id := ""
+	var scene_path := ""
 
 
 
 
-var _test_list = []
+var _test_list := []
 
 
-var _current_test = null
+var _current_test: TestData = null
 var _current_test_scene: Node = null
 var _current_test_scene: Node = null
 
 
-
-func _ready():
+func _ready() -> void:
 	option_selected.connect(_on_option_selected)
 	option_selected.connect(_on_option_selected)
 
 
 
 
-func _process(_delta):
+func _process(_delta: float) -> void:
 	if Input.is_action_just_pressed(&"restart_test"):
 	if Input.is_action_just_pressed(&"restart_test"):
 		if _current_test:
 		if _current_test:
 			_start_test(_current_test)
 			_start_test(_current_test)
 
 
 
 
-func add_test(id, scene_path):
-	var test_data = TestData.new()
+func add_test(id: String, scene_path: String) -> void:
+	var test_data := TestData.new()
 	test_data.id = id
 	test_data.id = id
 	test_data.scene_path = scene_path
 	test_data.scene_path = scene_path
 	_test_list.append(test_data)
 	_test_list.append(test_data)
@@ -31,13 +30,13 @@ func add_test(id, scene_path):
 	add_menu_item(id)
 	add_menu_item(id)
 
 
 
 
-func _on_option_selected(item_path):
-	for test in _test_list:
+func _on_option_selected(item_path: String) -> void:
+	for test: TestData in _test_list:
 		if test.id == item_path:
 		if test.id == item_path:
 			_start_test(test)
 			_start_test(test)
 
 
 
 
-func _start_test(test):
+func _start_test(test: TestData) -> void:
 	_current_test = test
 	_current_test = test
 
 
 	if _current_test_scene:
 	if _current_test_scene:
@@ -45,10 +44,10 @@ func _start_test(test):
 		_current_test_scene = null
 		_current_test_scene = null
 
 
 	Log.print_log("*** STARTING TEST: " + test.id)
 	Log.print_log("*** STARTING TEST: " + test.id)
-	var scene = load(test.scene_path)
+	var scene := load(test.scene_path)
 	_current_test_scene = scene.instantiate()
 	_current_test_scene = scene.instantiate()
 	get_tree().root.add_child(_current_test_scene)
 	get_tree().root.add_child(_current_test_scene)
 	get_tree().root.move_child(_current_test_scene, 0)
 	get_tree().root.move_child(_current_test_scene, 0)
 
 
-	var label_test = get_node(^"../LabelTest")
+	var label_test: Label = $"../LabelTest"
 	label_test.test_name = test.id
 	label_test.test_name = test.id

+ 16 - 17
2d/physics_tests/utils/characterbody_controller.gd

@@ -1,22 +1,21 @@
 extends CharacterBody2D
 extends CharacterBody2D
 
 
-
-var _initial_velocity = Vector2.ZERO
-var _constant_velocity = Vector2.ZERO
-var _motion_speed = 400.0
-var _gravity_force = 50.0
-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
-
-
-func _physics_process(_delta):
+var _initial_velocity := Vector2.ZERO
+var _constant_velocity := Vector2.ZERO
+var _motion_speed := 400.0
+var _gravity_force := 50.0
+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
+
+
+func _physics_process(_delta: float) -> void:
 	if _initial_velocity != Vector2.ZERO:
 	if _initial_velocity != Vector2.ZERO:
 		_velocity = _initial_velocity
 		_velocity = _initial_velocity
 		_initial_velocity = Vector2.ZERO
 		_initial_velocity = Vector2.ZERO

+ 9 - 11
2d/physics_tests/utils/container_log.gd

@@ -1,31 +1,29 @@
 extends Control
 extends Control
 
 
-
 const MAX_ENTRIES = 100
 const MAX_ENTRIES = 100
 
 
-var _entry_template
-
+var _entry_template: Label
 
 
-func _enter_tree():
+func _enter_tree() -> void:
 	Log.entry_logged.connect(_on_log_entry)
 	Log.entry_logged.connect(_on_log_entry)
 
 
-	_entry_template = get_child(0) as Label
+	_entry_template = get_child(0)
 	remove_child(_entry_template)
 	remove_child(_entry_template)
 
 
 
 
-func _exit_tree():
+func _exit_tree() -> void:
 	_entry_template.free()
 	_entry_template.free()
 
 
 
 
-func clear():
+func clear() -> void:
 	while get_child_count():
 	while get_child_count():
-		var entry = get_child(get_child_count() - 1)
+		var entry := get_child(get_child_count() - 1)
 		remove_child(entry)
 		remove_child(entry)
 		entry.queue_free()
 		entry.queue_free()
 
 
 
 
-func _on_log_entry(message, type):
-	var new_entry = _entry_template.duplicate() as Label
+func _on_log_entry(message: String, type: Log.LogType) -> void:
+	var new_entry: Label = _entry_template.duplicate()
 
 
 	new_entry.set_text(message)
 	new_entry.set_text(message)
 	if type == Log.LogType.ERROR:
 	if type == Log.LogType.ERROR:
@@ -34,7 +32,7 @@ func _on_log_entry(message, type):
 		new_entry.modulate = Color.WHITE
 		new_entry.modulate = Color.WHITE
 
 
 	if get_child_count() >= MAX_ENTRIES:
 	if get_child_count() >= MAX_ENTRIES:
-		var first_entry = get_child(0) as Label
+		var first_entry: Label = get_child(0)
 		remove_child(first_entry)
 		remove_child(first_entry)
 		first_entry.queue_free()
 		first_entry.queue_free()
 
 

+ 5 - 4
2d/physics_tests/utils/label_engine.gd

@@ -1,12 +1,13 @@
 extends Label
 extends Label
 
 
+func _ready() -> void:
+	var engine_name := ""
 
 
-func _process(_delta):
-	var engine_name = ""
 	match System.get_physics_engine():
 	match System.get_physics_engine():
 		System.PhysicsEngine.GODOT_PHYSICS:
 		System.PhysicsEngine.GODOT_PHYSICS:
 			engine_name = "GodotPhysics 2D"
 			engine_name = "GodotPhysics 2D"
 		System.PhysicsEngine.OTHER:
 		System.PhysicsEngine.OTHER:
-			var engine_setting = ProjectSettings.get_setting("physics/2d/physics_engine")
+			var engine_setting := String(ProjectSettings.get_setting("physics/2d/physics_engine"))
 			engine_name = "Other (%s)" % engine_setting
 			engine_name = "Other (%s)" % engine_setting
-	set_text("Physics engine: %s" % engine_name)
+
+	text = "Physics engine: %s" % engine_name

+ 2 - 3
2d/physics_tests/utils/label_fps.gd

@@ -1,5 +1,4 @@
 extends Label
 extends Label
 
 
-
-func _process(_delta):
-	set_text("FPS: %d" % Engine.get_frames_per_second())
+func _process(_delta: float) -> void:
+	text = "%d FPS (%.2f mspf)" % [Engine.get_frames_per_second(), 1000.0 / Engine.get_frames_per_second()]

+ 1 - 1
2d/physics_tests/utils/label_pause.gd

@@ -1,5 +1,5 @@
 extends Label
 extends Label
 
 
 
 
-func _process(_delta):
+func _process(_delta: float) -> void:
 	visible = get_tree().paused
 	visible = get_tree().paused

+ 2 - 2
2d/physics_tests/utils/label_slider_value.gd

@@ -2,6 +2,6 @@
 extends Label
 extends Label
 
 
 
 
-func _process(_delta):
-	var slider = get_node(^"../HSlider")
+func _process(_delta: float) -> void:
+	var slider: HSlider = get_node(^"../HSlider")
 	text = "%.1f" % slider.value
 	text = "%.1f" % slider.value

+ 2 - 3
2d/physics_tests/utils/label_test.gd

@@ -1,7 +1,6 @@
 extends Label
 extends Label
 
 
-
-var test_name = "":
+var test_name := "":
 	set(value):
 	set(value):
 		if (test_name != value):
 		if (test_name != value):
 			return
 			return
@@ -9,5 +8,5 @@ var test_name = "":
 		set_text("Test: %s" % test_name)
 		set_text("Test: %s" % test_name)
 
 
 
 
-func _ready():
+func _ready() -> void:
 	set_text("Select a test from the menu to start it")
 	set_text("Select a test from the menu to start it")

+ 2 - 3
2d/physics_tests/utils/label_version.gd

@@ -1,5 +1,4 @@
 extends Label
 extends Label
 
 
-
-func _process(_delta):
-	set_text("Godot Version: %s" % Engine.get_version_info().string)
+func _ready() -> void:
+	text = "Godot Version: %s" % Engine.get_version_info().string

+ 20 - 21
2d/physics_tests/utils/option_menu.gd

@@ -1,24 +1,23 @@
 class_name OptionMenu
 class_name OptionMenu
 extends MenuButton
 extends MenuButton
 
 
+signal option_selected(item_path: String)
+signal option_changed(item_path: String, checked: bool)
 
 
-signal option_selected(item_path)
-signal option_changed(item_path, checked)
 
 
-
-func add_menu_item(item_path, checkbox = false, checked = false, radio = false):
-	var path_elements = item_path.split("/", false)
-	var path_element_count = path_elements.size()
+func add_menu_item(item_path: String, checkbox: bool = false, checked: bool = false, radio: bool = false) -> void:
+	var path_elements := item_path.split("/", false)
+	var path_element_count := path_elements.size()
 	assert(path_element_count > 0)
 	assert(path_element_count > 0)
 
 
-	var path = ""
-	var popup = get_popup()
+	var path := ""
+	var popup := get_popup()
 	for element_index in range(path_element_count - 1):
 	for element_index in range(path_element_count - 1):
-		var popup_label = path_elements[element_index]
+		var popup_label := path_elements[element_index]
 		path += popup_label + "/"
 		path += popup_label + "/"
 		popup = _add_popup(popup, path, popup_label)
 		popup = _add_popup(popup, path, popup_label)
 
 
-	var label = path_elements[path_element_count - 1]
+	var label := path_elements[path_element_count - 1]
 	if radio:
 	if radio:
 		popup.add_radio_check_item(label)
 		popup.add_radio_check_item(label)
 		popup.set_item_checked(popup.get_item_count() - 1, checked)
 		popup.set_item_checked(popup.get_item_count() - 1, checked)
@@ -29,18 +28,18 @@ func add_menu_item(item_path, checkbox = false, checked = false, radio = false):
 		popup.add_item(label)
 		popup.add_item(label)
 
 
 
 
-func _add_item(parent_popup, label):
+func _add_item(parent_popup: PopupMenu, label: String) -> void:
 	parent_popup.add_item(label)
 	parent_popup.add_item(label)
 
 
 
 
-func _add_popup(parent_popup, path, label):
+func _add_popup(parent_popup: PopupMenu, path: String, label: String) -> PopupMenu:
 	if parent_popup.has_node(label):
 	if parent_popup.has_node(label):
-		var popup_node = parent_popup.get_node(label)
-		var popup_menu = popup_node as PopupMenu
-		assert(popup_menu)
-		return popup_menu
+		var popup_node := parent_popup.get_node(label)
+		var new_popup_menu: PopupMenu = popup_node
+		assert(new_popup_menu)
+		return new_popup_menu
 
 
-	var popup_menu = PopupMenu.new()
+	var popup_menu := PopupMenu.new()
 	popup_menu.name = label
 	popup_menu.name = label
 	popup_menu.hide_on_checkable_item_selection = false
 	popup_menu.hide_on_checkable_item_selection = false
 
 
@@ -52,11 +51,11 @@ func _add_popup(parent_popup, path, label):
 	return popup_menu
 	return popup_menu
 
 
 
 
-func _on_item_pressed(item_index, popup_menu, path):
-	var item_path = path + popup_menu.get_item_text(item_index)
+func _on_item_pressed(item_index: int, popup_menu: PopupMenu, path: String) -> void:
+	var item_path := path + popup_menu.get_item_text(item_index)
 
 
 	if popup_menu.is_item_radio_checkable(item_index):
 	if popup_menu.is_item_radio_checkable(item_index):
-		var checked = popup_menu.is_item_checked(item_index)
+		var checked := popup_menu.is_item_checked(item_index)
 		if not checked:
 		if not checked:
 			popup_menu.set_item_checked(item_index, true)
 			popup_menu.set_item_checked(item_index, true)
 			for other_index in range(popup_menu.get_item_count()):
 			for other_index in range(popup_menu.get_item_count()):
@@ -64,7 +63,7 @@ func _on_item_pressed(item_index, popup_menu, path):
 					popup_menu.set_item_checked(other_index, false)
 					popup_menu.set_item_checked(other_index, false)
 			option_selected.emit(item_path)
 			option_selected.emit(item_path)
 	elif popup_menu.is_item_checkable(item_index):
 	elif popup_menu.is_item_checkable(item_index):
-		var checked = not popup_menu.is_item_checked(item_index)
+		var checked := not popup_menu.is_item_checked(item_index)
 		popup_menu.set_item_checked(item_index, checked)
 		popup_menu.set_item_checked(item_index, checked)
 		option_changed.emit(item_path, checked)
 		option_changed.emit(item_path, checked)
 	else:
 	else:

+ 17 - 18
2d/physics_tests/utils/rigidbody_controller.gd

@@ -1,22 +1,21 @@
 extends RigidBody2D
 extends RigidBody2D
 
 
+var _initial_velocity := Vector2.ZERO
+var _constant_velocity := Vector2.ZERO
+var _motion_speed := 400.0
+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 _initial_velocity = Vector2.ZERO
-var _constant_velocity = Vector2.ZERO
-var _motion_speed = 400.0
-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
-
-
-func _ready():
+func _ready() -> void:
 	gravity_scale = 0.0
 	gravity_scale = 0.0
 
 
-func _physics_process(_delta):
+
+func _physics_process(_delta: float) -> void:
 	if _initial_velocity != Vector2.ZERO:
 	if _initial_velocity != Vector2.ZERO:
 		_velocity = _initial_velocity
 		_velocity = _initial_velocity
 		_initial_velocity = Vector2.ZERO
 		_initial_velocity = Vector2.ZERO
@@ -54,12 +53,12 @@ func _physics_process(_delta):
 	linear_velocity = _velocity
 	linear_velocity = _velocity
 
 
 
 
-func _integrate_forces(state):
+func _integrate_forces(state: PhysicsDirectBodyState2D) -> void:
 	_on_floor = false
 	_on_floor = false
 
 
-	var contacts = state.get_contact_count()
+	var contacts := state.get_contact_count()
 	for i in contacts:
 	for i in contacts:
-		var normal = state.get_contact_local_normal(i)
+		var normal := state.get_contact_local_normal(i)
 
 
 		# Detect floor.
 		# Detect floor.
 		if acos(normal.dot(Vector2.UP)) <= deg_to_rad(_floor_max_angle) + 0.01:
 		if acos(normal.dot(Vector2.UP)) <= deg_to_rad(_floor_max_angle) + 0.01:
@@ -70,5 +69,5 @@ func _integrate_forces(state):
 			_jumping = false
 			_jumping = false
 			_velocity.y = 0.0
 			_velocity.y = 0.0
 
 
-func is_on_floor():
+func is_on_floor() -> bool:
 	return _on_floor
 	return _on_floor

+ 9 - 10
2d/physics_tests/utils/rigidbody_pick.gd

@@ -1,30 +1,29 @@
 extends RigidBody2D
 extends RigidBody2D
 
 
+var _picked := false
+var _last_mouse_pos := Vector2.ZERO
 
 
-var _picked = false
-var _last_mouse_pos = Vector2.ZERO
 
 
-
-func _ready():
+func _ready() -> void:
 	input_pickable = true
 	input_pickable = true
 
 
 
 
-func _input(event):
-	var mouse_event = event as InputEventMouseButton
+func _input(event: InputEvent) -> void:
+	var mouse_event := event as InputEventMouseButton
 	if mouse_event and not mouse_event.pressed:
 	if mouse_event and not mouse_event.pressed:
 		_picked = false
 		_picked = false
 
 
 
 
-func _input_event(_viewport, event, _shape_idx):
-	var mouse_event = event as InputEventMouseButton
+func _input_event(_viewport: Node, event: InputEvent, _shape_idx: int) -> void:
+	var mouse_event := event as InputEventMouseButton
 	if mouse_event and mouse_event.pressed:
 	if mouse_event and mouse_event.pressed:
 		_picked = true
 		_picked = true
 		_last_mouse_pos = get_global_mouse_position()
 		_last_mouse_pos = get_global_mouse_position()
 
 
 
 
-func _physics_process(delta):
+func _physics_process(delta: float) -> void:
 	if _picked:
 	if _picked:
-		var mouse_pos = get_global_mouse_position()
+		var mouse_pos := get_global_mouse_position()
 		if freeze:
 		if freeze:
 			global_position = mouse_pos
 			global_position = mouse_pos
 		else:
 		else:

+ 7 - 9
2d/physics_tests/utils/scroll_log.gd

@@ -1,24 +1,22 @@
 extends ScrollContainer
 extends ScrollContainer
 
 
+@export var auto_scroll := false
 
 
-@export var auto_scroll = false
-
-
-func _ready():
-	var scrollbar = get_v_scroll_bar()
+func _ready() -> void:
+	var scrollbar := get_v_scroll_bar()
 	scrollbar.scrolling.connect(_on_scrolling)
 	scrollbar.scrolling.connect(_on_scrolling)
 
 
 
 
-func _process(_delta):
+func _process(_delta: float) -> void:
 	if auto_scroll:
 	if auto_scroll:
-		var scrollbar = get_v_scroll_bar()
+		var scrollbar := get_v_scroll_bar()
 		scrollbar.value = scrollbar.max_value
 		scrollbar.value = scrollbar.max_value
 
 
 
 
-func _on_scrolling():
+func _on_scrolling() -> void:
 	auto_scroll = false
 	auto_scroll = false
 	$"../CheckBoxScroll".button_pressed = false
 	$"../CheckBoxScroll".button_pressed = false
 
 
 
 
-func _on_check_box_scroll_toggled(button_pressed):
+func _on_check_box_scroll_toggled(button_pressed: bool) -> void:
 	auto_scroll = button_pressed
 	auto_scroll = button_pressed

+ 2 - 2
2d/physics_tests/utils/slider.gd

@@ -1,10 +1,10 @@
 extends HSlider
 extends HSlider
 
 
 
 
-@export var snap_step = 1.0
+@export var snap_step := 1.0
 
 
 
 
-func _process(_delta):
+func _process(_delta: float) -> void:
 	if Input.is_key_pressed(KEY_SHIFT):
 	if Input.is_key_pressed(KEY_SHIFT):
 		step = 0.1
 		step = 0.1
 	else:
 	else:

+ 10 - 10
2d/physics_tests/utils/system.gd

@@ -1,20 +1,20 @@
 extends Node
 extends Node
 
 
-
 enum PhysicsEngine {
 enum PhysicsEngine {
 	GODOT_PHYSICS,
 	GODOT_PHYSICS,
 	OTHER,
 	OTHER,
 }
 }
 
 
-var _engine = PhysicsEngine.OTHER
-
+var _engine: PhysicsEngine = PhysicsEngine.OTHER
 
 
-func _enter_tree():
+func _enter_tree() -> void:
 	process_mode = Node.PROCESS_MODE_ALWAYS
 	process_mode = Node.PROCESS_MODE_ALWAYS
 
 
+	# Always enable visible collision shapes on startup
+	# (same as the Debug > Visible Collision Shapes option).
 	get_tree().debug_collisions_hint = true
 	get_tree().debug_collisions_hint = true
 
 
-	var engine_string = ProjectSettings.get_setting("physics/2d/physics_engine")
+	var engine_string:= String(ProjectSettings.get_setting("physics/2d/physics_engine"))
 	match engine_string:
 	match engine_string:
 		"DEFAULT":
 		"DEFAULT":
 			_engine = PhysicsEngine.GODOT_PHYSICS
 			_engine = PhysicsEngine.GODOT_PHYSICS
@@ -24,7 +24,7 @@ func _enter_tree():
 			_engine = PhysicsEngine.OTHER
 			_engine = PhysicsEngine.OTHER
 
 
 
 
-func _process(_delta):
+func _process(_delta: float) -> void:
 	if Input.is_action_just_pressed(&"toggle_full_screen"):
 	if Input.is_action_just_pressed(&"toggle_full_screen"):
 		if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
 		if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
 			DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
 			DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
@@ -32,7 +32,7 @@ func _process(_delta):
 			DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
 			DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
 
 
 	if Input.is_action_just_pressed(&"toggle_debug_collision"):
 	if Input.is_action_just_pressed(&"toggle_debug_collision"):
-		var debug_collision_enabled = not _is_debug_collision_enabled()
+		var debug_collision_enabled := not _is_debug_collision_enabled()
 		_set_debug_collision_enabled(debug_collision_enabled)
 		_set_debug_collision_enabled(debug_collision_enabled)
 		if debug_collision_enabled:
 		if debug_collision_enabled:
 			Log.print_log("Debug Collision ON")
 			Log.print_log("Debug Collision ON")
@@ -46,13 +46,13 @@ func _process(_delta):
 		get_tree().quit()
 		get_tree().quit()
 
 
 
 
-func get_physics_engine():
+func get_physics_engine() -> PhysicsEngine:
 	return _engine
 	return _engine
 
 
 
 
-func _set_debug_collision_enabled(enabled):
+func _set_debug_collision_enabled(enabled: bool) -> void:
 	get_tree().debug_collisions_hint = enabled
 	get_tree().debug_collisions_hint = enabled
 
 
 
 
-func _is_debug_collision_enabled():
+func _is_debug_collision_enabled() -> bool:
 	return get_tree().debug_collisions_hint
 	return get_tree().debug_collisions_hint

+ 3 - 5
2d/physics_tests/utils/system_log.gd

@@ -1,20 +1,18 @@
 extends Node
 extends Node
 
 
-
 enum LogType {
 enum LogType {
 	LOG,
 	LOG,
 	ERROR,
 	ERROR,
 }
 }
 
 
-signal entry_logged(message, type)
-
+signal entry_logged(message: String, type: LogType)
 
 
-func print_log(message):
+func print_log(message: String) -> void:
 	print(message)
 	print(message)
 	entry_logged.emit(message, LogType.LOG)
 	entry_logged.emit(message, LogType.LOG)
 
 
 
 
-func print_error(message):
+func print_error(message: String) -> void:
 	push_error(message)
 	push_error(message)
 	printerr(message)
 	printerr(message)
 	entry_logged.emit(message, LogType.ERROR)
 	entry_logged.emit(message, LogType.ERROR)

+ 2 - 2
2d/platformer/enemy/enemy.gd

@@ -1,5 +1,5 @@
-class_name Enemy extends CharacterBody2D
-
+class_name Enemy
+extends CharacterBody2D
 
 
 enum State {
 enum State {
 	WALKING,
 	WALKING,

+ 2 - 1
2d/platformer/game.gd

@@ -1,4 +1,5 @@
-class_name Game extends Node
+class_name Game
+extends Node
 
 
 
 
 @onready var _pause_menu := $InterfaceLayer/PauseMenu as PauseMenu
 @onready var _pause_menu := $InterfaceLayer/PauseMenu as PauseMenu

+ 2 - 2
2d/platformer/gui/coins_counter.gd

@@ -1,5 +1,5 @@
-class_name CoinsCounter extends Panel
-
+class_name CoinsCounter
+extends Panel
 
 
 var _coins_collected: int = 0
 var _coins_collected: int = 0
 
 

+ 2 - 1
2d/platformer/gui/pause_menu.gd

@@ -1,4 +1,5 @@
-class_name PauseMenu extends Control
+class_name PauseMenu
+extends Control
 
 
 
 
 @export var fade_in_duration := 0.3
 @export var fade_in_duration := 0.3

+ 2 - 1
2d/platformer/level/coin.gd

@@ -1,4 +1,5 @@
-class_name Coin extends Area2D
+class_name Coin
+extends Area2D
 ## Collectible that disappears when the player touches it.
 ## Collectible that disappears when the player touches it.
 
 
 
 

+ 0 - 1
2d/platformer/level/level.gd

@@ -1,6 +1,5 @@
 extends Node2D
 extends Node2D
 
 
-
 const LIMIT_LEFT = -315
 const LIMIT_LEFT = -315
 const LIMIT_TOP = -250
 const LIMIT_TOP = -250
 const LIMIT_RIGHT = 955
 const LIMIT_RIGHT = 955

+ 2 - 1
2d/platformer/player/bullet.gd

@@ -1,4 +1,5 @@
-class_name Bullet extends RigidBody2D
+class_name Bullet
+extends RigidBody2D
 
 
 
 
 @onready var animation_player := $AnimationPlayer as AnimationPlayer
 @onready var animation_player := $AnimationPlayer as AnimationPlayer

Some files were not shown because too many files changed in this diff