Add block types

This commit is contained in:
Miloslav Ciz 2024-09-23 23:31:30 +02:00
parent e068b02b9f
commit f1bbb1e1b6
5 changed files with 93 additions and 104 deletions

75
map.h
View file

@ -71,38 +71,40 @@
#define LCR_MAP_COUNT 1
// normal blocks:
#define LCR_BLOCK_FULL 0x00 ///< completely filled block
#define LCR_BLOCK_BOTTOM 0x01 ///< filled bottom half
#define LCR_BLOCK_LEFT 0x02 ///< filled left half
#define LCR_BLOCK_BOTTOM_LEFT 0x03 ///< filled bottom left quarter
#define LCR_BLOCK_BOTTOM_LEFT_FRONT 0x04 ///< filled bottom left front eigth
#define LCR_BLOCK_RAMP 0x05
#define LCR_BLOCK_RAMP_HALF 0x06
#define LCR_BLOCK_RAMP_CURVED 0x07
#define LCR_BLOCK_RAMP_CURVED_SHORT 0x08
#define LCR_BLOCK_RAMP_CURVED_WALL 0x09
#define LCR_BLOCK_FULL 0x00 ///< completely filled block
#define LCR_BLOCK_BOTTOM 0x01 ///< filled bottom half
#define LCR_BLOCK_LEFT 0x02 ///< filled left half
#define LCR_BLOCK_BOTTOM_LEFT 0x03 ///< filled bottom left quarter
#define LCR_BLOCK_BOTTOM_LEFT_FRONT 0x04 ///< filled bottom left front eigth
#define LCR_BLOCK_RAMP 0x05 ///< plain ramp
#define LCR_BLOCK_RAMP_34 0x06 ///< plain ramp, 3/4 size
#define LCR_BLOCK_RAMP_12 0x07 ///< plain ramp, 1/2 size
#define LCR_BLOCK_RAMP_14 0x08 ///< plain ramp, 1/4 size
#define LCR_BLOCK_RAMP_CURVED 0x09
#define LCR_BLOCK_RAMP_CURVED_SHORT 0x0a
#define LCR_BLOCK_RAMP_CURVED_WALL 0x0b
#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
#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:
#define LCR_BLOCK_NONE 0x80 /**< no block, can be used e.g to make
holes */
#define LCR_BLOCK_CUBOID_FILL 0x81 /**< makes a cuboid from the previously
specified block, the size is given
by block coordinates */
#define LCR_BLOCK_CUBOID_HOLLOW 0x82 /**< same as the cuboid special block, but
makes a hollow cuboid */
#define LCR_BLOCK_START 0x83 /**< specifies start block position */
#define LCR_BLOCK_NONE 0x80 ///< no block, e.g to make holes
#define LCR_BLOCK_CUBOID_FILL 0x81 /**< makes a cuboid from the
previously specified block, the
size is given by block coords */
#define LCR_BLOCK_CUBOID_HOLLOW 0x82 /**< same as cuboid special block,
but makes a hollow one */
#define LCR_BLOCK_START 0x83 ///< specifies start block position
struct
{
uint16_t blockCount;
uint8_t blocks[LCR_SETTING_MAP_MAX_SIZE * LCR_BLOCK_SIZE];
uint8_t blocks[LCR_SETTING_MAP_MAX_BLOCKS * LCR_BLOCK_SIZE];
uint32_t startPos;
uint8_t environment;
@ -203,7 +205,7 @@ uint8_t *LCR_getMapBlockAtCoordNumber(uint32_t coord)
*/
uint8_t _LCR_mapAddBlock(const uint8_t block[LCR_BLOCK_SIZE])
{
if (LCR_currentMap.blockCount >= LCR_SETTING_MAP_MAX_SIZE)
if (LCR_currentMap.blockCount >= LCR_SETTING_MAP_MAX_BLOCKS)
return 0;
uint32_t coord = LCR_mapBlockGetCoordNumber(block);
@ -515,6 +517,29 @@ void LCR_mapGetBlockShape(uint8_t blockType, uint8_t transform,
ADD(0,0,0) ADD(0,0,6) ADD(6,0,6)
break;
case LCR_BLOCK_RAMP:
case LCR_BLOCK_RAMP_12:
case LCR_BLOCK_RAMP_14:
case LCR_BLOCK_RAMP_34:
{
uint8_t top =
(blockType == LCR_BLOCK_RAMP_14) +
(blockType == LCR_BLOCK_RAMP) * 4 +
(blockType == LCR_BLOCK_RAMP_12 || blockType == LCR_BLOCK_RAMP_34) * 2 +
(blockType == LCR_BLOCK_RAMP_34);
ADD(0,0,0) ADD(0,top,6) ADD(0,0,6) // side
ADD(6,0,0) ADD(6,0,6) ADD(6,top,6) // side
ADD(0,0,0) ADD(6,0,0) ADD(0,top,6) // top
ADD(6,0,0) ADD(6,top,6) ADD(0,top,6) // top
ADD(0,0,6) ADD(6,top,6) ADD(6,0,6) // back
ADD(0,0,6) ADD(0,top,6) ADD(6,top,6) // back
ADD(0,0,0) ADD(0,0,6) ADD(6,0,6) // bottom
ADD(0,0,0) ADD(6,0,6) ADD(6,0,0) // bottom
break;
}
default: break;
}