Adds in-game debug menu addon

Adds an in-game debug menu that displays performance metrics (FPS, frame times) and hardware/software information.

The menu can be toggled using the F3 key (or a custom input binding). It has different display styles, ranging from a compact FPS display to a detailed view with graphs and system information.
This commit is contained in:
Dan Baker 2025-05-04 17:53:46 +01:00
parent 214e0aa5e0
commit ff62d67f54
37 changed files with 1484 additions and 49 deletions

View file

@ -1,9 +1,12 @@
extends CharacterBody2D
@export var speed = 200
@export var weapon: RangedWeapon
@export var special_ability: Ability
@export var movement: PlayerMovement
var weapon: RangedWeapon
var movement: PlayerMovement
var combat: PlayerCombat
# Last direction for idle state
var last_direction = Vector2.DOWN
@ -11,19 +14,16 @@ var last_direction = Vector2.DOWN
@onready var animated_sprite = $PlayerSprite
func _ready():
weapon = RangedWeapon.new()
Log.pr("Weapon", weapon)
weapon = $RangedWeapon
combat = PlayerCombat.new()
# Initialize the movement resource with references
if movement:
movement.player = self
movement.animated_sprite = animated_sprite
movement.last_direction = Vector2.DOWN # Default direction
else:
# Create a new resource instance if none was assigned in the editor
movement = PlayerMovement.new()
movement.player = self
movement.animated_sprite = animated_sprite
movement = PlayerMovement.new()
movement.player = self
movement.animated_sprite = animated_sprite
movement.speed = speed
combat.player = self
combat.animated_sprite = animated_sprite
Log.pr("Adding projectile size additive modifier")
weapon.add_modifier(ProjectileSizeAdditive.new())
@ -37,11 +37,15 @@ func _ready():
# Size is now 1.5 * 1.5 = 2.25
# Add another additive size modifier (+0.7 or 70% increase)
Log.pr("Adding another projectile size additive modifier", 0.7)
Log.pr("Adding another projectile size additive modifier", 2)
var another_size_mod = ProjectileSizeAdditive.new()
another_size_mod.size_increase = 0.7
weapon.add_modifier(another_size_mod)
Log.pr(weapon.stats.get_stat("projectile_size"))
weapon.add_modifier(FireRateAdditive.new())
func _physics_process(delta):
movement.process(delta)
combat.process(delta)

View file

@ -0,0 +1,30 @@
extends Resource
class_name PlayerCombat
var player: CharacterBody2D
var animated_sprite: AnimatedSprite2D
func process(_delta):
# Get mouse position in global coordinates
var mouse_position = player.get_global_mouse_position()
# Get player position (assuming this script is attached to the player)
var player_position = player.global_position
# Calculate direction vector from player to mouse
var direction = mouse_position - player_position
# You can normalize this vector if you want a unit vector (length of 1)
# This is useful if you only care about direction, not distance
var normalized_direction = direction.normalized()
if Input.is_action_pressed("fire"):
player.weapon.fire(normalized_direction)
# Update animation
#update_animation()
func update_animation():
Log.pr(animated_sprite.animation)
if animated_sprite.animation != "throw":
Log.pr('Throwing animation!')
animated_sprite.play("throw")

View file

@ -0,0 +1 @@
uid://cx4ugb3hbh8t1

View file

@ -4,7 +4,7 @@ class_name PlayerMovement
var player: CharacterBody2D
var animated_sprite: AnimatedSprite2D
var speed: float = 300.0
var speed: float
var last_direction: Vector2 = Vector2.ZERO
func process(_delta):
@ -36,6 +36,9 @@ func process(_delta):
func update_animation(direction):
var anim_name = "idle" # Default animation
if animated_sprite.animation == "throw":
return # Don't change animation if throwing
if direction == Vector2.ZERO:
# Character is idle