Give different heights diff colors
This commit is contained in:
parent
175ea1ef85
commit
6700b64387
3 changed files with 29 additions and 11 deletions
16
demo1.cpp
16
demo1.cpp
|
@ -15,6 +15,8 @@
|
|||
|
||||
#define SUBSAMPLE 1
|
||||
|
||||
#define RCL_COMPUTE_FLOOR_TEXCOORDS 1
|
||||
|
||||
// redefine some parameters
|
||||
#define FPS 255
|
||||
#define GRAVITY_ACCELERATION (RCL_UNITS_PER_SQUARE * 3)
|
||||
|
@ -56,7 +58,7 @@ const unsigned char levelTexture[] =
|
|||
1, 1, 1, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, // 9 11
|
||||
1, 1, 1, 1, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, // 10 10
|
||||
1, 1, 1, 1, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, // 11 9
|
||||
1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, // 12 8
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, // 12 8
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, // 13 7
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, // 14 6
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, // 15 5
|
||||
|
@ -96,6 +98,8 @@ const signed char levelFloor[] =
|
|||
0,24,24,24,32,32,32,27,24,27,30,34,36,38,36,34,36,34,34,32,32,33,37,39,24,24,24,24,24 // 20 0
|
||||
};
|
||||
|
||||
const unsigned char heightLevelColors[8] = {HUE(10),HUE(0) - 3,HUE(4),HUE(1)};
|
||||
|
||||
#undef XX
|
||||
|
||||
#define XX 127 // helper to keep a big number two-characters, for formatting
|
||||
|
@ -975,9 +979,9 @@ RCL_Unit floorHeightAt(int16_t x, int16_t y)
|
|||
{
|
||||
if (x == 6 && (y == 13 || y == 14)) // moving lift
|
||||
return
|
||||
((RCL_absVal(-1 * (pokitto.frameCount % 64) + 32)) * RCL_UNITS_PER_SQUARE) / 8;
|
||||
((RCL_absVal(-1 * (pokitto.frameCount % 64) + 32)) * (RCL_UNITS_PER_SQUARE / 8));
|
||||
|
||||
withinMapReturn((levelFloor[index] * RCL_UNITS_PER_SQUARE) / 8,0)
|
||||
withinMapReturn(levelFloor[index] * (RCL_UNITS_PER_SQUARE / 8),0)
|
||||
}
|
||||
|
||||
RCL_Unit ceilingHeightAt(int16_t x, int16_t y)
|
||||
|
@ -1024,8 +1028,10 @@ int16_t intensity;
|
|||
else
|
||||
{
|
||||
color = pixel->isFloor ?
|
||||
addIntensity(40,intensity):
|
||||
addIntensity(18,intensity);
|
||||
heightLevelColors[(pixel->height / RCL_UNITS_PER_SQUARE) & 0b00000011] :
|
||||
18;
|
||||
|
||||
color = addIntensity(color,intensity);
|
||||
}
|
||||
|
||||
putSubsampledPixel(pixel->position.x,pixel->position.y,color);
|
||||
|
|
22
demo3.cpp
22
demo3.cpp
|
@ -38,7 +38,6 @@ Player player;
|
|||
|
||||
#define JUMP_SPEED 500
|
||||
|
||||
char floorColor = 0;
|
||||
RCL_Vector2D selectedSquare; ///< Coords of a square selected for editing.
|
||||
|
||||
/**
|
||||
|
@ -63,7 +62,9 @@ uint16_t changeIndex = 0;
|
|||
int16_t editCounter = 0;
|
||||
|
||||
#define SQUARE_COLORS 4
|
||||
#define FLOOR_COLORS 8
|
||||
uint8_t squareColors[SQUARE_COLORS];
|
||||
uint8_t floorColors[FLOOR_COLORS];
|
||||
|
||||
#define HEIGHT_PROFILE_LENGTH 256
|
||||
|
||||
|
@ -480,11 +481,13 @@ inline void pixelFunc(RCL_PixelInfo *pixel)
|
|||
}
|
||||
else if (pixel->isFloor)
|
||||
{
|
||||
|
||||
if (!pixel->isHorizon)
|
||||
{
|
||||
intensity = pixel->depth / RCL_UNITS_PER_SQUARE;
|
||||
|
||||
color = addIntensity(floorColor,intensity);
|
||||
color = addIntensity(floorColors[(pixel->height / RCL_UNITS_PER_SQUARE) % FLOOR_COLORS],intensity);
|
||||
}
|
||||
else
|
||||
color = floorColors[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -555,13 +558,20 @@ int main()
|
|||
defaultConstraints.maxHits = 6;
|
||||
defaultConstraints.maxSteps = 20;
|
||||
|
||||
floorColor = 166;
|
||||
|
||||
squareColors[0] = 179;
|
||||
squareColors[1] = 147;
|
||||
squareColors[2] = 130;
|
||||
squareColors[3] = 210;
|
||||
|
||||
floorColors[0] = HUE(2);
|
||||
floorColors[1] = HUE(3);
|
||||
floorColors[2] = HUE(10);
|
||||
floorColors[3] = HUE(11);
|
||||
floorColors[4] = HUE(1);
|
||||
floorColors[5] = HUE(5);
|
||||
floorColors[6] = HUE(6);
|
||||
floorColors[7] = HUE(14);
|
||||
|
||||
player.setPositionSquare(4,5);
|
||||
player.mCamera.height = floorHeightAt(4,5);
|
||||
|
||||
|
|
|
@ -70,6 +70,8 @@ Pokitto::Core pokitto;
|
|||
|
||||
#define TRANSPARENT_COLOR 0x8f /// Transparent color for sprites and GUI.
|
||||
|
||||
#define HUE(c) (c * 16 + 8) /// Gives a middle color of given hue (0 to 15).
|
||||
|
||||
RCL_Unit zBuffer[SUBSAMPLED_WIDTH]; ///< 1D z-buffer for visibility determination.
|
||||
|
||||
RCL_RayConstraints defaultConstraints;
|
||||
|
|
Loading…
Reference in a new issue