A game created for the Godot Wild Jam #21
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.1KB

  1. extends Node2D
  2. var _timer = 0.0
  3. var _level_running = true
  4. var _level_node = null
  5. func get_hours():
  6. return floor(_timer / 3600.0)
  7. func get_minutes():
  8. return floor(fmod((_timer / 60), 60.0))
  9. func get_seconds():
  10. return floor(fmod(_timer, 60.0))
  11. func load_level(src):
  12. _level_running = false
  13. get_node("Player").hide()
  14. var lvl = get_node("lvl")
  15. if _level_node != null:
  16. lvl.remove_child(_level_node)
  17. _level_node.call_deferred("free")
  18. _level_node = null
  19. var lvlres = load("res://Data/Scenes/Levels/" + src)
  20. if lvlres:
  21. _level_node = lvlres.instance()
  22. lvl.add_child(_level_node)
  23. reset()
  24. func reset():
  25. if _level_node:
  26. var p = get_node("Player")
  27. if _level_node.has_method("get_starting_position"):
  28. p.position = _level_node.get_starting_position()
  29. else:
  30. p.position = Vector2.ZERO
  31. p.reset()
  32. p.show()
  33. func _ready():
  34. set_physics_process(true)
  35. load_level("Level_TestSite.tscn")
  36. #var ps = get_node("Level_00/Player_Start")
  37. #get_node("Player").position = get_node("Level_TestSite").get_starting_position()
  38. #get_node("Player").show()
  39. func _physics_process(delta):
  40. if _level_running:
  41. _timer += delta