Diminish sprites

This commit is contained in:
Miloslav Číž 2018-09-27 14:52:31 +02:00
parent d15aa7f60b
commit 6322904d6d
3 changed files with 10 additions and 7 deletions

View file

@ -988,6 +988,11 @@ RCL_Unit ceilingHeightAt(int16_t x, int16_t y)
#undef withinMapReturn
inline int16_t distanceToIntensity(RCL_Unit distance)
{
return 8 - distance / (RCL_UNITS_PER_SQUARE / 2);
}
/**
Function for drawing a single pixel (like fragment shader). Bottleneck =>
should be as fast as possible.
@ -1001,7 +1006,7 @@ int16_t intensity;
uint8_t color;
intensity = 8 - pixel->depth / (RCL_UNITS_PER_SQUARE / 2);
intensity = distanceToIntensity(pixel->depth);
if (pixel->isWall)
{
@ -1018,8 +1023,6 @@ int16_t intensity;
}
else
{
intensity = 8 - pixel->depth / (RCL_UNITS_PER_SQUARE / 2);
color = pixel->isFloor ?
addIntensity(40,intensity):
addIntensity(18,intensity);
@ -1057,7 +1060,7 @@ void draw()
drawSpriteSquare(image,pos.position.x * SUBSAMPLE,
pos.position.y, pos.depth,
RCL_perspectiveScale(sprites[i].mPixelSize,pos.depth));
RCL_perspectiveScale(sprites[i].mPixelSize,pos.depth),distanceToIntensity(pos.depth));
}
/* trick: sort the sprites by distance with bubble sort as we draw - the

View file

@ -1035,7 +1035,7 @@ void draw()
drawSpriteSquare(spritePlasma,pos.position.x * SUBSAMPLE,
pos.position.y,pos.depth,
RCL_perspectiveScale(64,pos.depth));
RCL_perspectiveScale(64,pos.depth),1);
}
drawImage(imageBar,0,INFO_BAR_START - 3);

View file

@ -236,7 +236,7 @@ inline uint8_t sampleImage(const unsigned char *image, RCL_Unit x, RCL_Unit y)
Draws a scaled sprite on screen in an optimized way. The sprite has to be
square in resolution.
*/
void inline drawSpriteSquare(const unsigned char *sprite, int16_t x, int16_t y, RCL_Unit depth, int16_t size)
void inline drawSpriteSquare(const unsigned char *sprite, int16_t x, int16_t y, RCL_Unit depth, int16_t size, int16_t intensity)
{
if (size < 0 || size > 200 || // let's not mess up with the incoming array
sprite[0] != sprite[1]) // only draw square sprites
@ -271,7 +271,7 @@ void inline drawSpriteSquare(const unsigned char *sprite, int16_t x, int16_t y,
c = sprite[columnLocation + samplingIndices[j]];
if (c != TRANSPARENT_COLOR)
pokitto.display.drawPixel(xPos,y + j,c);
pokitto.display.drawPixel(xPos,y + j,addIntensity(c,intensity));
}
}
}