Files
Hugo Locurcio bac1e69164 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).
2024-06-01 12:12:18 +02:00

24 lines
807 B
GDScript

extends Node3D
## Camera idle scale effect intensity.
const CAMERA_IDLE_SCALE = 0.005
var counter := 0.0
@onready var camera_base_rotation: Vector3 = $Camera3D.rotation
func _ready() -> void:
# Clear the viewport.
var viewport: SubViewport = $SubViewport
viewport.render_target_clear_mode = SubViewport.CLEAR_MODE_ONCE
# Retrieve the texture and set it to the viewport quad.
$ViewportQuad.material_override.albedo_texture = viewport.get_texture()
func _process(delta: float) -> void:
# Animate the camera with an "idle" animation.
counter += delta
$Camera3D.rotation.x = camera_base_rotation.y + cos(counter) * CAMERA_IDLE_SCALE
$Camera3D.rotation.y = camera_base_rotation.y + sin(counter) * CAMERA_IDLE_SCALE
$Camera3D.rotation.z = camera_base_rotation.y + sin(counter) * CAMERA_IDLE_SCALE