31 lines
779 B
GDScript
31 lines
779 B
GDScript
extends Area2D
|
|
|
|
@export var speed : float = 80.0
|
|
@export var damage : int = 1
|
|
@export var audio_pool = []
|
|
|
|
@export_flags_2d_physics var map_collision_layer : int
|
|
@export_flags_2d_physics var bunny_collision_layer : int
|
|
|
|
var dir : float
|
|
|
|
func _process(delta):
|
|
self.translate(Vector2(cos(dir), sin(dir)) * speed * delta)
|
|
self.rotate(delta * 30)
|
|
pass
|
|
|
|
func _on_collision(body):
|
|
var collided_layer = null;
|
|
|
|
if body.get_class() == "TileMap":
|
|
collided_layer = body.tile_set.get_physics_layer_collision_layer(0)
|
|
if(body.has_method("get_collision_layer")):
|
|
collided_layer = body.get_collision_layer()
|
|
|
|
if collided_layer & map_collision_layer:
|
|
queue_free()
|
|
if collided_layer & bunny_collision_layer:
|
|
var bunny = body as Bunny
|
|
bunny.damage(damage)
|
|
queue_free()
|
|
pass
|