From 6c3e080ad94dcbd3a3db678dd55da51cde869335 Mon Sep 17 00:00:00 2001 From: dusoleil Date: Sat, 23 Jul 2022 17:15:46 -0400 Subject: Add FPS Counter --- FPS Counter.gd | 4 ++++ Main.tscn | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 FPS Counter.gd diff --git a/FPS Counter.gd b/FPS Counter.gd new file mode 100644 index 0000000..cc082a2 --- /dev/null +++ b/FPS Counter.gd @@ -0,0 +1,4 @@ +extends Label + +func _process(_delta): + set_text("FPS: %.1f" % Engine.get_frames_per_second()) diff --git a/Main.tscn b/Main.tscn index 5f502df..4920fb8 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=12 format=2] +[gd_scene load_steps=14 format=2] [ext_resource path="res://Main.gd" type="Script" id=1] [ext_resource path="res://Ground.png" type="Texture" id=2] [ext_resource path="res://Player.tscn" type="PackedScene" id=3] [ext_resource path="res://Chicken.tscn" type="PackedScene" id=4] [ext_resource path="res://fence.tres" type="Material" id=5] +[ext_resource path="res://FPS Counter.gd" type="Script" id=6] [sub_resource type="BoxShape" id=1] extents = Vector3( 25, 1, 25 ) @@ -25,6 +26,9 @@ extents = Vector3( 5, 1, 0.05 ) [sub_resource type="BoxShape" id=6] extents = Vector3( 0.05, 1, 5 ) +[sub_resource type="Theme" id=8] +Label/colors/font_color = Color( 0.00784314, 0.0392157, 0.811765, 1 ) + [node name="Main" type="Node"] script = ExtResource( 1 ) chicken = ExtResource( 4 ) @@ -87,13 +91,22 @@ transform = Transform( 1, 0, 0, 0, 0.968718, 0.248166, 0, -0.248166, 0.968718, 0 [node name="UI" type="Control" parent="."] anchor_right = 1.0 anchor_bottom = 1.0 +theme = SubResource( 8 ) [node name="Controls" type="Label" parent="UI"] margin_right = 166.0 margin_bottom = 82.0 -custom_colors/font_color = Color( 0.00784314, 0.0392157, 0.811765, 1 ) text = "move: WASD or Left Stick look: Arrows or Right Stick up: Space or Right Trigger down: Ctrl or Left Trigger Release Cursor: Esc" + +[node name="FPS Counter" type="Label" parent="UI"] +anchor_left = 1.0 +anchor_right = 1.0 +margin_left = -114.0 +margin_bottom = 14.0 +text = "FPS: 10000000.00" +align = 2 +script = ExtResource( 6 ) -- cgit v1.2.3