diff --git a/demo2.cpp b/demo2.cpp index 9fb6bac..62f67c4 100644 --- a/demo2.cpp +++ b/demo2.cpp @@ -19,7 +19,7 @@ Player player; #define SHOT_SPEED 5 * UNITS_PER_SQUARE #define INFO_BAR_START 70 -#define TEXTURE_DISTANCE (UNITS_PER_SQUARE * 6) +#define TEXTURE_MAX_DISTANCE (UNITS_PER_SQUARE * 6) const unsigned char level[] = { @@ -28,19 +28,19 @@ const unsigned char level[] = 4,0,0,4,0,0,4,0,0,4,0,0,2,4,0,4,4,0,0,0,0,0,0,2,0,0,0,0,0,0,0,2, // 0 0,0,0,0,0,0,0,0,0,0,0,0,3,4,0,0,0,0,1,3,2,4,0,4,0,0,0,0,0,0,0,0, // 1 0,0,0,0,0,0,0,0,0,0,0,0,2,4,0,0,0,0,1,0,0,0,0,3,0,0,0,0,0,0,0,0, // 2 - 0,0,4,0,0,0,0,0,0,0,0,0,2,4,4,0,3,1,1,0,2,1,2,3,0,0,1,0,1,0,0,2, // 3 + 0,0,5,0,0,0,0,0,0,0,0,0,2,4,4,0,3,1,1,0,2,1,2,3,0,0,1,0,1,0,0,2, // 3 0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,2, // 4 0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,2,3,0,2,2,0,0,0,0,0,0,0,0,0,2, // 5 4,0,3,1,3,1,0,2,2,2,3,2,2,2,0,0,3,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 6 - 0,0,2,0,0,0,0,0,0,4,0,0,0,0,0,0,0,2,0,0,0,0,1,2,0,3,4,0,0,0,0,0, // 7 - 0,0,1,0,0,0,0,0,0,4,0,0,0,0,0,0,0,2,0,0,0,0,4,0,0,0,1,0,0,2,0,0, // 8 + 0,0,2,0,0,0,0,0,0,5,0,0,0,0,0,0,0,5,0,0,0,0,1,2,0,5,5,0,0,0,0,0, // 7 + 0,0,1,0,0,0,0,0,0,5,0,0,0,0,0,0,0,2,0,0,0,0,4,0,0,0,5,0,0,2,0,0, // 8 0,0,2,0,0,0,0,0,0,2,3,2,4,0,0,0,2,2,4,1,4,0,4,4,4,3,2,0,0,4,2,2, // 9 0,0,4,4,4,0,0,0,0,0,0,0,0,0,0,3,3,4,0,0,0,0,0,1,0,0,0,0,0,0,0,4, // 10 2,0,0,0,3,0,0,0,0,0,0,0,0,0,3,3,2,4,0,0,0,0,0,1,0,0,4,0,0,3,0,1, // 11 - 1,3,1,0,4,4,4,2,2,1,2,0,2,2,3,0,0,1,4,0,0,0,3,3,3,2,2,0,0,0,0,2, // 12 + 1,3,1,0,4,4,4,2,2,1,2,0,2,2,3,0,0,1,4,0,0,0,3,3,3,5,2,0,0,0,0,2, // 12 0,0,0,0,0,0,0,0,0,4,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,1, // 13 - 0,0,0,3,0,3,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4, // 14 - 0,0,0,0,0,0,0,0,0,4,0,0,0,0,2,0,0,4,0,0,4,0,0,1,0,3,0,3,0,3,0,1 // 15 + 0,0,0,3,0,5,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4, // 14 + 0,0,0,0,0,0,0,0,0,4,0,0,0,0,2,0,0,5,0,0,4,0,0,1,0,3,0,3,0,3,0,1 // 15 }; const unsigned char texture1[] = @@ -391,6 +391,93 @@ const unsigned char texture4[] = ,0x09,0x09,0x59,0x09 }; +const unsigned char texture5[] = +{ 32, 36 // width, height + ,0x00,0x09,0x00,0x00,0x00,0x09,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09,0x00,0x09,0x00,0x00,0x00,0x09 + ,0x09,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0x12 + ,0x09,0x09,0x00,0x09,0x00,0x00,0x00,0x09,0x09,0x00,0x00,0x00,0x00,0x00 + ,0x00,0x00,0x00,0x03,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00 + ,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09,0x00,0x09,0x00,0x00 + ,0x00,0x09,0x09,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00 + ,0x00,0x07,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x09,0x09,0x09,0x09 + ,0x09,0x12,0x09,0x09,0x00,0x09,0x00,0x00,0x00,0x09,0x09,0x00,0x00,0x00 + ,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x00,0x03,0x07,0x00,0x00,0x00,0x00 + ,0x00,0x00,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09,0x00,0x09 + ,0x00,0x00,0x00,0x09,0x09,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x03 + ,0x07,0x07,0x07,0x03,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x09,0x09 + ,0x09,0x09,0x09,0x12,0x09,0x09,0x00,0x09,0x00,0x00,0x00,0x09,0x09,0x00 + ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09 + ,0x00,0x09,0x00,0x00,0x00,0x09,0x09,0x00,0x00,0x07,0x00,0x00,0x00,0x00 + ,0x00,0x03,0x07,0x07,0x07,0x03,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00 + ,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09,0x00,0x09,0x00,0x00,0x00,0x09 + ,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x00,0x03,0x07 + ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0x12 + ,0x09,0x09,0x00,0x09,0x00,0x00,0x00,0x09,0x09,0x00,0x00,0x07,0x00,0x00 + ,0x00,0x00,0x00,0x03,0x07,0x07,0x07,0x03,0x00,0x00,0x00,0x00,0x07,0x00 + ,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09,0x00,0x09,0x00,0x00 + ,0x00,0x09,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x09,0x09,0x09 + ,0x09,0x12,0x09,0x09,0x00,0x09,0x00,0x00,0x00,0x09,0x09,0x00,0x00,0x07 + ,0x00,0x00,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00 + ,0x07,0x00,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09,0x00,0x09 + ,0x00,0x00,0x00,0x09,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x03,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x09 + ,0x09,0x09,0x09,0x12,0x09,0x09,0x00,0x09,0x00,0x00,0x00,0x09,0x09,0x00 + ,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x00,0x07,0x03,0x00,0x00 + ,0x00,0x00,0x07,0x00,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09 + ,0x00,0x09,0x00,0x00,0x00,0x09,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x00,0x07,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09,0x00,0x09,0x00,0x00,0x00,0x09 + ,0x09,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0x12 + ,0x09,0x09,0x00,0x09,0x00,0x00,0x00,0x09,0x09,0x00,0x00,0x00,0x00,0x00 + ,0x00,0x07,0x00,0x07,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09,0x00,0x09,0x00,0x00 + ,0x00,0x09,0x09,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x09,0x09,0x09,0x09 + ,0x09,0x12,0x09,0x09,0x00,0x09,0x00,0x00,0x00,0x09,0x09,0x00,0x00,0x00 + ,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x00,0x00,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09,0x00,0x09 + ,0x00,0x00,0x00,0x09,0x09,0x00,0x00,0x07,0x00,0x00,0x00,0x07,0x07,0x07 + ,0x07,0x07,0x07,0x03,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x09,0x09 + ,0x09,0x09,0x09,0x12,0x09,0x09,0x00,0x09,0x00,0x00,0x00,0x09,0x09,0x00 + ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x03,0x07,0x00,0x00 + ,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09 + ,0x00,0x09,0x00,0x00,0x00,0x09,0x09,0x00,0x00,0x07,0x00,0x00,0x00,0x00 + ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00 + ,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09,0x00,0x09,0x00,0x00,0x00,0x09 + ,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00 + ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0x12 + ,0x09,0x09,0x00,0x09,0x00,0x00,0x00,0x09,0x09,0x00,0x00,0x07,0x00,0x00 + ,0x00,0x07,0x07,0x07,0x07,0x07,0x07,0x03,0x00,0x00,0x00,0x00,0x07,0x00 + ,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09,0x00,0x09,0x00,0x00 + ,0x00,0x09,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00 + ,0x03,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x09,0x09,0x09 + ,0x09,0x12,0x09,0x09,0x00,0x09,0x00,0x00,0x00,0x09,0x09,0x00,0x00,0x07 + ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x07,0x00,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09,0x00,0x09 + ,0x00,0x00,0x00,0x09,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03 + ,0x07,0x07,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x09 + ,0x09,0x09,0x09,0x12,0x09,0x09,0x00,0x09,0x00,0x00,0x00,0x09,0x09,0x00 + ,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x07,0x03,0x00,0x03,0x07,0x00,0x00 + ,0x00,0x00,0x07,0x00,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09 + ,0x00,0x09,0x00,0x00,0x00,0x09,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x00,0x03,0x07,0x07,0x07,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09,0x00,0x09,0x00,0x00,0x00,0x09 + ,0x09,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0x12 + ,0x09,0x09,0x00,0x09,0x00,0x00,0x00,0x09,0x09,0x00,0x00,0x00,0x00,0x00 + ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x00,0x00,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09,0x00,0x09,0x00,0x00 + ,0x00,0x09,0x09,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + ,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x09,0x09,0x09,0x09 + ,0x09,0x12,0x09,0x09 +}; + const unsigned char spritePlasma[] = { 32, 32 // width, height ,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x58,0x07,0x07 @@ -469,8 +556,12 @@ const unsigned char spritePlasma[] = ,0x48,0x07 }; -const unsigned char *textures[] = {texture1, texture2, texture3, texture4}; -unsigned char textureAverageColors[4]; +#define TEXTURES 5 + +const unsigned char *textures[TEXTURES] = + {texture1, texture2, texture3, texture4, texture5}; + +unsigned char textureAverageColors[TEXTURES]; Unit floorHeightAt(int16_t x, int16_t y) { @@ -510,9 +601,11 @@ inline void pixelFunc(PixelInfo pixel) if (pixel.isWall) { - c = pixel.depth > TEXTURE_DISTANCE ? - textureAverageColors[pixel.hit.type] : - sampleImage(textures[pixel.hit.type],pixel.hit.textureCoord,pixel.textureCoordY); + Unit textureScroll = pixel.hit.type != 4 ? 0 : 16 * pokitto.frameCount; + + c = pixel.depth < TEXTURE_MAX_DISTANCE ? + sampleImage(textures[pixel.hit.type],pixel.hit.textureCoord + textureScroll,pixel.textureCoordY) : + textureAverageColors[pixel.hit.type]; if (previousColumn == pixel.position.x) { @@ -566,7 +659,7 @@ int main() { initGeneral(); - for (uint8_t i = 0; i < 4; ++i) + for (uint8_t i = 0; i < TEXTURES; ++i) textureAverageColors[i] = computeAverageColor(textures[i]); cFloor = rgbToIndex(0,1,1);