How do I program 8-directional shooting?

I am currently working on a run-and-gun platformer game sort of like Contra, and I am very new to Godot, I have basic player movement and jumping down and I am currently working on the shooting mechanic, I have been following a tutorial, which uses mouse aim, but I would like to use 8-directional firing with arrow keys instead of a mouse, The player can fire to the right but not any of the other directions.

Here is my current code for the player:

extends CharacterBody2D

@onready var _animated_sprite = $AnimatedSprite2D
const bulletpath = preload("res://scenes/Bullet.tscn")
var bullet_set = "right"



func _process(delta):
	if Input.is_action_just_pressed("Shoot"):
		shoot()

func shoot():
	var bullet = bulletpath.instantiate()
	
	get_parent().add_child(bullet)
	bullet.position = $Marker2D.global_position
	
	
const SPEED = 200.0
const JUMP_VELOCITY = -300.0

# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")


func _physics_process(delta):
	# Add the gravity.
	if not is_on_floor():
		velocity.y += gravity * delta

	# Handle jump.
	if Input.is_action_just_pressed("jump") and is_on_floor():
		velocity.y = JUMP_VELOCITY
		


	

	

	# Get the input direction and handle the movement/deceleration.
	# As good practice, you should replace UI actions with custom gameplay actions.
	
	#Handles runing and idle animations and fliping the character sprite horizontally depending on direction
	var direction = Input.get_axis("move_left", "move_right")
	
	if direction > 0:
		_animated_sprite.flip_h = false
	
	elif direction < 0:
		_animated_sprite.flip_h = true
	
	if direction == 0:
		_animated_sprite.play("idle")
	else:
		_animated_sprite.play("run")
	
	
	if direction:
		velocity.x = direction * SPEED
	else:
		velocity.x = move_toward(velocity.x, 0, SPEED)
	


	
	
	move_and_slide()

Here is the current code for the player bullet:

extends Area2D

var dir = 1

func _ready():
	apply_scale(Vector2(.4, .2))
	
func set_dir(direction):
	dir = direction
	

func _process(delta):
	position.x += 20 * dir
	


Here is the link to the tutorial I have been following for the shooting:

This Project uses Godot 4.2.2, I have been following a tutorial that uses Godot 3.

I am also curious on how I would go about coding in animations for shooting and shooting while running as well, if possible. Thank you!

maybe I am not understanding correctly but… you are just not using the set_dir function from the bullet scene, so the bullet direction remains as 1 always