Demo3 FPS++
This commit is contained in:
parent
915c9167eb
commit
3533d9eeb4
1 changed files with 23 additions and 12 deletions
35
demo3.cpp
35
demo3.cpp
|
@ -10,12 +10,14 @@
|
|||
license: CC0 1.0
|
||||
*/
|
||||
|
||||
#define SUBSAMPLE 1
|
||||
|
||||
// redefine player's height
|
||||
#define PLAYER_SPEED (RCL_UNITS_PER_SQUARE * 6)
|
||||
#define RCL_HORIZONTAL_FOV ((3 * RCL_UNITS_PER_SQUARE) / 10)
|
||||
#define GRAVITY_ACCELERATION (RCL_UNITS_PER_SQUARE * 2)
|
||||
#define RCL_CAMERA_COLL_HEIGHT_BELOW ((3 * RCL_UNITS_PER_SQUARE) / 2)
|
||||
#define FPS 40
|
||||
#define FPS 255
|
||||
#define HEAD_BOB_HEIGHT 150
|
||||
#define HEAD_BOB_STEP 20
|
||||
|
||||
|
@ -63,6 +65,9 @@ int16_t editCounter = 0;
|
|||
#define SQUARE_COLORS 4
|
||||
uint8_t squareColors[SQUARE_COLORS];
|
||||
|
||||
unsigned char floorGradient[15];
|
||||
unsigned char wallGradients[SQUARE_COLORS][15];
|
||||
|
||||
#define HEIGHT_PROFILE_LENGTH 256
|
||||
|
||||
/// Used for terrain generation.
|
||||
|
@ -466,18 +471,22 @@ inline void pixelFunc(RCL_PixelInfo *pixel)
|
|||
|
||||
if (pixel->isWall)
|
||||
{
|
||||
color = pixel->hit.square.x != selectedSquare.x || pixel->hit.square.y != selectedSquare.y || (editing && pokitto.frameCount % 2) == 0 ?
|
||||
squareColors[pixel->hit.type] : 30;
|
||||
|
||||
intensity = pixel->depth / (RCL_UNITS_PER_SQUARE * 3);
|
||||
intensity += pixel->hit.direction % 2 == 0 ? 2 : 0;
|
||||
if (pixel->hit.square.x != selectedSquare.x || pixel->hit.square.y != selectedSquare.y || (editing && pokitto.frameCount % 2) == 0)
|
||||
{
|
||||
intensity = pixel->depth / (RCL_UNITS_PER_SQUARE * 3);
|
||||
intensity += pixel->hit.direction % 2 == 0 ? 2 : 0;
|
||||
|
||||
color = wallGradients[pixel->hit.type][RCL_clamp(7 + intensity,0,14)];
|
||||
}
|
||||
else
|
||||
color = 30;
|
||||
}
|
||||
else if (pixel->isFloor)
|
||||
{
|
||||
color = floorColor;
|
||||
|
||||
if (!pixel->isHorizon)
|
||||
intensity = pixel->depth / (RCL_UNITS_PER_SQUARE * 3);
|
||||
intensity = pixel->depth / (RCL_UNITS_PER_SQUARE * 4);
|
||||
|
||||
color = floorGradient[RCL_clamp(7 + intensity,0,14)];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -490,9 +499,6 @@ inline void pixelFunc(RCL_PixelInfo *pixel)
|
|||
color = imageBackground[2 + backgroundColumn * 44 + RCL_clamp(pixel->position.y - player.mCamera.shear,0,43)];
|
||||
}
|
||||
|
||||
if (intensity != 0)
|
||||
color = addIntensity(color,intensity);
|
||||
|
||||
putSubsampledPixel(pixel->position.x,pixel->position.y,color);
|
||||
}
|
||||
|
||||
|
@ -558,6 +564,11 @@ int main()
|
|||
squareColors[2] = rgbToIndex(0,7,0);
|
||||
squareColors[3] = rgbToIndex(4,4,0);
|
||||
|
||||
initGradient(floorGradient,floorColor);
|
||||
|
||||
for (uint8_t i = 0; i < SQUARE_COLORS; ++i)
|
||||
initGradient(wallGradients[i],squareColors[i]);
|
||||
|
||||
player.setPositionSquare(4,5);
|
||||
player.mCamera.height = floorHeightAt(4,5);
|
||||
|
||||
|
|
Loading…
Reference in a new issue