One of the things I’m enjoying most about writing Galactic Gladiators in Visual FoxPro is discovering things that make me stop and think:
“Hang on… FoxPro can do that?”
The latest one started with BARF.
BARF is the alien who appears on screen and communicates with the player. I’d already been playing around with animating his mouth, but obviously if BARF is going to move his mouth, at some point he really ought to say something.
My first thought was the obvious one: record some speech, save it as WAV files and play the appropriate file when required.
But then I discovered something considerably more interesting.
Visual FoxPro can talk directly to the Microsoft Speech engine.
Because VFP can create and control COM objects, this is remarkably simple. Create the Microsoft speech object, give it some text, and Windows speaks it.
Something along the lines of:
loVoice = CREATEOBJECT("SAPI.SpVoice")
loVoice.Speak("Welcome, Earthling.")
And that’s basically it.
BARF has a voice.
What I particularly like about this is that BARF’s dialogue no longer has to be prerecorded.
Galactic Gladiators can construct something at runtime and BARF can actually say it.
So instead of having a recording saying:
“You have reached level three.”
the game could potentially construct:
“Rob, somehow you have survived level three. Nobody is quite sure how.”
Or comment on the player’s score, lives, performance, what just killed them, or anything else the game knows about.
And because it’s being generated at runtime, I can keep adding ridiculous things for him to say without recording another sound file.
That’s when this stopped being simply “I’ve got speech working” and became another one of those moments where the possibilities suddenly opened up.
BARF could interrupt you.
He could mock you.
He could give instructions.
He could react to particularly bad playing.
He could say different things on different playthroughs.
He could even occasionally say something completely unexpected.
All driven by Visual FoxPro.
There is something wonderfully inappropriate about a development environment most people associate with database applications controlling a spaceship, animating aliens, playing music, supporting a game controller — and now talking to the player through Microsoft’s speech engine.
Every time I think I’ve found Visual FoxPro’s ceiling, I seem to find another trapdoor in it.
And this time an alien called BARF was on the other side.
Unfortunately, now that BARF can talk, the next problem is getting him to shut up.
