37 lines
740 B
GDScript
37 lines
740 B
GDScript
extends Node2D
|
|
var position_y
|
|
var position_x
|
|
|
|
var richtung = 1
|
|
@export var speed = 500
|
|
|
|
func _ready() -> void:
|
|
position_x = position.x
|
|
position_y = position.y
|
|
|
|
func _on_area_2d_2_area_entered(area: Area2D) -> void:
|
|
if area.is_in_group("spieler"):
|
|
die()
|
|
|
|
func _process(delta: float) -> void:
|
|
position.x += speed*delta
|
|
if Globel.leben == false:
|
|
position.y = position_y
|
|
position.x = position_x
|
|
visible=true
|
|
$Area2D.add_to_group("Gegner")
|
|
$Area2D2.add_to_group("tötung")
|
|
|
|
func die():
|
|
visible = false
|
|
#$Icon.scale.y = 0.5
|
|
$Area2D.remove_from_group("Gegner")
|
|
$Area2D2.remove_from_group("tötung")
|
|
|
|
func umkerung():
|
|
speed = -speed
|
|
|
|
func _on_area_2d_body_entered(body: Node2D) -> void:
|
|
umkerung()
|
|
print(body.name)
|