As many have already pointed out, Bresenham's line algorithm specifically avoids using floats. I'm no Java expert, but I believe floats are quite slow in Java.

I've commented things in your code that could be improved.

public static boolean solidSpace (int x0, int y0, int x1, int y1)
{
float dx = Math.abs(x1-x0); // why make these floats? The two input arguments are integers, so the result can be an integer too
float dy = Math.abs(y1-y0); // <-----
int sx = (x0 < x1) ? 1 : -1;
int sy = (y0 < y1) ? 1 : -1;
float err = dx-dy; // dx and dy should be integers, so err can also be an integer
byte[][] b = Stage.STAGE.stageData; // This could be expensive, copying a two dimensional array from one place to another. Consider using the original array directly
while (true)
{
if (b[y0][x0] == SOLID)
return false;
if (x0 == x1 && y0 == y1)
return true;
float e2 = 2*err;
if (e2 > -dy)
{
err -= dy;
x0 += sx;
}
if (e2 < dx)
{
err += dx;
y0 += sy;
}
}
}

And here's how I'd write it.

public static boolean solidSpace (int x0, int y0, int x1, int y1)
{
int dx = Math.abs(x1-x0);
int dy = Math.abs(y1-y0);
int sx = (x0 < x1) ? 1 : -1;
int sy = (y0 < y1) ? 1 : -1;
int err = dx-dy;
while (true)
{
if (Stage.STAGE.stageData[y0][x0] == SOLID)
return false;
if (x0 == x1 && y0 == y1)
return true;
float e2 = 2*err;
if (e2 > -dy)
{
err -= dy;
x0 += sx;
}
if (e2 < dx)
{
err += dx;
y0 += sy;
}
}
}

How large is your array (stage_width and stage_height), and how many line checks are you performing every game loop? I have a feeling there may be some inefficiency in the way you're using the method as well.

**Edited by TheComet, 07 November 2013 - 04:09 AM.**

"Windows 10 doesn't only include spyware, it is *designed* as spyware" -- Gaius Publius, The Big Picture RT Interview

"[...] we will access, disclose and preserve personal data, including your content (such as the content of your emails, other **private communications **or files in **private folders**), when we have a good faith belief that doing so is necessary" -- Windows 10 Privacy Statement