mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-04 23:10:08 +01:00
- Allow placing/breaking blocks when further away (up to 5 blocks instead of 4). - Add a background to the debug display to improve readability on bright backgrounds. - Simplify coordinate display using the `%v` placeholder available in 4.3 onwards.
29 lines
928 B
GDScript
29 lines
928 B
GDScript
extends Label
|
|
# Displays some useful debug information in a Label.
|
|
|
|
@onready var player := $"../Player"
|
|
@onready var voxel_world := $"../VoxelWorld"
|
|
|
|
func _process(_delta: float) -> void:
|
|
if Input.is_action_just_pressed(&"debug"):
|
|
visible = not visible
|
|
|
|
text = "Position: %.1v" % player.transform.origin \
|
|
+ "\nEffective render distance: " + str(voxel_world.effective_render_distance) \
|
|
+ "\nLooking: " + _cardinal_string_from_radians(player.transform.basis.get_euler().y) \
|
|
+ "\nMemory: " + "%3.0f" % (OS.get_static_memory_usage() / 1048576.0) + " MiB" \
|
|
+ "\nFPS: %d" % Engine.get_frames_per_second()
|
|
|
|
|
|
# Expects a rotation where 0 is North, on the range -PI to PI.
|
|
func _cardinal_string_from_radians(angle: float) -> String:
|
|
if angle > TAU * 3 / 8:
|
|
return "South"
|
|
if angle < -TAU * 3 / 8:
|
|
return "South"
|
|
if angle > TAU * 1 / 8:
|
|
return "West"
|
|
if angle < -TAU * 1 / 8:
|
|
return "East"
|
|
return "North"
|