Precompute gradients (FPS++)

This commit is contained in:
Miloslav Číž 2018-09-24 18:58:16 +02:00
parent a9cde181be
commit 915c9167eb

View file

@ -38,6 +38,9 @@ Player player;
Sprite sprites[SPRITES];
unsigned char floorGradient[15];
unsigned char ceilGradient[15];
/// For each level square says the texture index.
const unsigned char levelTexture[] =
{
@ -1023,8 +1026,8 @@ inline void pixelFunc(RCL_PixelInfo *pixel)
}
else
color = pixel->isFloor ?
rgbToIndex(intensity/2,intensity,intensity/3) :
rgbToIndex(intensity,intensity/2,0);
floorGradient[RCL_clamp(intensity,0,14)] :
ceilGradient[RCL_clamp(intensity,0,14)];
putSubsampledPixel(pixel->position.x,pixel->position.y,color);
}
@ -1094,6 +1097,9 @@ int main()
{
initGeneral();
initGradient(floorGradient,rgbToIndex(3,7,0));
initGradient(ceilGradient,rgbToIndex(6,2,1));
defaultConstraints.maxHits = 8;
defaultConstraints.maxSteps = 10;