24 lines
472 B
GDScript
24 lines
472 B
GDScript
extends Node2D
|
|
|
|
var speed = 100
|
|
var base_speed = 10
|
|
var direction = 0
|
|
|
|
var damage
|
|
var hostile = false
|
|
|
|
@onready var polygon = $Polygon2D
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
position += speed*delta*base_speed*direction
|
|
|
|
if position.x < 0 or position.x > 256 or position.y < 0 or position.y > 256:
|
|
queue_free()
|
|
|
|
|
|
func _on_body_entered(body: Node2D) -> void:
|
|
if body.is_in_group("damageable"):
|
|
damage = body.damage(damage)
|
|
if damage <= 0:
|
|
queue_free()
|