|
Features

What I Did During My Summer Vacation: Developing a Game in 13 Weeks
Sound
and Animation
Direct Sound replaced the "Play" function so that multiple audio files could
be outputted simultaneously. In Poker Challenge, each room had background
(ambient) music playing and the poker rooms had three to four large background
music files. While the ambient music was playing, one or two sound effects
could be triggered. In the four player poker room, any of the three animated
characters will chat with the players, therefore a chat audio file had to
be in memory. The following code (using DSutil.cpp,
DSutil.h and DSound.h)
was used to initialize Direct Sound, the needed sound buffers (four background
sound buffers, two sound effect buffers and one character chat buffer) and
a sample of how the sounds were played.
///------ DirectSound Object and Buffers ------//
CSoundManager* g_pSoundManager = NULL;
CSound* g_pBackSound[4] = {NULL,NULL,NULL,NULL};
CSound* g_pSFX1Sound = NULL;
CSound* g_pSFX2Sound = NULL;
CSound* g_pChatSound = NULL;
void InitDSound(HWND hWnd)
{
HRESULT hr;
// Create a static IDirectSound in the CSound class.
// Set coop level to DSSCL_PRIORITY or DSSCL_NORMAL, and
set primary buffer
// format to stereo, 22kHz and 16-bit output.
g_pSoundManager = new CSoundManager();
If( FAILED( hr = g_pSoundManager->Initialize( hWnd, DSSCL_NORMAL,
4, 22050, 16 ) ) ){
MessageBox( hWnd, "Error initializing DirectSound.
Program will now exit.",
"DirectSound
Init", MB_OK | MB_ICONERROR );
exit(1);
}
}
// CREATE THE SOUND EFFECTS #1 AUDIO BUFFER
// flag==1 to test if playing, else overwrite new SFX1 Sound
int NewSFX1Sound(TCHAR *strFileName,int flag) {
HRESULT hr;
if(g_pSFX1Sound){
// testing if sound is playing
if((flag==1) && g_pSFX1Sound->IsSoundPlaying())return(1);
g_pSFX1Sound->Stop();
}
if(strlen(strFileName)>0){
SAFE_DELETE(g_pSFX1Sound);
// Sound if existed has stopped and has been deleted
hr = g_pSoundManager->Create( &g_pSFX1Sound,
strFileName, 0, GUID_NULL, 1 );
}
return(0);
}
// PLAY THE SOUND EFFECTS #1 AUDIO BUFFER
void PlaySFX1()
{
HRESULT hr;
DWORD dwFlags = 0L; // set to DSBPLAY_LOOPING if looping
needed g_pSFX1Sound ->Stop(); g_pSFX1Sound ->Reset();
Hr = g_pSFX1Sound->Play( 0, dwFlags );
}
In the
four player poker room, the the opponents are highly animated characters
designed to chat at 15 frames per second. Each character has seven different
poses and each pose has five different eye frames and seven different
mouth frames. The first time a player enters the four player poker room,
all of the required graphics (poses, mouth and eye frames) are loaded
into memory as surfaces. Using fast blitting from surface to screen and
a 67 millisecond timer (1/15 of a second), the animations mimicked the
chat audio files. Every chat line for each character was broken into a
1/15 of a second "pose, mouth, eye" setting which became the structure
used to describe character animation. A zero for the eye or mouth position
meant to use the pose's eye or mouth. The audio lines were then mapped
to various response categories like "raise", "fold," and "call."
// ANIMATION: POSE, MOUTH, EYE FRAMES
char Pchar_buff[10][1000][3]={
//YVETTE: "Wow,good hand"
{{1, 3, 0},{1, 7, 0},{1, 7, 5},{1, 1, 5},{1, 1, 5},{1, 1, 5},{1, 1,
5},
{1, 1, 5},{1, 1, 5},{1, 6, 5},{1, 7, 5},{1, 7, 5},{1, 7, 0},
{1, 3, 0},{1, 3, 0},{1, 3, 0},{2,10, 0},{2, 6, 5},{2, 6, 5},{2,10,
5},
{2, 3, 5},{2,10, 5},{2, 1, 5},{2, 1, 5},{2, 1, 5},{2, 1, 5},
// CORRESPONDING AUDIO FILES
char CharAudio[10][30][30]={
{ // Yvette
{"\\Yvette\\GOODHAND.WAV"}, {"\\Yvette\\likethat2.WAV"},
void LoadTalkerPic(int pl, int st) // pl is player, st is
start line
{
int stoffset=0,i,xpose,xmouth,xeyes;
BOOL flag; DWORD startTime=0;
DWORD Msec7=67; // 67 ms (67/1000) is close to 1/15
of a second
RECT prc;
CurPose= 9; // force a change
CurMouth= 0;
CurEyes= 0;
// Locate the line to have character say
for(i=0;i st;i++)
Stoffset+= Pchar_offset[pl][i];
// Have character perform 1/15 second animation: pose, mouth and
eyes
for(i=0;i>Pchar_offset[pl][st];i++){
// Get from the above chat structure the pose
xpose= (int)Pchar_buff[pl][stoffset+i][0];
Xmouth=0;
xeyes= 0;
// Get from the above chat structure the mouth frame if((int)Pchar_buff[pl][stoffset+i][1]>0)
xmouth= (int)Pchar_buff[pl][stoffset+i][1]+5;
// Get from the above chat structure the eye frame if((int)Pchar_buff[pl][stoffset+i][2]>0)
xeyes= (int)Pchar_buff[pl][stoffset+i][2];
// Make the character talk for 1/15 of a second MakeCharTalk(0,pl,xpose,xeyes,xmouth);
// Start the audio after the first frame is displayed
if(i==0){
if(strlen(CharAudio[pl][st])>0){
strcpy(WAVfname,".\\WAV");
strcat(WAVfname,CharAudio[pl][st]);
NewChatSound(WAVfname,0);
PlayChat();
}
} // i==0
} // i loop
}
Addictive
Gaming Techniques
Poker Challenge has several interesting gaming concepts that draw the
player deeper into the game play. Players start off with $2,500 and no
reputation points on the first level of the Poker Palace. They can enter
the tournament or non-tournament poker room, view the prize room (initially
it's empty), see the elevator (initially blocked by a bouncer), play slots
and view their statistics. Curiosity and fun game play will propel the
player to play in the non-tournament poker room to raise enough money
to enter the tournaments. Through winning at tournaments, player earns
reputation points, valuable prizes and money. As they increase their reputation
points, the other floors open up where the opponents play tougher and
high stake games are available. Eventually, through game play and word
of mouth, players will learn about a secret poker game for $2.5 million
and the World Championship which is only achievable through winning enough
reputation points from the third floor of the Poker Palace. As the players
win tournaments, the prize room will fill up. Until then, players will
wonder what valuable prizes go in the prize room slots. There are also
a few hidden "Easter eggs" for players to discover. The statistics tables
are also updated as the player enters each poker room. In the non-tournament
rooms the player can decide which poker variation to play. While in a
tournament room, only one variation of poker is played for the 20 hands.
The humorous and well-animated 4-player mode is very addictive and immerses
the player into the poker atmosphere. The slot room is an extra feature
that promotes Phantom EFX's first title. Hopefully this winter's holiday
season, many players will enjoy what I did this summer.
______________________________________________________
|