36 lines
611 B
GDScript
36 lines
611 B
GDScript
extends Area2D
|
|
|
|
var innocent = false
|
|
@onready var timer = $Timer
|
|
@onready var animated_sprite_2d = $AnimatedSprite2D
|
|
@onready var collision_shape_2d = $CollisionShape2D
|
|
|
|
var mover = 25
|
|
var up = false
|
|
|
|
func _on_body_entered(body):
|
|
if not innocent:
|
|
body.shrink()
|
|
innocent = true
|
|
timer.start()
|
|
|
|
func _process(delta):
|
|
if mover < 25:
|
|
collision_shape_2d.position.y += -1 if up else 1
|
|
animated_sprite_2d.position.y += -1 if up else 1
|
|
mover += 1
|
|
|
|
func _on_timer_timeout():
|
|
innocent = false
|
|
|
|
func move_up():
|
|
mover = 0
|
|
up = true
|
|
|
|
func move_down():
|
|
mover = 0
|
|
up = false
|
|
|
|
func f_die():
|
|
queue_free()
|