diff --git a/assets/levelY.gif b/assets/levelY.gif index 5ea93b8..37d4df9 100644 Binary files a/assets/levelY.gif and b/assets/levelY.gif differ diff --git a/assets/sfx_monster.raw b/assets/sfx_monster.raw new file mode 100644 index 0000000..fecf4a2 --- /dev/null +++ b/assets/sfx_monster.raw @@ -0,0 +1 @@ +€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€~‚€~€€€€}}‚…„}xy|‚ƒƒƒƒƒyuuy€ˆŠˆ„€~|yx{„…~{}€€„……}tt{„ˆˆ„€{pky‰ˆ€‚‚}ut~Š„vou~‡‰ƒƒƒyusw‚‰Ž†|v|Š‡ynsŒuv‚Š„wrr|†‹ˆ{|€€~}{~‚‚ƒ‚||}€€‚€|{~ƒƒ€~€€}}~ƒ||~|}‚…‡xy~}‚…‡„~zy}~yswˆ•Ž‚}„†vjlw‚Œ‹‹„||{y|‡†|zƒˆ„|xz†‚~‚††„ƒ{xxyz}…Œmj‚Œƒ„ˆ|w}{v~Œˆ€|†ˆ}€zy}z|{‹‹ˆ‚|ztsz…‰ƒ…†zv|‡Ž‚yy~~€†…„}tvzƒ€ƒ€|…ƒ~z{‚…ƒ€}}~||‚€|{}ƒƒyx}††}y~‰Œ‡†~ŠŒ{gf{—©c^vœœZUwŸ²¤~fhmsz„Ž”wlxƒ€‚…~ww~€}ˆ„‚…†‡l^d{’˜•€shn~ŒŽ‰‚rmnw†’‘€uwv|€yv|z}‹‚|x|x|yqzŒ„‚zxtx€‚„„‚}|w{~‚‚}z}€{|†„~||~|‚€~„…€|zy~‚€ƒ‚€|z~€|}„„‚…‡…‚{yy}†‰„zx‰…xoqŽ“|sv~…‚}~ƒ‰€yz„“tt†…|t‡ƒz„Š}{ƒ†}y„„tr…’zvz„‡spy•¥“kgŠzrt‚™–‡tcl‹ €wŒpr•˜iY{•{|‡†~…thƒ˜—|ovxˆ•Šid‹¡…a]€š¢•wkx””ucn€‹’ˆyy€{v’ŸyXl¦|ckwƒ‹‚xŽ›‰b[t‘›ˆvz‡’‹odj}†’’xp~–ž€VQ~¯ŸjMc‹›žšˆo`i{‘„t{sw‰„xw~†|tx|ŠŽŠ|tz~ztyƒ‰‰yt£ÑãÕ¼€L7?GGU~®º¼¿¸¥b8)6Ng†§ÃÊ¿±¤{@!1aŠ°½ÀËÄsK2Yy ÏðäƤ{L+'=Um‘¸ÓÓµŒm[@+5\ˆš«ÆÍÀ®—rD,3DVk’¼àÞ»–oP97:It¡ÄËÊȲ’_1&ERd“ÆßÔ®†jP89E\€¢ÂËÆ·—q\SF9=`‹«ÀÊÄ»™lN<48Af¢ÐÛɳŸ‹nQ4*=e²Âù®™nA0@KUh’ÁÞÝĤ~P/'0Hv«Í†}xuz…Œ}icr’’Œ€{~|}‚Ž†tcey‰‰ƒzx‰„{|‰‰tnyƒˆzn}š¦’xf`iku{ƒŒ›«§•wedotwyz|†‘Švkrz…‰”¡“~cWs‘š„kk€„~†‹}xz~|qu€ˆ†ylfs‹˜–‰wsvˆ€|~zxumtwzˆ•‘‚vox„„zv€†…€}ysry‚……†{ywtv‚‹„~}ƒˆ‚|‚„}wutˆ…ƒts}„„„…{|†Œ‡zx~€}{}„‰‡}y|‚ƒ~wuy…ƒ|pow‚‘˜ž‘~rorw|~}~ƒ‰‚xsy‚…‡‡……‚~€‚…{~}{y{…Œ‹ƒz{}‚‚~{yŠ‰„~|{ywvu|Š’’…~zux|}~‚‡ˆ„~}~|||‚†„€~|}ƒ†zy~~}ƒ†„~~}}ƒƒ€|{}‚~{|ƒ€}„ƒ€}€}|€„‚}}‚|€€€~~€~~~€€€€€€€€€€~€~~€€€€~~€€€€€€€€€€€€€€€€€~€€€ \ No newline at end of file diff --git a/main.c b/main.c index bfe564b..ab03926 100755 --- a/main.c +++ b/main.c @@ -261,6 +261,8 @@ struct uint8_t spriteAnimationFrame; uint8_t explosionSoundPlayed; /**< Prevents playing too many explosion sounds at once */ + uint8_t monsterSoundPlayed; + RCL_RayConstraints rayConstraints; uint8_t keyStates[SFG_KEY_COUNT]; /**< Pressed states of keys, each value stores the number of frames for which the @@ -448,6 +450,13 @@ void SFG_playSoundSafe(uint8_t soundIndex, uint8_t volume) SFG_game.explosionSoundPlayed = 1; } + else if (soundIndex == 5) // monster sound + { + if (!SFG_game.monsterSoundPlayed) + SFG_playSound(soundIndex,volume); + + SFG_game.monsterSoundPlayed = 1; + } else SFG_playSound(soundIndex,volume); } @@ -1717,7 +1726,9 @@ uint8_t SFG_distantSoundVolume(RCL_Unit x, RCL_Unit y, RCL_Unit z) if (distance >= SFG_SFX_MAX_DISTANCE) return 0; - return 255 - (distance * 255) / SFG_SFX_MAX_DISTANCE; + uint32_t result = 255 - (distance * 255) / SFG_SFX_MAX_DISTANCE; + + return (result * result) / 256; } void SFG_createExplosion(RCL_Unit x, RCL_Unit y, RCL_Unit z) @@ -2059,6 +2070,16 @@ void SFG_monsterPerformAI(SFG_MonsterRecord *monster) state == SFG_MONSTER_STATE_GOING_SW) coordAdd[1] = add; + if ((coordAdd[0] != 0 || coordAdd[1] != 0) && SFG_random() < + SFG_MONSTER_SOUND_PROBABILITY) + SFG_playSoundSafe(5, + SFG_distantSoundVolume( + SFG_MONSTER_COORD_TO_RCL_UNITS(monster->coords[0]), + SFG_MONSTER_COORD_TO_RCL_UNITS(monster->coords[1]), + SFG_floorHeightAt( + SFG_MONSTER_COORD_TO_SQUARES(monster->coords[0]), + SFG_MONSTER_COORD_TO_SQUARES(monster->coords[1]))) / 2); + if (add) state = SFG_MONSTER_STATE_IDLE; } @@ -2455,7 +2476,15 @@ void SFG_updateLevel() monster->stateType = (monster->stateType & SFG_MONSTER_MASK_TYPE) | SFG_MONSTER_STATE_DYING; - SFG_playSoundSafe(2,255); + uint8_t volume = SFG_distantSoundVolume( + SFG_MONSTER_COORD_TO_RCL_UNITS(monster->coords[0]), + SFG_MONSTER_COORD_TO_RCL_UNITS(monster->coords[1]), + SFG_floorHeightAt( + SFG_MONSTER_COORD_TO_SQUARES(monster->coords[0]), + SFG_MONSTER_COORD_TO_SQUARES(monster->coords[1]))); + + SFG_playSoundSafe(2,volume); + SFG_playSoundSafe(5,volume); } else if (state != SFG_MONSTER_STATE_INACTIVE) { @@ -3132,6 +3161,7 @@ void SFG_gameStepMenu() void SFG_gameStep() { SFG_game.explosionSoundPlayed = 0; + SFG_game.monsterSoundPlayed = 0; for (uint8_t i = 0; i < SFG_KEY_COUNT; ++i) if (!SFG_keyPressed(i)) diff --git a/settings.h b/settings.h index 2020210..6a78749 100644 --- a/settings.h +++ b/settings.h @@ -194,12 +194,17 @@ */ #define SFG_BLINK_PERIOD 500 +/** + Probability (0 - 255) of how often a monster makes sound during movement. +*/ +#define SFG_MONSTER_SOUND_PROBABILITY 64 + //------ developer/debug settings ------ /** Developer cheat for having infinite ammo in all weapons. */ -#define SFG_INFINITE_AMMO 0 +#define SFG_INFINITE_AMMO 1 /** Developer cheat for immortality. diff --git a/sounds.h b/sounds.h index fcc5f69..46cbc0e 100644 --- a/sounds.h +++ b/sounds.h @@ -301,6 +301,60 @@ SFG_PROGRAM_MEMORY uint8_t SFG_sounds[][SFG_SFX_SIZE] = 136,136,136,136,136,136,136,136,136,136,135,119,119,119,119,119,119,119,119,119, 119,119,119,136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,136, 136,136,136,136,136 + }, + { // 5, robot/monster sound (beep) +136,120,120,120,136,136,136,136,120,120,135,136,136,136,120,136,136,119,136, +136,120,136,119,120,136,136,136,120,136,119,120,136,135,119,136,135,120,136,119, +119,136,136,119,119,120,136,136,135,119,119,136,136,136,119,119,119,136,119,120, +136,136,135,119,120,136,136,119,103,136,136,120,135,119,120,136,118,119,136,136, +136,119,119,136,136,119,120,135,103,136,136,119,136,135,119,120,136,119,120,135, +119,120,136,135,119,119,135,120,136,135,119,136,136,119,136,119,120,136,135,119, +119,119,136,136,119,120,119,136,136,119,119,119,119,137,136,120,135,102,120,136, +136,119,119,120,135,120,136,119,120,136,119,136,136,135,119,119,119,136,136,134, +104,136,136,119,119,119,136,135,120,136,120,119,119,119,135,136,136,136,119,119, +119,136,136,135,119,136,135,119,120,136,135,119,120,135,136,136,119,136,119,120, +136,135,119,120,135,119,136,135,119,136,136,136,120,119,119,136,119,120,136,135, +120,135,102,121,169,118,87,137,151,85,121,186,118,102,119,136,152,118,120,136, +135,119,120,120,136,136,136,136,101,103,153,152,135,102,120,136,135,102,120,153, +135,119,119,135,119,119,136,135,119,119,119,120,136,135,119,119,136,136,136,119, +119,119,136,119,119,135,120,135,119,119,120,135,120,136,119,119,136,136,135,119, +135,119,136,136,136,136,135,119,120,136,119,120,136,118,119,137,135,119,120,135, +119,136,135,119,120,152,119,136,119,120,135,136,119,136,119,136,135,120,152,119, +120,136,119,119,154,150,103,152,119,120,153,135,102,138,135,136,119,153,101,121, +151,120,135,136,118,137,151,103,120,152,102,138,134,88,154,151,103,153,118,104, +137,135,120,119,153,117,105,167,102,120,136,119,137,134,87,153,135,120,152,102, +103,137,151,119,153,133,87,169,100,104,153,152,102,103,153,135,119,136,119,120, +136,119,119,135,119,120,136,119,119,119,120,136,135,122,222,219,132,51,68,87, +171,187,186,134,50,52,104,172,203,186,116,33,54,139,188,204,151,67,52,87, +155,220,152,136,98,17,73,223,218,136,100,34,53,155,187,188,185,82,18,71, +155,205,203,150,65,19,86,156,238,201,100,50,36,122,205,220,167,66,34,88, +171,204,201,102,84,51,71,155,221,184,118,66,19,107,238,202,152,99,1,72, +172,204,218,116,51,36,104,172,222,183,83,35,87,120,190,234,118,100,34,70, +155,237,170,167,50,52,104,155,221,168,100,51,69,103,190,236,134,82,2,120, +138,223,199,102,82,19,105,204,204,185,82,52,85,106,216,103,153,117,104,134, +104,152,118,103,137,135,136,136,135,102,119,121,151,104,152,84,104,135,154,134, +103,136,119,135,120,135,120,135,136,119,136,118,86,153,118,137,134,137,117,105, +153,136,117,103,136,120,152,119,119,136,135,136,135,104,152,137,136,119,119,120, +119,135,86,156,204,253,150,67,35,87,155,222,200,84,52,51,89,206,236,186, +115,34,69,104,206,220,150,84,67,53,141,254,168,118,50,53,104,188,186,151, +84,68,87,172,220,169,135,66,53,120,154,188,203,116,52,84,71,189,219,169, +116,34,53,122,207,236,167,66,35,86,155,221,184,101,66,53,137,172,204,169, +116,35,69,105,190,219,150,83,51,71,172,204,203,149,49,35,104,172,238,200, +100,51,69,105,205,218,134,83,52,88,172,204,185,117,84,51,104,172,204,185, +100,51,52,106,221,203,152,101,50,54,139,204,186,150,67,68,86,156,221,202, +117,34,52,122,200,135,119,120,136,118,103,137,152,135,119,119,136,152,118,103, +136,135,119,136,135,120,135,118,120,135,103,154,151,102,102,119,136,154,169,118, +102,119,119,120,152,118,119,136,154,151,101,121,152,102,136,120,136,119,119,119, +120,136,118,103,137,152,119,119,136,136,119,119,118,119,120,136,153,135,103,136, +119,136,136,119,119,120,136,136,135,136,119,119,120,136,119,136,135,120,135,119, +120,136,135,136,119,119,136,136,119,136,135,119,136,119,120,136,135,119,136,119, +119,136,135,119,118,120,153,153,151,118,119,119,119,136,135,119,136,136,136,135, +120,136,135,119,119,119,136,136,119,120,135,119,136,136,119,119,119,119,137,152, +135,119,119,119,136,136,119,119,119,136,136,136,119,120,136,119,119,119,136,136, +119,119,119,136,136,136,135,119,136,119,120,136,119,136,135,120,119,136,135,120, +135,119,136,119,136,135,119,136,119,119,120,136,136,119,120,135,136,135,120,135, +119,136,119,136,135,136,119,120,136,120,136,120,136,119,135,119,136,119,136,135, +136,119,120,135,120 } };