From 21cedabf85af587c23da1e08fbb5eafc43a81827 Mon Sep 17 00:00:00 2001 From: Miloslav Ciz Date: Fri, 29 Nov 2024 00:51:43 +0100 Subject: [PATCH] Add hill block --- assets.h | 7 ++++++- map.h | 40 +++++++++++++++++++++++++++++++++++----- racing.h | 18 ++++++++++++++++++ 3 files changed, 59 insertions(+), 6 deletions(-) diff --git a/assets.h b/assets.h index f8e1749..d647b28 100644 --- a/assets.h +++ b/assets.h @@ -18,7 +18,12 @@ static const char *LCR_maps[] = { - "LM;;;0; #=s0s0 #}r0s0-|L #*r0c0 " + "LM;;;0;#*s1s0" + "#=s0s0 #fd190" + "#=C0s1 #fd190" + "#=M0s2 #fd190" + "#=W0s3 #fd190" + "#(s0r0" }; #define LCR_IMAGE_SIZE 64 ///< one-dimension resolution of bitmap image diff --git a/map.h b/map.h index 586daf8..12b5dcf 100644 --- a/map.h +++ b/map.h @@ -103,11 +103,15 @@ #define LCR_BLOCK_RAMP_STEEP 0x0c ///< extremely steep ramp #define LCR_BLOCK_CORNER 0x0d ///< diagonal corner #define LCR_BLOCK_CORNER_12 0x0e ///< diagonal corner (1/2 wide) +#define LCR_BLOCK_HILL 0x0f ///< curved "hill" #define LCR_BLOCK_FULL_ACCEL 0x20 #define LCR_BLOCK_FULL_FAN 0x30 #define LCR_BLOCK_CHECKPOINT_0 0x40 ///< checkpoint, not taken #define LCR_BLOCK_CHECKPOINT_1 0x41 ///< checkpoint, taken + + + #define LCR_BLOCK_FINISH 0x42 ///< finish // special blocks: @@ -129,8 +133,6 @@ - bumpy road */ - - #define LCR_MAP_BLOCK_CACHE_SIZE (8 * 2) /// do not change /** @@ -344,6 +346,7 @@ uint8_t _LCR_mapCharToBlockType(char c) case '|': return LCR_BLOCK_RAMP_STEEP; break; case 'A': return LCR_BLOCK_CORNER; break; case '\\': return LCR_BLOCK_CORNER_12; break; + case '(': return LCR_BLOCK_HILL; break; case '>': return LCR_BLOCK_FULL_ACCEL; break; case 'o': return LCR_BLOCK_FULL_FAN; break; case '+': return LCR_BLOCK_CHECKPOINT_0; break; @@ -505,14 +508,17 @@ uint8_t LCR_mapLoadFromStr(const char *mapStr) mat = LCR_mapBlockGetMaterial(prevBlock); transform = LCR_mapBlockGetTransform(prevBlock); LCR_mapBlockGetCoords(prevBlock,&x,&y,&z); - + for (uint8_t k = 0; k < coords[2]; ++k) for (uint8_t j = 0; j < coords[1]; ++j) for (uint8_t i = 0; i < coords[0]; ++i) - if (block == LCR_BLOCK_CUBOID_FILL || + if ((block == LCR_BLOCK_CUBOID_FILL || k == 0 || k == coords[2] - 1 || j == 0 || j == coords[1] - 1 || - i == 0 || i == coords[0] - 1) + i == 0 || i == coords[0] - 1) && + (x + i < LCR_MAP_SIZE_BLOCKS && + y + j < LCR_MAP_SIZE_BLOCKS && + z + k < LCR_MAP_SIZE_BLOCKS)) { LCR_makeMapBlock(prevBlock[0],x + i,y + j,z + k,mat,transform, tmpBlock); @@ -847,6 +853,30 @@ void LCR_mapGetBlockShape(uint8_t blockType, uint8_t transform, break; } + case LCR_BLOCK_HILL: + ADD(0,0,0) ADD(6,0,0) ADD(0,2,1) // front + ADD(6,0,0) ADD(6,2,1) ADD(0,2,1) + ADD(0,2,1) ADD(6,2,1) ADD(0,3,2) // front 2 + ADD(6,2,1) ADD(6,3,2) ADD(0,3,2) + ADD(0,3,2) ADD(6,3,2) ADD(0,4,4) // front 3 + ADD(6,3,2) ADD(6,4,4) ADD(0,4,4) + ADD(0,4,4) ADD(6,4,4) ADD(0,4,6) // top + ADD(6,4,4) ADD(6,4,6) ADD(0,4,6) + ADD(0,0,0) ADD(0,0,6) ADD(6,0,0) // bottom + ADD(6,0,0) ADD(0,0,6) ADD(6,0,6) + ADD(0,0,6) ADD(0,4,6) ADD(6,4,6) // back + ADD(0,0,6) ADD(6,4,6) ADD(6,0,6) + ADD(0,0,0) ADD(0,2,1) ADD(0,0,6) // left + ADD(0,2,1) ADD(0,3,2) ADD(0,0,6) + ADD(0,3,2) ADD(0,4,4) ADD(0,0,6) + ADD(0,4,4) ADD(0,4,6) ADD(0,0,6) + ADD(6,0,0) ADD(6,0,6) ADD(6,2,1) // right + ADD(6,2,1) ADD(6,0,6) ADD(6,3,2) + ADD(6,3,2) ADD(6,0,6) ADD(6,4,4) + ADD(6,4,4) ADD(6,0,6) ADD(6,4,6) + + break; + default: break; } diff --git a/racing.h b/racing.h index facfea8..bec9bcc 100644 --- a/racing.h +++ b/racing.h @@ -227,6 +227,24 @@ TPE_Vec3 _LCR_racingBlockEnvFunc(TPE_Vec3 point, const uint8_t *block) break; } + case LCR_BLOCK_HILL: + { + point = + (point.y > -1 * LCR_PHYSICS_UNIT / 4 && point.z < LCR_PHYSICS_UNIT / 4) ? + TPE_envCylinder(point, + TPE_vec3(0,-1 * LCR_PHYSICS_UNIT / 2,LCR_PHYSICS_UNIT / 4), + TPE_vec3(LCR_PHYSICS_UNIT / 2,0,0), + LCR_PHYSICS_UNIT / 2 + LCR_PHYSICS_UNIT / 4) : + TPE_envAABox(point,TPE_vec3(0,0,0), + TPE_vec3(LCR_PHYSICS_UNIT / 2,LCR_PHYSICS_UNIT / 4, + LCR_PHYSICS_UNIT / 2)); + + if (point.y < -1 * LCR_PHYSICS_UNIT / 4) // for some reason happens somet. + point.y = -1 * LCR_PHYSICS_UNIT / 4; + + break; + } + case LCR_BLOCK_CORNER: case LCR_BLOCK_CORNER_12: {