A stealth-based 2D platformer where you don't have to kill anyone unless you want to. https://www.semicolin.games
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.

58 lines
1.6 KiB

  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using System.Collections.Generic;
  4. namespace Jumpy {
  5. // TODO: add a WriteLine sort of functionality.
  6. static class Debug {
  7. struct DebugRect {
  8. public Rectangle rect;
  9. public Color color;
  10. public DebugRect(Rectangle rect, Color color) {
  11. this.rect = rect;
  12. this.color = color;
  13. }
  14. }
  15. public static bool Enabled;
  16. static List<DebugRect> rects = new List<DebugRect>();
  17. static Texture2D whiteTexture;
  18. public static void Initialize(GraphicsDevice graphics) {
  19. whiteTexture = new Texture2D(graphics, 1, 1);
  20. whiteTexture.SetData(new Color[] { Color.White });
  21. }
  22. public static void Clear() {
  23. rects.Clear();
  24. }
  25. public static void AddRect(Rectangle rect, Color color) {
  26. rects.Add(new DebugRect(rect, color));
  27. }
  28. public static void Draw(SpriteBatch spriteBatch) {
  29. if (!Enabled) {
  30. return;
  31. }
  32. foreach (var debugRect in rects) {
  33. var rect = debugRect.rect;
  34. var color = debugRect.color;
  35. // top side
  36. spriteBatch.Draw(
  37. whiteTexture, new Rectangle(rect.Left, rect.Top, rect.Width, 1), color);
  38. // bottom side
  39. spriteBatch.Draw(
  40. whiteTexture, new Rectangle(rect.Left, rect.Bottom - 1, rect.Width, 1), color);
  41. // left side
  42. spriteBatch.Draw(
  43. whiteTexture, new Rectangle(rect.Left, rect.Top, 1, rect.Height), color);
  44. // right side
  45. spriteBatch.Draw(
  46. whiteTexture, new Rectangle(rect.Right - 1, rect.Top, 1, rect.Height), color);
  47. }
  48. }
  49. }
  50. }