Precompute gradients (FPS++)
This commit is contained in:
parent
a9cde181be
commit
915c9167eb
1 changed files with 8 additions and 2 deletions
10
demo1.cpp
10
demo1.cpp
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue