mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-04 15:00:09 +01:00
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:
@@ -108,7 +108,7 @@ mesh = SubResource("1")
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="."]
|
||||
transform = Transform3D(0.877582, 0.229849, -0.420736, 0, 0.877582, 0.479426, 0.479426, -0.420736, 0.770151, -1.68294, 2.25571, 3.0806)
|
||||
fov = 74.0
|
||||
fov = 60.0
|
||||
|
||||
[node name="OmniLight3D" type="OmniLight3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.3, 2, 1)
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
extends Control
|
||||
|
||||
## The 3D viewport's shrink factor. For instance, 1 is full resolution,
|
||||
## 2 is half resolution and 4 is quarter resolution. Lower values look
|
||||
## sharper but are slower to render.
|
||||
var scale_factor := 1
|
||||
|
||||
# The 3D viewport's shrink factor. For instance, 1 is full resolution,
|
||||
# 2 is half resolution and 4 is quarter resolution. Lower values look
|
||||
# sharper but are slower to render.
|
||||
var scale_factor = 1
|
||||
var filter_mode = Viewport.SCALING_3D_MODE_BILINEAR
|
||||
var filter_mode := Viewport.SCALING_3D_MODE_BILINEAR
|
||||
|
||||
@onready var viewport = get_tree().root
|
||||
@onready var scale_label = $VBoxContainer/Scale
|
||||
@onready var filter_label = $VBoxContainer/Filter
|
||||
@onready var viewport: Window = get_tree().root
|
||||
@onready var scale_label: Label = $VBoxContainer/Scale
|
||||
@onready var filter_label: Label = $VBoxContainer/Filter
|
||||
|
||||
|
||||
func _ready():
|
||||
viewport.scaling_3d_mode = Viewport.SCALING_3D_MODE_BILINEAR
|
||||
func _ready() -> void:
|
||||
viewport.scaling_3d_mode = filter_mode
|
||||
|
||||
|
||||
func _unhandled_input(event):
|
||||
if event.is_action_pressed("cycle_viewport_resolution"):
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed(&"cycle_viewport_resolution"):
|
||||
scale_factor = wrapi(scale_factor + 1, 1, 5)
|
||||
viewport.scaling_3d_scale = 1.0 / scale_factor
|
||||
scale_label.text = "Scale: %3.0f%%" % (100.0 / scale_factor)
|
||||
|
||||
if event.is_action_pressed("toggle_filtering"):
|
||||
if event.is_action_pressed(&"toggle_filtering"):
|
||||
filter_mode = wrapi(filter_mode + 1, Viewport.SCALING_3D_MODE_BILINEAR, Viewport.SCALING_3D_MODE_MAX) as Viewport.Scaling3DMode
|
||||
viewport.scaling_3d_mode = filter_mode
|
||||
filter_label.text = (
|
||||
|
||||
@@ -21,6 +21,10 @@ run/main_scene="res://hud.tscn"
|
||||
config/features=PackedStringArray("4.2")
|
||||
config/icon="res://icon.webp"
|
||||
|
||||
[debug]
|
||||
|
||||
gdscript/warnings/untyped_declaration=1
|
||||
|
||||
[display]
|
||||
|
||||
window/stretch/mode="canvas_items"
|
||||
|
||||
Reference in New Issue
Block a user