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.
30 lines
934 B
GDScript
30 lines
934 B
GDScript
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")
|