From d748874c08dc2a602fba680d21d8c1909a18b30e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Fri, 14 Sep 2018 19:42:02 +0200 Subject: [PATCH] Add doors --- demo2.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/demo2.cpp b/demo2.cpp index 5af058b..b4053d5 100644 --- a/demo2.cpp +++ b/demo2.cpp @@ -66,11 +66,11 @@ const unsigned char level[] = 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,2,0,0,0,0,4,0,0,0,5,0,0,2,0,0, // 8 + 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,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,5,2,0,0,0,0,2, // 12 + 1,3,1,0,4,4,4,2,2,1,2,6,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,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 @@ -776,8 +776,23 @@ Unit floorHeightAt(int16_t x, int16_t y) Unit textureAt(int16_t x, int16_t y) { + Unit t = 0; + if (x >= 0 && x < LEVEL_X_RES && y >= 0 && y < LEVEL_Y_RES) - return max(level[(LEVEL_Y_RES - y -1) * LEVEL_X_RES + x] - 1,0); + t = max(level[(LEVEL_Y_RES - y -1) * LEVEL_X_RES + x] - 1,0); + + t = t == 5 ? 1 : t; // square 6 has the same texture as 1 + + return t; +} + +Unit rollAt(int16_t x, int16_t y) +{ + Unit square = textureAt(x,y); + + if (x >= 0 && x < LEVEL_X_RES && y >= 0 && y < LEVEL_Y_RES && + level[(LEVEL_Y_RES - y -1) * LEVEL_X_RES + x] == 6) + return (pokitto.frameCount * 10) % UNITS_PER_SQUARE; return 0; } @@ -846,7 +861,7 @@ void draw() #ifdef RENDER_PRECISE render(player.mCamera,floorHeightAt,0,textureAt,pixelFunc,c); #else - renderSimple(player.mCamera,floorHeightAt,textureAt,pixelFunc,c); + renderSimple(player.mCamera,floorHeightAt,textureAt,pixelFunc,rollAt,c); #endif player.mCamera.height -= player.mHeadBob;