earth.gd 708 B

1234567891011121314151617181920212223242526272829
  1. extends Node2D
  2. onready var MAIN = find_parent("MAIN")
  3. # Declare member variables here. Examples:
  4. # var a: int = 2
  5. # var b: String = "text"
  6. func _process(delta: float) -> void:
  7. if MAIN.started:
  8. position.x += MAIN.speed * delta
  9. if position.x <= -100:
  10. if MAIN.delegation_hit:
  11. get_tree().change_scene("res://end3.tscn")
  12. else:
  13. get_tree().change_scene("res://end4.tscn")
  14. # Called when the node enters the scene tree for the first time.
  15. func _ready() -> void:
  16. $scaler/area.connect("body_entered",self,"on_hit")
  17. pass # Replace with function body.
  18. func on_hit(_body):
  19. if MAIN.delegation_hit:
  20. get_tree().change_scene("res://end1.tscn")
  21. else:
  22. get_tree().change_scene("res://end2.tscn")