25 lines
		
	
	
		
			593 B
		
	
	
	
		
			GDScript
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			593 B
		
	
	
	
		
			GDScript
		
	
	
	
	
	
class_name Bullet extends Area2D
 | 
						|
 | 
						|
var speed:float = 700
 | 
						|
@onready var bullet_graphic = $BulletGraphic
 | 
						|
signal bulletDamageSignal(area, bullet)
 | 
						|
# Called when the node enters the scene tree for the first time.
 | 
						|
func _ready():
 | 
						|
	pass # Replace with function body.
 | 
						|
 | 
						|
 | 
						|
# Called every frame. 'delta' is the elapsed time since the previous frame.
 | 
						|
func _process(delta):
 | 
						|
	position += transform.x * speed * delta
 | 
						|
 | 
						|
func setSpeed(value)->void:
 | 
						|
	speed = value
 | 
						|
	if speed<0:
 | 
						|
		bullet_graphic.flip_h = true
 | 
						|
	else:
 | 
						|
		bullet_graphic.flip_h = false
 | 
						|
 | 
						|
 | 
						|
func _on_area_entered(area):
 | 
						|
	bulletDamageSignal.emit(area, self)
 |