Compare commits

..

No commits in common. "63a2645814a57391a68fd959e3f677bd55b5bbcc" and "fb3538cea90b8abd10fbb152cbc995ebded97dcc" have entirely different histories.

5 changed files with 14 additions and 20 deletions

View File

@ -1,7 +1,6 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
namespace SemiColinGames { namespace SemiColinGames {
public static class Debug { public static class Debug {
@ -38,7 +37,7 @@ namespace SemiColinGames {
static VertexPositionColor[] lineVertices; static VertexPositionColor[] lineVertices;
static VertexBuffer vertexBuffer; static VertexBuffer vertexBuffer;
[Conditional("DEBUG")] [System.Diagnostics.Conditional("DEBUG")]
public static void Initialize(GraphicsDevice graphics) { public static void Initialize(GraphicsDevice graphics) {
lineVertices = new VertexPositionColor[MAX_LINE_VERTICES]; lineVertices = new VertexPositionColor[MAX_LINE_VERTICES];
vertexBuffer?.Dispose(); vertexBuffer?.Dispose();
@ -46,17 +45,17 @@ namespace SemiColinGames {
graphics, typeof(VertexPositionColor), MAX_LINE_VERTICES, BufferUsage.WriteOnly); graphics, typeof(VertexPositionColor), MAX_LINE_VERTICES, BufferUsage.WriteOnly);
} }
[Conditional("DEBUG")] [System.Diagnostics.Conditional("DEBUG")]
public static void WriteLine(string s) { public static void WriteLine(string s) {
System.Diagnostics.Debug.WriteLine(s); System.Diagnostics.Debug.WriteLine(s);
} }
[Conditional("DEBUG")] [System.Diagnostics.Conditional("DEBUG")]
public static void WriteLine(string s, params object[] args) { public static void WriteLine(string s, params object[] args) {
System.Diagnostics.Debug.WriteLine(s, args); System.Diagnostics.Debug.WriteLine(s, args);
} }
[Conditional("DEBUG")] [System.Diagnostics.Conditional("DEBUG")]
public static void Clear(bool paused) { public static void Clear(bool paused) {
toasts.Clear(); toasts.Clear();
if (!paused) { if (!paused) {
@ -64,18 +63,18 @@ namespace SemiColinGames {
} }
} }
[Conditional("DEBUG")] [System.Diagnostics.Conditional("DEBUG")]
public static void AddToast(string s) { public static void AddToast(string s) {
toasts.AddLast(s); toasts.AddLast(s);
} }
// FPS text is always displayed as the first toast (if set). // FPS text is always displayed as the first toast (if set).
[Conditional("DEBUG")] [System.Diagnostics.Conditional("DEBUG")]
public static void SetFpsText(string s) { public static void SetFpsText(string s) {
toasts.AddFirst(s); toasts.AddFirst(s);
} }
[Conditional("DEBUG")] [System.Diagnostics.Conditional("DEBUG")]
public static void AddRect(Rectangle rect, Color color) { public static void AddRect(Rectangle rect, Color color) {
AddLine(rect.Left, rect.Top + 1, rect.Right, rect.Top + 1, color); AddLine(rect.Left, rect.Top + 1, rect.Right, rect.Top + 1, color);
AddLine(rect.Left + 1, rect.Top + 1, rect.Left + 1, rect.Bottom, color); AddLine(rect.Left + 1, rect.Top + 1, rect.Left + 1, rect.Bottom, color);
@ -83,7 +82,7 @@ namespace SemiColinGames {
AddLine(rect.Left + 1, rect.Bottom, rect.Right, rect.Bottom, color); AddLine(rect.Left + 1, rect.Bottom, rect.Right, rect.Bottom, color);
} }
[Conditional("DEBUG")] [System.Diagnostics.Conditional("DEBUG")]
public static void AddRect(AABB box, Color color) { public static void AddRect(AABB box, Color color) {
Rectangle rect = new Rectangle( Rectangle rect = new Rectangle(
(int) (box.Position.X - box.HalfSize.X), (int) (box.Position.Y - box.HalfSize.Y), (int) (box.Position.X - box.HalfSize.X), (int) (box.Position.Y - box.HalfSize.Y),
@ -91,13 +90,13 @@ namespace SemiColinGames {
AddRect(rect, color); AddRect(rect, color);
} }
[Conditional("DEBUG")] [System.Diagnostics.Conditional("DEBUG")]
public static void AddPoint(Point p, Color color) { public static void AddPoint(Point p, Color color) {
AddLine(p.X, p.Y - 2, p.X, p.Y + 1, color); AddLine(p.X, p.Y - 2, p.X, p.Y + 1, color);
AddLine(p.X - 2, p.Y, p.X + 1, p.Y, color); AddLine(p.X - 2, p.Y, p.X + 1, p.Y, color);
} }
[Conditional("DEBUG")] [System.Diagnostics.Conditional("DEBUG")]
public static void AddLine(int p1x, int p1y, int p2x, int p2y, Color color) { public static void AddLine(int p1x, int p1y, int p2x, int p2y, Color color) {
if (lineIdx >= MAX_LINE_VERTICES) { if (lineIdx >= MAX_LINE_VERTICES) {
return; return;
@ -107,17 +106,17 @@ namespace SemiColinGames {
lineIdx += 2; lineIdx += 2;
} }
[Conditional("DEBUG")] [System.Diagnostics.Conditional("DEBUG")]
public static void AddLine(Point start, Point end, Color color) { public static void AddLine(Point start, Point end, Color color) {
AddLine(start.X, start.Y, end.X, end.Y, color); AddLine(start.X, start.Y, end.X, end.Y, color);
} }
[Conditional("DEBUG")] [System.Diagnostics.Conditional("DEBUG")]
public static void AddLine(Vector2 start, Vector2 end, Color color) { public static void AddLine(Vector2 start, Vector2 end, Color color) {
AddLine(start.ToPoint(), end.ToPoint(), color); AddLine(start.ToPoint(), end.ToPoint(), color);
} }
[Conditional("DEBUG")] [System.Diagnostics.Conditional("DEBUG")]
public static void DrawToasts(SpriteBatch spriteBatch) { public static void DrawToasts(SpriteBatch spriteBatch) {
if (!Enabled) { if (!Enabled) {
return; return;
@ -133,7 +132,7 @@ namespace SemiColinGames {
} }
} }
[Conditional("DEBUG")] [System.Diagnostics.Conditional("DEBUG")]
public static void Draw(GraphicsDevice graphics, BasicEffect lightingEffect) { public static void Draw(GraphicsDevice graphics, BasicEffect lightingEffect) {
if (!Enabled) { if (!Enabled) {
return; return;

View File

@ -51,7 +51,6 @@ namespace SemiColinGames {
} }
// This creates and populates a new array. It's O(n) and should probably only be used for tests. // This creates and populates a new array. It's O(n) and should probably only be used for tests.
// TODO: restrict visibility so that it can only be used by tests.
public T[] ToArray() { public T[] ToArray() {
T[] result = new T[items.Length]; T[] result = new T[items.Length];
for (int i = 0; i < items.Length; i++) { for (int i = 0; i < items.Length; i++) {

View File

@ -22,7 +22,6 @@ namespace SemiColinGames {
int errorXY; // Error value e_xy from the PDF. int errorXY; // Error value e_xy from the PDF.
// The size of the output is the size of the longer dimension, plus one. // The size of the output is the size of the longer dimension, plus one.
int resultSize = Math.Max(dx, -dy) + 1; int resultSize = Math.Max(dx, -dy) + 1;
// TODO: an array or list should be passed in by the caller.
var result = new Point[resultSize]; var result = new Point[resultSize];
int i = 0; int i = 0;

View File

@ -83,8 +83,6 @@ namespace SemiColinGames {
} }
bool harmedByCollision = false; bool harmedByCollision = false;
// TODO: pass in movePoints to Line.Rasterize instead of having that function allocate a
// new array.
Point[] movePoints = Line.Rasterize(0, 0, (int) movement.X, (int) movement.Y); Point[] movePoints = Line.Rasterize(0, 0, (int) movement.X, (int) movement.Y);
for (int i = 1; i < movePoints.Length; i++) { for (int i = 1; i < movePoints.Length; i++) {
int dx = movePoints[i].X - movePoints[i - 1].X; int dx = movePoints[i].X - movePoints[i - 1].X;

View File

@ -29,7 +29,6 @@ namespace SemiColinGames {
histogram[bucket]++; histogram[bucket]++;
} }
[Conditional("DEBUG")]
public void DumpStats() { public void DumpStats() {
Debug.WriteLine(name + ".DumpStats():"); Debug.WriteLine(name + ".DumpStats():");
for (int i = 0; i < histogram.Length; i++) { for (int i = 0; i < histogram.Length; i++) {