A Smoll game engine
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

58 righe
2.1 KiB

  1. using System.Collections.Specialized;
  2. using System.Numerics;
  3. using Raylib_cs;
  4. namespace Smoll.Ex1 {
  5. class CrosshairGizmoComponent : Smoll.Component {
  6. Transform2DComponent? ownerTransform;
  7. public CrosshairGizmoComponent()
  8. {}
  9. public override void OnAttached() {
  10. ownerTransform = owner.GetComponent<Transform2DComponent>();
  11. }
  12. public override void Draw(Smoll.Layer.DrawMode drawMode) {
  13. if(drawMode == Layer.DrawMode.Debug) {
  14. ownerTransform ??= owner.GetComponent<Transform2DComponent>();
  15. ownerTransform ??= new Transform2DComponent();
  16. var tr = ownerTransform.AbsoluteTransform();
  17. Raylib.DrawCircleLines((int)tr.position.Real, (int)tr.position.Imaginary, 5.5f, Color.Black);
  18. Raylib.DrawLine(
  19. (int)tr.position.Real,
  20. (int)tr.position.Imaginary-10,
  21. (int)tr.position.Real,
  22. (int)tr.position.Imaginary+10,
  23. Color.Lime);
  24. Raylib.DrawLine(
  25. (int)tr.position.Real-10,
  26. (int)tr.position.Imaginary,
  27. (int)tr.position.Real+10,
  28. (int)tr.position.Imaginary,
  29. Color.Red);
  30. Raylib.DrawText(
  31. tr.angle.ToString(),
  32. (int)tr.position.Real+7,
  33. (int)tr.position.Imaginary+7,
  34. 14,
  35. Color.Magenta
  36. );
  37. Raylib.DrawText(
  38. tr.position.Real.ToString(),
  39. (int)tr.position.Real+7,
  40. (int)tr.position.Imaginary+23,
  41. 14,
  42. Color.Red
  43. );
  44. Raylib.DrawText(
  45. tr.position.Imaginary.ToString(),
  46. (int)tr.position.Real+7,
  47. (int)tr.position.Imaginary+39,
  48. 14,
  49. Color.Lime
  50. );
  51. }
  52. }
  53. }
  54. }