Difference between revisions of "Give the ego footstep sounds"
From SCI Wiki
Jump to navigationJump to searchm (1 revision) |
|
(No difference)
|
Revision as of 16:45, 5 August 2013
Here's how to do it, using the SNDBLAST or MTBLAST drivers. I created 4 separate WAV footstep sounds & appended them to 4 empty sound resources. Then in the room script, I added a doit() method which basically checks the current loop of the ego. On two of the cells, we trigger a random sound playback of one of the footsteps.
Code:
(local
currentCel
previousCel
loop
)
...
(method (doit)
(var randomSound)
= currentCel (send gEgo:cel)
(if (<> currentCel previousCel)
= loop (send gEgo:loop)
= randomSound Random(0 3)
// ego is walking horizontally
(if(== loop 0 or == loop 1)
(if(== currentCel 0 or == currentCel 4)
(send gTheSoundFX:
prevSignal(0)
stop()
number(randomSound)
play()
)
)
)
// ego is walking vertically
(if(== loop 2 or == loop 3)
(if(== currentCel 3 or == currentCel 0)
(send gTheSoundFX:
prevSignal(0)
stop()
number(randomSound)
play()
)
)
)
)
= previousCel currentCel
)
I did have to make a modification to the ego view in the template game. The 'vertical' animations (the ones where the ego is walking toward/away from you) only had 5 cells, which made the ego sound like he was hobbling. I added an additional cell to each loop which worked, but the result is that the ego appears to be dancing. Quite humorous.
I've uploaded the demo (with source code) to the fan games section.