diff options
Diffstat (limited to 'Asteroid.gd')
-rw-r--r-- | Asteroid.gd | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/Asteroid.gd b/Asteroid.gd new file mode 100644 index 0000000..8b93b24 --- /dev/null +++ b/Asteroid.gd @@ -0,0 +1,71 @@ +extends RigidBody2D + +@export var killer : bool +@export var posessed : bool +@export var persistent_linear_velocity : Vector2 +@export var particle_chad : PackedScene +@export var particle_virgin : PackedScene + +# 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): + pass + #look_at(get_tree().get_root().get_node("Prototype/Player").position) + +func _physics_process(delta): + #global_position += linear_velocity + if persistent_linear_velocity != Vector2.ZERO: + linear_velocity = persistent_linear_velocity + pass + +func _on_area_entered(area): + if killer: + area.queue_free() + +func start_timebomb(): + $"LifeTimer".start() + +func _on_life_timer_timeout(): + queue_free() + +func _on_body_entered(body): + print(body.name) + if killer: + if body.name != "Player": + print("kill") + body.destroy(true) + else: + if !("killer" in body): + if posessed: + if body.name != "Player": + body.destroy() + else: + body.destroy() + elif body.killer: + return + else: + body.destroy() + +#func _on_area_2d_area_entered(area): +# pass # Replace with function body. + +#func _on_area_2d_body_entered(body): +# if killer: +# body.queue_free() + +func destroy(player_killed = false): + var part + + if player_killed: + part = particle_chad + else: + part = particle_virgin + + var new = part.instantiate() + new.position = global_position + new.emitting = true + get_tree().get_root().get_node("Prototype").add_child(new) + queue_free() |