Fix walls

This commit is contained in:
Miloslav Číž 2018-09-15 11:34:08 +02:00
parent cf9504fbd9
commit 735987ff33

View file

@ -55,28 +55,35 @@ Player player;
#define INFO_BAR_START 70
#define TEXTURE_MAX_DISTANCE (UNITS_PER_SQUARE * 6)
// temporary defines for better visibility of walls and floors below
#define D 6
#define o 0
const unsigned char level[] =
{
/* 10 12 14 16 18 20 22 24 26 28 30
0 1 2 3 4 5 6 7 8 9 11 13 15 17 19 21 23 25 27 29 31 */
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,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,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,6,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,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,o,o,2,2,4,1,4,o,4,4,4,3,2,o,o,4,2,2, // 9
o,o,4,4,4,o,o,o,o,o,o,o,o,o,o,3,3,4,o,o,o,o,o,1,o,o,o,o,o,o,o,4, // 1o
2,o,o,o,3,o,o,o,o,o,o,o,o,o,3,3,2,4,o,o,o,o,o,1,o,o,4,o,o,3,o,1, // 11
1,3,1,o,4,4,4,2,2,1,2,D,2,2,3,o,o,1,4,o,o,o,3,3,3,5,2,o,o,o,o,2, // 12
o,o,o,o,o,o,o,o,o,4,o,o,o,o,2,o,o,o,o,o,o,o,o,o,o,o,o,o,o,3,o,1, // 13
o,o,o,3,o,5,o,3,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,4, // 14
o,o,o,o,o,o,o,o,o,4,o,o,o,o,2,o,o,5,o,o,4,o,o,1,o,3,o,3,o,3,o,1 // 15
};
#undef D
#undef o
const unsigned char texture1[] =
{ 32, 36 // width, height
,0x01,0x01,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09
@ -86,6 +93,7 @@ const unsigned char texture1[] =
,0x0a,0x0a,0x12,0x0a,0x09,0x12,0x09,0x09,0x09,0x09,0x09,0x12,0x09,0x09
,0x09,0x01,0x01,0x01,0x12,0x12,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09
,0x09,0x09,0x0a,0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x0a,0x09,0x09,0x09
,0x09,0x09,0x09,0x09,0x12,0x09,0x09,0x09,0x09,0x01,0x01,0x01,0x12,0x0a
,0x12,0x09,0x12,0x09,0x12,0x12,0x0a,0x09,0x12,0x09,0x12,0x12,0x12,0x1a
,0x1b,0x1b,0x12,0x12,0x12,0x09,0x09,0x12,0x09,0x09,0x12,0x12,0x09,0x09
@ -768,9 +776,14 @@ unsigned char textureAverageColors[TEXTURES];
Unit floorHeightAt(int16_t x, int16_t y)
{
if (x < 0 || x >= LEVEL_X_RES || y < 0 || y >= LEVEL_Y_RES)
return UNITS_PER_SQUARE * 2;
Unit square = level[(LEVEL_Y_RES - y -1) * LEVEL_X_RES + x];
#ifdef RENDER_PRECISE
/* algorithm used with this version doesn't support rolling doors, so give
door square zero height */
return square == 0 || square == 6 ? 0 : UNITS_PER_SQUARE * 2;
#else
return square == 0 ? 0 : UNITS_PER_SQUARE * 2;
@ -779,6 +792,9 @@ Unit floorHeightAt(int16_t x, int16_t y)
Unit collisionAt(int16_t x, int16_t y)
{
if (x < 0 || x >= LEVEL_X_RES || y < 0 || y >= LEVEL_Y_RES)
return UNITS_PER_SQUARE;
Unit square = level[(LEVEL_Y_RES - y -1) * LEVEL_X_RES + x];
return square == 0 || square == 6 ? 0 : UNITS_PER_SQUARE;
}