This commit is contained in:
Miloslav Číž 2018-09-01 12:04:17 +02:00
parent b3176f613d
commit 56431d0f57

View file

@ -18,6 +18,9 @@ public:
if (x > 12 || y > 12)
return max(x,y) - 10;
if (x < 5 && x > 2 && y < 5 && y > 2)
return 1;
return (x < 0 || y < 0 || x > 9 || y > 9) ? 1 : 0;
}
};
@ -34,7 +37,7 @@ public:
mCamera.direction = 660;
mCamera.fovAngle = UNITS_PER_SQUARE / 4;
mCamera.height = 0;
mCamera.resolution.x = 55;
mCamera.resolution.x = 36;
mCamera.resolution.y = 88;
}
};
@ -48,11 +51,39 @@ Unit heightFunc(int16_t x, int16_t y)
return level.getHeight(x,y) * UNITS_PER_SQUARE;
}
bool dither(uint8_t intensity, uint32_t x, uint32_t y)
{
switch (intensity)
{
case 0: return false; break;
case 1: return x % 2 == 0 && y % 2 == 0; break;
case 2: return x % 2 == y % 2; break;
case 3: return x % 2 != 0 || y % 2 != 0; break;
default: return true; break;
}
}
void pixelFunc(PixelInfo pixel)
{
p.display.color = pixel.isWall ? pixel.hit.direction + 4 : 3;
p.display.drawPixel(pixel.position.x * 2,pixel.position.y);
p.display.drawPixel(pixel.position.x * 2 + 1,pixel.position.y);
uint8_t c = pixel.isWall ? pixel.hit.direction + 4 : 3;
uint16_t x = pixel.position.x * 3;
uint16_t y = pixel.position.y;
uint8_t d = pixel.depth / (UNITS_PER_SQUARE * 2);
p.display.color = dither(d,x,y) ? 0 : c;
p.display.drawPixel(x,pixel.position.y);
x++;
p.display.color = dither(d,x,y) ? 0 : c;
p.display.drawPixel(x,pixel.position.y);
x++;
p.display.color = dither(d,x,y) ? 0 : c;
p.display.drawPixel(x,pixel.position.y);
}
void draw()
@ -60,7 +91,7 @@ void draw()
RayConstraints c;
c.maxHits = 3;
c.maxSteps = 32;
c.maxSteps = 10;
render(player.mCamera,heightFunc,pixelFunc,c);
}
@ -68,7 +99,7 @@ void draw()
int main()
{
p.begin();
p.setFrameRate(60);
p.setFrameRate(30);
p.display.setFont(fontTiny);