Add monster sound

This commit is contained in:
Miloslav Číž 2020-03-30 18:52:54 +02:00
parent 41f61b049b
commit b2f59297cb
5 changed files with 93 additions and 3 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

1
assets/sfx_monster.raw Normal file
View File

@ -0,0 +1 @@
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€~≠÷~€€€€}}eп}xy|ャャyuuy€<79><C280>€~|yx{у~{}€€<C280>}tt{ц<>€{pky燕<79>}ut~轄ёou~㊨ャメyusw紙|v|括yns香uvжrr|<7C><>{|€€~}{~bモ||}€€≠€|{~ャ÷~€€}}~=メ||~|}〟xy~<7E>}e℡~zy}~ysw<73>獅}фvjlw給л|{y|㊥|zヨлxz≧<7A>~<><EFBD86>{xxyz}<7D>j<EFBD8C>w}{v~決€|<>±€zy}z|°豪<C2B0>|ztsz<7A><EFBFBD>v|㍽y~~€<>мtvz€€|<>~z{eム}}~||≠€|{}<EFBC9D>yx}<7D>}y~煙㊥~褐{gf{掠<>c^v骨<76>ZUw浚、~fhmszь拍wlxム~ww~€}∴р<D180>^d{著撫€shn~月奄rmnw<6E>操uwv|€yv|z}居<>x|x|yqz件рzxtx€≠т<E289A0>|w{~}z}€{|<7C>~||~|<>~у€|zy~<7E>€|z~€|}р≦㊤<E289A6>yy}<7D>йx<7F>oq雌鋼sv~<7E>}~ラ€yz<7F>衡t<E8A1A1>|t㏍zш}{ユ}yыдr<D0B4>鉱vz<7A>spy払徒g衰zrt枚tcl侠€w曙pr葺iY{武{|㊥~≦th<74>慾ovx<76>格d僑<64>]€圓婦kx粕ucn€<C280>y€{v帖yXl擱|ckwル寺叡[t騒<74>z∫黍dj}<7D>遅p~満€VQ~ッ殍Mc魚椢<E9AD9A>`i{髄<>t{刻sw♂зw~<>tx|且掛tz~ztyラ拷yt」ム耻シ€L7?GGU~ョコシソク・獣8)6Ng<4E>テハソア、{@!1a寛スタヒト捏K2<H[v損ルツ搖шi+J尤﨨ャ処lJ..?^粉コオシタエ塑."Ix涅ヌヤホー罵@<Yn堕鈿ネ壇K=.)Gz」タムレヒ、tH,$-R└イニフテ捐`XK:5Jz楡ルヨオ瞬`D%2mカ裼フ」粋i0 N€ヲチハフユュp@8</Gm恨チリ盪tP9*7Uwx<77>裹ャxlgG$&Nj誠耜ォュ」p7'2BcクロロゥN63E^n~イ肅ツ敬U&,r隙<72><EFBFBD>hkW$0d估ヘヘナー甜*1FWWkァヨy沾|^o庶oeヱビkm|酷】肢€轄xgm|vz燈yn汚<6E>Je炎{瀬仔h~恰yベw球rsп}|<7C>~o[k増~n<><6E>{Wm侭虫志^j}朽z≒<7A>rpt°<74><EFBFBD>g∑渚剥<E6B89A>yqp<70>y鶏[e畔ナノ<EFBE85>單K5$6Ut直゙衫産A?J36W痛聶フサ「v< 'L]k座籟ト僕QGD6;V稼<56>c?,;Zo樟フク・宋[JJHUu。ナヤヌッ寥rE)5[w€闘セナトカE3HTLJsーユラセァ肺N(!>Yy<59><EFBFBD>ニ、{L+'=Um尊モモオ稽[@+5\<5C>ォニヘタョ羊D,3DVk直玻サ撲P97:It。トヒハネイ胆1&<b襖ハ韜チ鈎E;>ERd独゚ヤョ<EFBE94>P89E\€「ツヒニキ窯\SF9=`境タハトサ冤N<48Af「ミロノウ沂nQ4*=e彰ツテケョ冢A0@KUh鎮゙ント、~P/'0Hvォヘ<EFBDAB>}xuz<75>殉icr穀柱€{~|}炊tcey演ホx縁к|演tnyヨzn}圜遅f`iku{レ岫ァ婦edotwyz|<7C>革krz<72>硲冬cWs霜<73>k€н<C280>急xz~|qu€<75>ylfs鋸哩wsv∴÷|~zxumtwz∴助曹voxтzv€<76>€}ysry≠≦<E289A0>≧{ywtvн}ヨ<>}wut∴<74>ts}ту{|<7C><>x~÷}{}ч合}y|~wuy≦<79>|pow<77>梠~rorw|~}~ラsy<EFBD85><E38AA6>~€~}{y{<7B>泣z{}~{y♀延~|{ywvu|樺注<E6A8BA>zux|}~<>~}~|||fп€×|}ユ】y~~}ユп~~}}==ャ€|{}≠~{|€}с€}€}|€р}}≠|€€€~~÷~~~€€÷€€€€€€€<7F>~÷~~€÷€€~~€€€€€€€€€€€€€€€€€~€€€

34
main.c
View File

@ -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))

View File

@ -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.

View File

@ -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
}
};