extends Sprite2D

signal bomb_sliced(bomb: Node2D)

# Bomb textures
var bomb_texture = preload("res://assets/images/bomb_small.png")
var explosion_texture = preload("res://assets/images/explosion_small.png")

# Bomb sounds
var fuse_sound = preload("res://assets/sounds/bomb-fuse.wav")
var explode_sound = preload("res://assets/sounds/bomb-explode.wav")

# Movement properties
var velocity = Vector2.ZERO
var gravity = 800.0
var rotation_speed = 0.0
var is_sliced = false

func _ready():
	# Add to BOMB group
	add_to_group("BOMB")
	
	# Set initial texture
	texture = bomb_texture
	
	# Add random rotation
	rotation = randf_range(-PI/4, PI/4)
	rotation_speed = randf_range(-2, 2)
	
	# Set initial velocity (random x, upward y)
	velocity = Vector2(randf_range(-100, 100), -400)

func _process(delta):
	if not is_sliced:
		# Update position based on velocity
		position += velocity * delta
		
		# Apply gravity to velocity
		velocity.y += gravity * delta
		
		# Update rotation
		rotation += rotation_speed * delta
		
		# Remove if off screen
		if position.y > 800:
			queue_free()

func play_fuse_sound():
	# TODO: Create AudioStreamPlayer dynamically and play fuse sound (Lecture 14)
	pass

func slice(slash_pos: Vector2):
	# TODO: Implement bomb slicing (Lecture 14)
	pass

func detonate():
	# TODO: Swap texture to explosion, play explosion sound (Lecture 14)
	pass

func play_explosion_sound():
	# TODO: Create AudioStreamPlayer dynamically and play explosion sound (Lecture 14)
	pass
