the-third-place/scenes/bullet.gd
Henry 4f0eff986f On the advice of Sophie, I adjusted the shader settings on the resource
to be local to the scene so not all CRTs flashed when one got hit.
2026-03-01 12:21:40 +00:00

56 lines
1.4 KiB
GDScript

extends Area2D
@onready var bullet = $Bullet/Sprite2D
@export var speed = -250
var shader_active = false
var pause = false
func start(pos):
position = pos
func _process(delta):
if pause == true: return
position.y += speed * delta
# Signal checks to see if the bullet leaves the viewport then removes bullet.
func _on_visible_on_screen_notifier_2d_screen_exited() -> void:
queue_free()
func _on_area_entered(area: Area2D) -> void:
if area.is_in_group("enemies"):
match area.enemy_type:
"crt":
if area.is_in_group("enemies"):
print("CRT hit!")
area.hit_detection()
queue_free()
"shards":
if area.is_in_group("shards"):
print("Shards hit!")
area.hit_detection()
"mirror":
if area.is_in_group("enemies"):
print("Mirror hit!")
area.hit_detection()
queue_free()
"chicken":
if area.is_in_group("enemies"):
print("Chicken hit!")
area.hit_detection()
queue_free()
#func bullet_fx():
#shader_active = true
#bullet.material.set_shader_parameter("toggle", 1.0)
#pause = true
#await get_tree().create_timer(1).timeout
#pause = false
#shader_active = false
#bullet.material.set_shader_parameter("toggle", 0.0)