Add invisible wall

This commit is contained in:
Miloslav Číž 2020-02-24 08:26:35 +01:00
parent 7dfa0d32a5
commit 4e4dd996da
3 changed files with 33 additions and 20 deletions

View File

@ -82,6 +82,9 @@ level ideas:
- barrel on elevator - barrel on elevator
- platforming vertical section in which the player is going upwards out of a big - platforming vertical section in which the player is going upwards out of a big
hole hole
- invisible bridge (perhaps not straight) made of bleckers (invisible walls)
over a hole, leading to an easter egg
- start of level: a corner blocked by an invisible wall, to indicate entrance
bugs: bugs:

View File

@ -105,6 +105,7 @@ typedef struct
access card. */ access card. */
#define SFG_LEVEL_ELEMENT_LOCK1 0x0e #define SFG_LEVEL_ELEMENT_LOCK1 0x0e
#define SFG_LEVEL_ELEMENT_LOCK2 0x0f #define SFG_LEVEL_ELEMENT_LOCK2 0x0f
#define SFG_LEVEL_ELEMENT_BLOCKER 0x10 ///< Invisible wall.
/* /*
Monsters have lower 4 bits zero and are only distinguished by the 4 upper Monsters have lower 4 bits zero and are only distinguished by the 4 upper
@ -304,7 +305,7 @@ SFG_PROGRAM_MEMORY SFG_Level SFG_levels[SFG_NUMBER_OF_LEVELS] =
{SFG_LEVEL_ELEMENT_TELEPORT, {20, 40}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_TELEPORT, {20, 40}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}},
{SFG_LEVEL_ELEMENT_TERMINAL, {11, 25}}, {SFG_LEVEL_ELEMENT_TERMINAL, {11, 26}}, {SFG_LEVEL_ELEMENT_TERMINAL, {11, 25}}, {SFG_LEVEL_ELEMENT_TERMINAL, {11, 26}},
{SFG_LEVEL_ELEMENT_MONSTER_WARRIOR, {10, 45}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_MONSTER_WARRIOR, {10, 45}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}},
{SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_BLOCKER, {14, 26}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}},
{SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}},
{SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}},
{SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}}, {SFG_LEVEL_ELEMENT_NONE, {0, 0}},

23
main.c
View File

@ -1114,10 +1114,10 @@ RCL_Unit SFG_ceilingHeightAt(int16_t x, int16_t y)
Gets sprite (image and sprite size) for given item. Gets sprite (image and sprite size) for given item.
*/ */
void SFG_getItemSprite( void SFG_getItemSprite(
uint8_t elementType, uint8_t *spriteIndex, uint8_t *spriteSize) uint8_t elementType, const uint8_t **sprite, uint8_t *spriteSize)
{ {
*spriteSize = 0; *spriteSize = 0;
*spriteIndex = elementType - 1; *sprite = (const uint8_t *) &(SFG_itemSprites[elementType - 1]);
switch (elementType) switch (elementType)
{ {
@ -1137,7 +1137,12 @@ void SFG_getItemSprite(
case SFG_LEVEL_ELEMENT_CARD0: case SFG_LEVEL_ELEMENT_CARD0:
case SFG_LEVEL_ELEMENT_CARD1: case SFG_LEVEL_ELEMENT_CARD1:
case SFG_LEVEL_ELEMENT_CARD2: case SFG_LEVEL_ELEMENT_CARD2:
*spriteIndex = SFG_LEVEL_ELEMENT_CARD0 - 1; *sprite =
(const uint8_t *) &(SFG_itemSprites[SFG_LEVEL_ELEMENT_CARD0 - 1]);
break;
case SFG_LEVEL_ELEMENT_BLOCKER:
*sprite = 0;
break; break;
default: default:
@ -1153,7 +1158,8 @@ uint8_t SFG_itemCollides(uint8_t elementType)
return return
elementType == SFG_LEVEL_ELEMENT_BARREL || elementType == SFG_LEVEL_ELEMENT_BARREL ||
elementType == SFG_LEVEL_ELEMENT_TREE || elementType == SFG_LEVEL_ELEMENT_TREE ||
elementType == SFG_LEVEL_ELEMENT_TERMINAL; elementType == SFG_LEVEL_ELEMENT_TERMINAL ||
elementType == SFG_LEVEL_ELEMENT_BLOCKER;
} }
void SFG_setAndInitLevel(const SFG_Level *level) void SFG_setAndInitLevel(const SFG_Level *level)
@ -3649,11 +3655,13 @@ void SFG_draw()
worldPosition.y = worldPosition.y =
SFG_ELEMENT_COORD_TO_RCL_UNITS(e.coords[1]); SFG_ELEMENT_COORD_TO_RCL_UNITS(e.coords[1]);
uint8_t spriteIndex; const uint8_t *sprite;
uint8_t spriteSize; uint8_t spriteSize;
SFG_getItemSprite(e.type,&spriteIndex,&spriteSize); SFG_getItemSprite(e.type,&sprite,&spriteSize);
if (sprite != 0)
{
RCL_PixelInfo p = RCL_PixelInfo p =
RCL_mapToScreen( RCL_mapToScreen(
worldPosition, worldPosition,
@ -3664,12 +3672,13 @@ void SFG_draw()
if (p.depth > 0) if (p.depth > 0)
{ {
SFG_drawScaledSprite( SFG_drawScaledSprite(
SFG_itemSprites[spriteIndex], sprite,
p.position.x * SFG_RAYCASTING_SUBSAMPLE,p.position.y, p.position.x * SFG_RAYCASTING_SUBSAMPLE,p.position.y,
RCL_perspectiveScale(SFG_SPRITE_SIZE(spriteSize),p.depth), RCL_perspectiveScale(SFG_SPRITE_SIZE(spriteSize),p.depth),
p.depth / (RCL_UNITS_PER_SQUARE * 2),p.depth - 1000); p.depth / (RCL_UNITS_PER_SQUARE * 2),p.depth - 1000);
} }
} }
}
// projectile sprites: // projectile sprites:
for (uint8_t i = 0; i < SFG_currentLevel.projectileRecordCount; ++i) for (uint8_t i = 0; i < SFG_currentLevel.projectileRecordCount; ++i)