Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. AREA 2D {MAP} Scene
  2. extends Node2D
  3. export (float) var spawntime
  4. export (float) var start
  5. export (PackedScene) var e1
  6. export (PackedScene) var e2
  7. var score = 1
  8.  
  9. # Called when the node enters the scene tree for the first time.
  10. func _ready():
  11. randomize()
  12. $Spawner.wait_time = spawntime
  13. $Start.wait_time = start
  14. $Start.start()
  15.  
  16. func game_over():
  17. $Score.stop()
  18. $Spawner.stop()
  19. pass
  20.  
  21. func _on_Tank_shoot(bullet, _position, _direction):
  22. var b = bullet.instance()
  23. add_child(b)
  24. b.start(_position, _direction)
  25.  
  26.  
  27. func _on_Start_timeout():
  28. $Spawner.start()
  29. $Score.start()
  30.  
  31.  
  32. func _on_Score_timeout():
  33. score = score + 1
  34.  
  35.  
  36. func _on_Spawner_timeout():
  37. var enemy
  38. var check
  39. randomize()
  40. check = rand_range(0, 1)
  41. if check >= 0.5:
  42. check = ceil(check)
  43. else:
  44. check = floor(check)
  45. if check == 0:
  46. enemy = e1.instance()
  47. add_child(enemy)
  48. else:
  49. enemy = e2.instance()
  50. add_child(enemy)
  51. #get_parent().get_node("Enemy2").connect("shoot", self, "_on_Tank_shoot") my attempt at connecting the signals
  52. enemy.position = Vector2(100, 100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement