system.gd 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. extends Node
  2. enum PhysicsEngine {
  3. GODOT_PHYSICS,
  4. OTHER,
  5. }
  6. var _engine: PhysicsEngine = PhysicsEngine.OTHER
  7. func _enter_tree() -> void:
  8. process_mode = Node.PROCESS_MODE_ALWAYS
  9. # Always enable visible collision shapes on startup
  10. # (same as the Debug > Visible Collision Shapes option).
  11. get_tree().debug_collisions_hint = true
  12. var engine_string:= String(ProjectSettings.get_setting("physics/2d/physics_engine"))
  13. match engine_string:
  14. "DEFAULT":
  15. _engine = PhysicsEngine.GODOT_PHYSICS
  16. "GodotPhysics2D":
  17. _engine = PhysicsEngine.GODOT_PHYSICS
  18. _:
  19. _engine = PhysicsEngine.OTHER
  20. func _process(_delta: float) -> void:
  21. if Input.is_action_just_pressed(&"toggle_full_screen"):
  22. if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
  23. DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
  24. else:
  25. DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
  26. if Input.is_action_just_pressed(&"toggle_debug_collision"):
  27. var debug_collision_enabled := not _is_debug_collision_enabled()
  28. _set_debug_collision_enabled(debug_collision_enabled)
  29. if debug_collision_enabled:
  30. Log.print_log("Debug Collision ON")
  31. else:
  32. Log.print_log("Debug Collision OFF")
  33. if Input.is_action_just_pressed(&"toggle_pause"):
  34. get_tree().paused = not get_tree().paused
  35. if Input.is_action_just_pressed(&"exit"):
  36. get_tree().quit()
  37. func get_physics_engine() -> PhysicsEngine:
  38. return _engine
  39. func _set_debug_collision_enabled(enabled: bool) -> void:
  40. get_tree().debug_collisions_hint = enabled
  41. func _is_debug_collision_enabled() -> bool:
  42. return get_tree().debug_collisions_hint