diff --git a/assets.h b/assets.h index 431ed2d..3e2bd84 100644 --- a/assets.h +++ b/assets.h @@ -60,7 +60,7 @@ static const char *LCR_internalDataFile = ":^s1A0 :fk110" // ramps before wall ":=s0B0 :fd910" // concrete wall - ":nu0j1 :ly0j1 :AA0j1 " + ":nu0j1 :uy0j1 :AA0j1 " ":vw0m0" ":vx0m0J" diff --git a/make.sh b/make.sh index c291270..aebfd75 100755 --- a/make.sh +++ b/make.sh @@ -3,5 +3,5 @@ clear clear -gcc -std=c99 -g -Wall -Wextra -pedantic -O1 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers `sdl2-config --libs --static-libs` -o game frontend_sdl.c && ./game +gcc -std=c99 -g -Wall -Wextra -pedantic -O1 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers `sdl2-config --libs --static-libs` -o game frontend_sdl.c && ./game $@ diff --git a/map.h b/map.h index 3125b50..73543dc 100644 --- a/map.h +++ b/map.h @@ -105,7 +105,7 @@ #define LCR_BLOCK_HILL '(' ///< curved "hill" #define LCR_BLOCK_BUMP '~' ///< small bump on the road #define LCR_BLOCK_CORNER_CONVEX 'n' ///< curved corner (convex) -#define LCR_BLOCK_CORNER_CONCAVE 'l' ///< curved corner (concave) +#define LCR_BLOCK_CORNER_CONCAVE 'u' ///< curved corner (concave) #define LCR_BLOCK_FULL_ACCEL '>' ///< full block with accelerator #define LCR_BLOCK_BOTTOM_ACCEL 'z' ///< bottom half block with accelerator @@ -450,7 +450,7 @@ uint8_t LCR_mapLoadFromStr(char (*getNextCharFunc)(void), const char *name) c = getNextCharFunc(); - if (c > '0' && c <= '3') + if (c >= '0' && c <= '3') { mat = c - '0'; c = getNextCharFunc(); diff --git a/renderer.h b/renderer.h index 5af6304..05b358a 100644 --- a/renderer.h +++ b/renderer.h @@ -252,6 +252,31 @@ void LCR_rendererDrawText(const char *text, int x, int y, uint16_t color, } } +/** + Guesses (not 100% accurately) if a quad is convex or not. +*/ +int _LCR_rendererQuadLooksConvex(S3L_Unit quad[8]) +{ + S3L_Unit cx = (quad[0] + quad[2] + quad[4] + quad[6]) / 4; + S3L_Unit cy = (quad[1] + quad[3] + quad[5] + quad[7]) / 4; + + S3L_Unit r = 0; + + for (int i = 0; i < 8; i += 2) + { + r += S3L_abs(cx - quad[i]); + r += S3L_abs(cy - quad[i + 1]); + } + + r = (3 * r) / 32; + + for (int i = 0; i < 8; i += 2) + if (S3L_abs(cx - quad[i]) <= r && S3L_abs(cy - quad[i + 1]) <= r) + return 0; + + return 1; +} + uint16_t _LCR_pixelColor = 0; /**< Holds pixel color for _LCR_pixelFunc3D. This is needed is texture subsampling is on. */ @@ -631,7 +656,8 @@ uint8_t _LCR_rendererCheckMapTriCover(const S3L_Index *t1, points2D[13] = (4 * points2D[7] + 3 * points2D[9] + points2D[11]) / 8; // first: does the triangle alone cover the other one? - if (_LCR_rendererQuadCoversTri(points2D + 6,points2D)) + if (_LCR_rendererQuadLooksConvex(points2D +6) && + _LCR_rendererQuadCoversTri(points2D + 6,points2D)) result |= 1 << j; else {