Add monster dead sprite

This commit is contained in:
Miloslav Číž 2020-07-31 11:32:15 +02:00
parent f035da7a05
commit 7450436bf4
5 changed files with 40 additions and 16 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 449 B

After

Width:  |  Height:  |  Size: 636 B

View File

@ -1327,6 +1327,24 @@ SFG_PROGRAM_MEMORY uint8_t SFG_monsterSprites[][SFG_TEXTURE_STORE_SIZE] =
0,0,0,34,42,153,145,1,195,16,23,119,115,65,0,0,0,0,0,32,2,170,34,31,236,49,23,
116,17,17,0,0,0,0,0,0,0,34,2,24,238,193,1,17,0,0,0,0,0,0,0,0,0,32,0,24,254,193,
0,35,48,0,0,0,0,0,0,0,0,0,0,1,17,16,2,32,48,0,0,0,0,0,0,0,0,0,0,0,1,0,2,0,0,0
},
{ // 18 universal dead/corpse sprite
175,0,3,4,1,5,6,2,157,18,95,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,4,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,66,34,0,0,0,0,0,0,0,0,0,0,0,
0,0,4,50,34,0,0,0,0,0,0,0,0,0,0,0,0,0,4,36,17,0,0,0,0,0,0,0,0,0,0,0,0,1,18,65,
49,0,0,0,0,0,0,0,0,0,0,1,17,34,34,19,51,0,0,0,0,0,0,0,0,0,1,22,98,34,34,33,20,0,
0,0,0,0,0,0,0,0,22,101,101,40,130,36,68,0,0,0,0,0,0,0,0,0,22,85,102,85,136,129,
17,0,0,0,0,0,0,0,0,1,85,85,82,37,136,22,68,0,0,0,0,0,0,0,0,1,18,53,85,34,132,19,
36,0,0,0,0,0,0,0,0,0,2,34,85,84,33,100,66,0,0,0,0,0,0,0,0,1,35,51,51,39,22,102,
49,0,0,0,0,0,0,0,0,1,50,58,58,39,65,101,33,0,0,0,0,0,0,0,0,0,18,34,34,116,22,83,
17,0,0,0,0,0,0,0,0,0,1,34,20,68,17,50,20,0,0,0,0,0,0,0,0,0,0,17,4,68,34,20,52,0,
0,0,0,0,0,0,0,0,0,0,0,34,39,83,49,0,0,0,0,0,0,0,0,0,0,0,34,35,117,51,65,0,0,0,0,
0,0,0,0,0,0,0,0,19,115,51,52,0,0,0,0,0,0,0,0,0,0,0,0,19,55,163,153,0,0,0,0,0,0,
0,0,0,0,0,0,1,55,51,153,0,0,0,0,0,0,0,0,0,0,0,0,0,17,115,41,0,0,0,0,0,0,0,0,0,0,
0,0,17,53,36,65,0,0,0,0,0,0,0,0,0,0,0,0,21,33,17,18,0,0,0,0,0,0,0,0,0,0,0,0,1,
16,1,35,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,50,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,34,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,2,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,34,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0
}
};

38
main.c
View File

@ -221,6 +221,7 @@ typedef struct
#define SFG_MONSTER_STATE_GOING_SW 10
#define SFG_MONSTER_STATE_GOING_W 11
#define SFG_MONSTER_STATE_GOING_NW 12
#define SFG_MONSTER_STATE_DEAD 13
typedef struct
{
@ -532,9 +533,11 @@ static inline uint8_t SFG_RCLUnitToZBuffer(RCL_Unit x)
const uint8_t *SFG_getMonsterSprite(
uint8_t monsterType, uint8_t state, uint8_t frame)
{
uint8_t index = 17; // makes the code smaller compared to returning pointers
uint8_t index =
state == SFG_MONSTER_STATE_DEAD ? 18 : 17;
// ^ makes the code smaller compared to returning pointers
if (state != SFG_MONSTER_STATE_DYING)
if ((state != SFG_MONSTER_STATE_DYING) && (state != SFG_MONSTER_STATE_DEAD))
switch (monsterType)
{
case SFG_LEVEL_ELEMENT_MONSTER_SPIDER:
@ -586,7 +589,7 @@ const uint8_t *SFG_getMonsterSprite(
index = 16;
break;
}
return SFG_monsterSprites[index];
}
@ -2286,7 +2289,10 @@ void SFG_updateLevel()
{
SFG_MonsterRecord *m = &(SFG_currentLevel.monsterRecords[j]);
if (SFG_MR_STATE(*m) != SFG_MONSTER_STATE_INACTIVE)
uint8_t state = SFG_MR_STATE(*m);
if ((state != SFG_MONSTER_STATE_INACTIVE) &&
(state != SFG_MONSTER_STATE_DEAD))
{
if (SFG_projectileCollides(p,
SFG_MONSTER_COORD_TO_RCL_UNITS(m->coords[0]),
@ -2499,7 +2505,8 @@ void SFG_updateLevel()
{
monster->stateType =
(monster->stateType & SFG_MONSTER_MASK_TYPE) |
SFG_MONSTER_STATE_IDLE;
(monster->health != 0 ?
SFG_MONSTER_STATE_IDLE : SFG_MONSTER_STATE_DEAD);
}
SFG_currentLevel.checkedMonsterIndex++;
@ -2519,6 +2526,10 @@ void SFG_updateLevel()
SFG_MonsterRecord *monster = &(SFG_currentLevel.monsterRecords[i]);
uint8_t state = SFG_MR_STATE(*monster);
if ((state == SFG_MONSTER_STATE_INACTIVE) ||
(state == SFG_MONSTER_STATE_DEAD))
continue;
if (state == SFG_MONSTER_STATE_DYING)
{
if (SFG_MR_TYPE(*monster) == SFG_LEVEL_ELEMENT_MONSTER_ENDER)
@ -2534,22 +2545,15 @@ void SFG_updateLevel()
}
}
// remove dead
for (uint16_t j = i; j < SFG_currentLevel.monsterRecordCount - 1; ++j)
SFG_currentLevel.monsterRecords[j] =
SFG_currentLevel.monsterRecords[j + 1];
SFG_currentLevel.monsterRecordCount -= 1;
i--;
monster->stateType =
(monster->stateType & 0xf0) | SFG_MONSTER_STATE_DEAD;
}
else if (monster->health == 0)
{
monster->stateType = (monster->stateType & SFG_MONSTER_MASK_TYPE) |
SFG_MONSTER_STATE_DYING;
}
else if (state != SFG_MONSTER_STATE_INACTIVE)
else
{
#if SFG_PREVIEW_MODE == 0
SFG_monsterPerformAI(monster);
@ -2916,7 +2920,9 @@ void SFG_gameStepPlaying()
{
SFG_MonsterRecord *m = &(SFG_currentLevel.monsterRecords[i]);
if (SFG_MR_STATE(*m) == SFG_MONSTER_STATE_INACTIVE)
uint8_t state = SFG_MR_STATE(*m);
if (state == SFG_MONSTER_STATE_INACTIVE || state == SFG_MONSTER_STATE_DEAD)
continue;
RCL_Vector2D mPos;