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).
This commit is contained in:
Hugo Locurcio
2024-06-01 12:12:18 +02:00
committed by GitHub
parent 8e9c180278
commit bac1e69164
498 changed files with 5218 additions and 4776 deletions

View File

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

View File

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