MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON EXECUTIVE SUMMARY: Abstract of game One of the nations most popular games, Trivial Pursuit, now has a new makeover with multimedia. Players will play the multimedia version which will ask questions from different categories such as Cinema, Music, Art, and People, by playing and displaying video clips, avi’s, audio wave sounds, and bitmap images from memorable music videos, movies scenes, sports events, historical places, etc. The game will challenge even the best trivia enthusiast with questions at different skill levels and multimedia in various forms. The game is timed and up to four players can play at their own level, Novice, Smart Guy, and Trivia Expert where the questions will be in a difficulty range corresponding to the players skill level entered before the game starts. There are many unique options and features which make the game different and better than the board game. Game genre: The game genre is in the category of interactive game shows such as Jeopardy and You Don’t Know Jack. Game Play and Appearance: The game plays as follows: First, the players sees a splash screen which then leads them to the player information screen (form) which gathers the number of players playing, the names of the players, their skill level, and the number of points they want to play up to etc. The game then loads the questions from a database which contains all the information about each question including the difficulty level and all the different answers to choose from. The game has the play option of multiple choice or text answer by the player. The players also have the choice of choosing the number of points they want to play up to and the amount of time allowed to answer each question and whether a player can lose points for answering a question incorrectly. The game includes special features: replays and hints/removes. Each player gets three replays that they can use—they can view a scene, video clip, or hear an audio clip again in the event that the scene or audio clip did not ring a bell the first time. In multiple choice trivial pursuit, a player gets two “remove” options—the game will remove an incorrect answer and leave the remaining answers to choose from. In text answer, they will receive text displayed hints in a Hint box. Each player gets three hints that they can use and use at 1 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON most two hints per question. There are many play and option settings as discussed in the Game Specification. Once the game starts, each player will receive a random question generated by the program. The program contains logic that ensures that no question is asked more than once. Most questions will have a multimedia aspect to them—either a video clip, audio wave file, and/or a bitmap image will be shown that goes along with the question. There will be a timer at the top of the screen so that the player can see how much time is remaining. Once the timer gets to 0, a “Time Up” message is displayed and the players loses the chance to answer The next question will be asked to the next player if there is more than one player. The objective for each player is to get to the target number of points before the other players. Depending on the skill level of the player and whether they play in penalty mode, whereby they can lose points for answering a question incorrectly, it could be challenging to win. Afterwards, the game evaluates their overall performance by calculating their score percentage, the number of total questions answered correctly divided by the total number answered to win. If only one player is playing, once the total points is reached, the game goes directly to the results display. Otherwise, a winner animation is shown and then the results display. PRODUCT SPECIFICATION: Production Team: The production team consists of only myself. I designed the GUI forms, Flash animations, and did all the database programming (with the aid of DataEnvironment, Connection, and Command ADO objects). I also designed the database table including all the information and data for all of the fields required for each record. Aside from the programming challenge, I am responsible for providing unique, challenging, and fun questions that are entertaining. While I try to provide a good distribution of questions from different categories, the bulk come from Cinema and Music since they have the most multimedia aspects to them such as music videos, clips, and movie trailers. Target Audience: The target audience is for families (it is a great family get-together game) as well as teenagers and adults, especially those who love trivia and multimedia. The game is designed with the sole purpose for entertainment and fun so that lots of entertaining multimedia 2 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON aspects are incorporated in the game. This includes movie trailers and video clips of popular movies, music videos, and scenes of memorable places, people, and events. Game Play Time: The game play time will vary depending on the number of players and the skill level of the player. On average, the game could take anywhere between 10 minutes to 25 minutes assuming two players who play up to 75 points (each question is worth 5 points and they lose two points for answering a question incorrectly (in penalty mode), and it takes on average 15 seconds to respond to each question (each player has 30 seconds to respond to a question before they lose there turn. The game also includes challenge questions which could increase or decrease the time play since a correct answer is worth 10 points and an incorrect answer loses 7 points. Production Tools: The game was developed in Visual Basic 6.0 Enterprise Edition in Microsoft Visual Studio. All GUI forms of the game were developed with VB design tools including built-in Components such as picture boxes, labels, buttons, list boxes, text boxes, etc. as well as external ActiveX components, controls, and references including timers, Windows Media Player, and Flash Players. The game interfaces with a back-end database developed in Microsoft Access using Active Data Objects (ADO), i.e., the DataEnvironment object, which simplifies the database programming due to the built-in connection and driver support. The multimedia avi, wave, and bitmap files were taken from selected Internet sites. Flash 4.0 is used for the Splash screen at the beginning of the game as well after the game in both the winner animation (if a player wins and more than one player is playing), the animation if the player loses to the computer, and the ending credits form which acknowledges all of the film and music companies who own the clips and copyrights of the pictures, video, and sound clips used in the game. USER GUIDE: Installation: To install the game, click the Setup Icon on the CD-ROM. The installation wizard will create all the directories and copy all the files to the correct directories and 3 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON subdirectories including all of the multimedia files, bitmaps, dlls, and ActiveX components (.ocx files) needed. To start the game, go to (1) Start, (2) Programs, and (3) Click on Multimedia Trivial Pursuit which will start the executable. The game requires approximately 650 MB of free disk space to run the game from the hard drive and runs on Windows Me/2000. How to Play the Game: T.he game requires interaction and use of a mouse. The player must first enter the number of players by selecting the number of players from the listbox in Form 2. Form 2. Click Number of Players The next form, Form 3, includes player information and game options. Each player must enter their name and select their skill level. By default, all players are at the Novice level. In the play options, they can select from the different options, total points played to, multiple choice or text play mode, background sound effects, penalty mode, computer play, computer skill level, and whether to play all question levels (Play All Level Option). If no options are selected, the game will use all the default settings—multiple choice mode, timer at 30 seconds, no computer play, Novice level playing from all categories. 4 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON Form 3 User Information and Play Options After clicking the Next button, Form 4 is displayed. The user selects the categories that they want to play from (by default the game will play from them all). They can also set the timer options—“on” or “off”. If the timer is on, they can set the time amount, 15 or 30 seconds, as well as whether to play in Speed Play mode. After all the play settings and options have been set, the game begins. 5 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON Form 4 Category and Timer Options In multiple choice mode, the player will see four multiple choice answers. The player clicks on the answer that they think is correct. Figure 1 shows the game interface in multiple choice mode. If the player is correct, a pop message will say “Correct” and their score will increase by 5 points. If the player is incorrect, a pop-up message will say “Incorrect” and display the correct answer. If the player is playing in penalty mode, they will lose 2 points. If they are not, they will not lose any points. If more than one 1 player is playing (including the computer), the game will then ask the next player their question. After all other players have been asked their questions, it will be player 1’s turn again. If the computer is playing, the a message box will display what answer the computer has chosen and then answer message box indicating whether the computer is correct or incorrect. The score, time, and category of the question is displayed in the upper left of the game interface. The user can adjust the volume level of the sound by moving the volume control slider in the lower right. 6 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON Figure 1 Game Interface in Multiple Choice Mode Each player can click on Hints to have an incorrect answer removed in multiple choice mode. Each player receives a total of 3 Hints for the entire game. They will be notified with a message that they have no more hints if they click on Hints when they have none. The user can also click on Replays to replay a video clip or sound clip. Each player has a total of 3 replays available to them. In text answer mode, the player enters their answer in the text answer box and clicks the Submit button to submit their answer when finished. Figure 2 shows the game interface in text answer mode. The game logic is case insensitive, but is sensitive to the spelling—the 7 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON answer must be spelled correctly or it will be incorrect. If the computer is playing, the computer will type (display) its answer in the text answer box. If a player is correct, just as in multiple choice mode, a pop-up message will display “Correct”. Otherwise, it will display “Incorrect” along with the correct answer. The game will alternate between players in a round robin when asking questions to each player. Figure 2 Game Interface in Text Answer Mode 8 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON If the player clicks on Hints, a Hint display box will display a text hint if one exists. The player can receive a maximum of 2 text hints per text answer question. Some questions may only have one text display hint, some may have two, and some may have none. If a question has none or only one, a text message saying “There are no more hints for this question” will be shown. Challenge Questions During the game, a player may be asked if they want to accept a challenge question. The player will be asked if they want to accept and receive a challenge question. If they click “Yes”, then if they get the answer correct they will get 10 points instead of just 5. But if they are wrong, they will lose 7 points regardless of whether they are in penalty mode or not. If they don’t accept, then the question is asked just like all the other questions—a correct answer will get 5 points and an incorrect answer in penalty mode will lose 2 points. Essentially, accepting to receive a challenge question is a way for the player to get closer or farther from the total number of points needed to win by “gambling” on whether they will answer the next randomly generated question correctly or not. In either multiple choice or text mode, a player wins by reaching the total number of points (selected at the beginning of the game) first. If more than one player is playing, the player will be notified with a “You win!” message. The winner will then hear clapping from the audience (a sound clip) and see a Flash Animation announcing that they have won. Afterwards, a Results Display form, shown in Figure 3, will display the results of all the players as well as comments about the overall performance of each player based on the percentage of questions they answer correctly. If only one player is playing, then the game will say “Total points reached” (since they are not competing against anyone) and then 9 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON display the results. Figure 3 Result Form After the Results Form, the credits form will be shown acknowledging all of the film and music companies that own the copyrights of all video and music clips used throughout the game. 10 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON GAME SPECIFICATION Game Play The game has many options and features to make the game more fun and challenging. The first major feature is the play mode: multiple choice or text answer. If the player choosers multiple choice, they will receive 4 multiple choice answers to choose from. The answers will appear on buttons that can be clicked on with a mouse. In text answer mode, the user will type their answer in a text box and click a submit button when finished. The game will compare the player’s answer with the correct answer stored in the database. If they match the answer is correct. If not, it is wrong. In this first version of the game, the player must enter the identical spelling of the answer in the database since no dictionary look-up feature is used. The answers must be identical though the it is not sensitive to lower and upper case letters since the logic of the game converts all answers to upper case. The second main feature is computer-play. If only one person decides to play, they can also play against the computer which can play in both multiple choice and text mode. In both modes, a pop-up message box will tell what choice the computer has made. In multiple choice mode, the focus will then go to the button with that answer. In text mode, the answer will appear in the text box. The forms displayed are as follows: The player initially sees a load-up Splash screen with cool multimedia effects to get them interested. The player then enters the number of players. Once the number of players is selected, each player must enter their name and skill level. The game mode must be agreed by all players. The game can be played in multiple choice format or text mode in which case each player must type their answer. The latter mode is much more challenging and requires the player to correctly spell their answer. Later versions of the game will have a spell checker and compare the players answer with similar spellings if it is close in spelling, but not quite right. The players must also pick the number of total points to play up to—the first to reach the total number of points wins. Interface: Figure 1 shows the interface mockup of a typical question in multiple choice mode— the player gets it wrong and a pop-up message box tells the player the correct answer. What makes the game fun is that there are many questions and all of them have a multimedia aspect to them—via video, audio, and/or bitmap images. 11 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON Storyboards and Character Bibles Each player is their own character. The plot is simple—win the game by earning the target number of points first. If you are playing by yourself, you will be evaluated on your performance at the end of the game. While the game doesn’t have perhaps the action of Quake or Doom, it is just as fun if not more so due to all the multimedia files incorporated into the game. Each question is uniquely designed with the proper images, scenes, and audio. The game does not have a story line or any character bibles. But it does have a unique use and integration of multimedia that few games have. Level and Option Modes: The game has several play option modes to make the game more fun and more challenging as detailed and discussed below. The game can be played with up to four players. One player can also play against the computer. Play Mode: The main play option is multiple choice or text answer mode. In multiple choice mode, the player is presented with four multiple choice answers (displayed on command buttons) and chooses their answer by clicking on the button with the displayed answer. If their answer is correct, a message box will display “Correct”, otherwise a message box will display, “Incorrect” and also display the correct answer. Version 1.2 of the game will include 4 and 5 multiple choice modes—the choice to have 4 possible answers or 5. The probability of a random guess as correct in 5 choice mode is lower—20% and will make the game slightly more challenging. If the player chooses text answer mode, the user interface will display a text answer box and a submit button. The player types in their answer and clicks the Submit button when finished. The same message box will appear for a correct or incorrect answer as in multiple choice mode. Hint Option: If hints are enabled, the user can click on the Hint button to get a clue about the correct answer. In multiple choice mode, an incorrect answer (button) is removed, i.e. it’s Visible property is set to false. In text mode, a label appears with a text clue. The user can get use up to 2 hints per question and receives a total of 3 hints per game 12 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON Total Points: The total number of points to played for can be changed by clicking on the desired number in the total point list box. The player can choose to play between 10 and 100 points. Each question is worth five points. Penalty Option: In penalty mode, if turned on, will deduct 3 points for each incorrect answer. If turned “off”, no points will be deducted for an incorrect answer. Skill Option: The skill level chosen for a player determines the difficulty level of the questions they are asked. The player can elect to play at the Novice, Smart, or Expert level—questions from the Expert level will be much hard than those at the Novice level. Questions from the Smart level are of medium difficulty—between easy and hard. While there is subjectivity as to what constitutes an easy, medium, or difficult question, I have tried to categorize questions that I think the average person would find easy, medium, or difficult, respectively. Finally, as the player gets closer to the total points needed to win, the questions will get harder for all players to make the game even more challenging. By default, each player is set to Novice. Play-All Mode: If Play-All Levels mode is selected (by clicking the checkbox), the computer will ask questions from all skill levels. This is for the player that wants a variation in the difficulty of the questions over the course of the game. Timer Option: The player can elect to play timed—players can choose to be timed 15 or 30 seconds for each question. When time is up, the correct answer is displayed and the next question is shown. The player can also elect to play in Speed Play mode—a speed timer that starts at 60 seconds and quickly counts down to 0. By default, the timer is “on” and set to 30 seconds. Background Sound Effects: The user can turn sound effects “on” or “off”. If “on”, background music (from Who Wants to be a Millionaire) will played before each question. By default, this option is “off”. Computer Play: If only one player is playing, they can choose to also play against the computer. By default, this option is not enabled unless only one player is chosen. If it is turned off, the computer skill levels options are enabled. In this mode, the computer’s skill level can be set 13 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON to Novice, Smart, or Expert. the default computer skill is Novice. A rule-based expert system determines the probability of the computer being correct based on the skill level chosen for the computer. If the computer is selected to be a novice, then the computer has 1/3 chance to have a 25% of being correct, a 1/3 chance to have a 33.3% chance of being correct, and 1/3 chance to have a 50% chance of being correct. This increases the randomization of the computer since the player never knows the actual likelihood of the computer being correct. However, if the computer is a novice, it has an expected chance of E[X] = (1/3)(1/4) + (1/3)(1/3) + (1/3)(1/2) = 1/12 + 1/9 + 1/6 = 0.361 = 36.1% of being correct over the course of the game, where X is an indicator variable such that X = 1 if the compute is correct and X = 0 if the computer is incorrect. If the computer is at the Smart Level is has an expectation of E[X] = (1/2)(1/3) + (1/2)(1/2) = 0.4166 41.7% of being correct over the course of the game, and if it is on Expert Level, is always has a 50% of being correct. If the player is in Play-All mode where questions from any skill level can be asked, then computer has a probability of being correct of: E[X] = (N/T)(0.361) + (S/T)(0.471) + (E/T)(0.5) where N = the total number of novice level questions that are asked, S = the total number of smart level questions that are asked, E = the total number of expert level questions that are asked, and T = the total number of questions that can be asked where T = N + S + E. For example, if N = 4, S = 7, E = 6, then the expected percentage of questions the computer will answer correctly is E[X] = (4/17)(0.361) + (7/17)(0.471) + (6/17)(0.5) = 0.455 = 45.5%. This number will change depending on N, S, and E. If we assume a fair distribution of the questions from each skill level such that any question from any skill level has an equal chance of being chosen in Play-All mode, then E[X] = (1/3)(0.361) + (1/3)(0.471) + (1/3)(0.5) = 0.444 44.4%. To make the game more challenging, if in fact the player is in Play-All mode and if the computer gets an expert level question, it will then have a 1/2 chance of being correct with probability 1/2 and a 1/2 chance of being correct with certainty. Thus, E[X] = (1/3)(0.361) + (1/3)(0.471) + (1/3)(0.75) = 0.527 = 52.7%, being correct on average more than 50% of the time. If the computer is 15 or more point behind, it will get it’s current question correct with certainty to add a little artificial intellgence to the game. 14 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON Category Selection: The question categories include Cinema, Music, People, Art, and Geography. The player can select to play from all categories or select only those categories that they want to play from. In Version 1 of the game, most of the questions come from Cinema and Music and because there are a limited number of questions (250), the game will include those categories. Version 1.2 will allow the player to be more selective since there will be more questions. By default, all categories are played (the Play All Categories check box is checked). Game Features The game has some special features: Did You Know… After a question is answered, the game will give the correct answer as well as some additional information or tidbits about the topic of the question if there are any. The additional facts are highlights about the subject of the question just asked and adds entertainment value to the game. A pop-up form will display more information and/or bitmaps related to the question. The form will automatically close itself. . Volume Control The game also includes a volume control so that user’s can control the volume level. The control is a slider. As the position of the slider tab moves left, the volume is reduced and as the slider tab moves right, the volume level increases. Animation If a player wins by reaching or exceeding the total points played for first, they will be taken to a winner form that will have clapping in the background and a Flash animation. If the user plays against the computer and loses, they will see a special Flash Animation poking fun at them (they lost to a computer) before going to the Results form. DESIGN SPECIFICATION: Implementation Details Multimedia Trivial Pursuit uses a GUI front-end developed in Visual Basic that contains various buttons and controls for the user to interact with. In particular, in multiple choice mode, there are four multiple choice answer buttons to choose from as shown in Figure 1 and in text answer mode there is a text box with a Submit button as seen in Figure 2. 15 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON The player can also view the timer shown in the upper left hand corner which is ticking down to 0. The player’s score appears in the upper right hand corner and is updated after each question is answered. Players have the option of being penalized if they answer a question incorrectly by playing in penalty mode. The game logic keeps track of each player’s score, name, number of correct questions, number of incorrect questions (through use of an array of player records data structure), questions asked, remaining time for each question, and handles for opening, buffering, and loading of wave and video data files. The game makes sure that the questions asked are commensurate with the player’s skill level. I had the responsibility of coding the difficulty level of each question into the Level field of each question record. The game interfaces with a Microsoft Access database as a back-end through a DataEnvironment ADO object which is an object that facilitates the connection and opening of the database for the reading of records. The database contains the following information for each record: question, 4 possible answers, the correct answer, type of multimedia used, path of multimedia files, difficulty level of question, additional info, and hints (for text mode). The database structure is detailed in the Design Specification. Most fields are text (VARCHAR). The game makes extensive use of Win32 API dlls for the video and audio programming. The dlls are imported into the game through Module libraries. Classes include VideoPlayer and WavePlayer objects to open, control, and close video and audio devices. Game Challenges: There are a couple of major issues that made developing and implementing the game quite challenging. First, Visual Basic does not have an inherent multithreading model like C++ such as the Sleep, ThreadProc, and Wait thread functions. In fact, it does not have any built functions to deal with thread synchronization and resource locking. Consequently, the synchronization of the loading of questions and answers from the database, while simultaneous loading, opening, and playing sound, bitmaps, and avi files became the main implementation detail. There were threading issues with the timer events. The game utilizes multiple timers and timing events which are running concurrently, in the background, with the running of 16 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON other processes, i.e., loading of wave files. Preventing deadlock for the simultaneous acquisition of resources like memory between different processes was necessary. Performance degradation in the loading of large files at run time was a common problem. It turns out, however, that if the files are located on the hard drive and not read from a CD-ROM or loaded from a dll or embedded resource, the game runs smoothly and there are no racing conditions. This can be attributed to the fact that the time to locate the file, load and open it, is significantly reduced if a file pointer does not have to search a CDROM or dll. This comes at the expense of distributing an enormous number of files and requiring a huge amount of disk space, at least 650 MB. In Version 1.2, use of dll’s will be used in conjunction with Win32 API threading calls. 17 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON Architecture: A flow diagram of the design architecture is shown: Multimedia Directory Wave Files Input: Question Responses VB GUI Forms Output Video AVI and MOV files Bitmap Files Game Logic And Data Processing (Display Questions And Answers) DataEnvir onment ADO Microsoft Access DB Modules MCI Registry Functions Video Player Win32 dlls winmm.dll Class Modules Utilities Wave Player Helper Modules Timer As can be seen, the main game logic engine must handle the interface with the database, the Win32 dlls, modules, class modules, and the interface with the user GUI. Data Structures and Interface Definition The main data structure is the Player data structure that is a record of all of the Player’s attributes. The game uses an array of records to store each player’s information and attributes: 18 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON Type PlayerRecord PlayerName As String // Name of Player SkillLevel As String // Play of Level of Player (Novice, Smart, Expert) Replays As Integer // Number of Replays Available Hints As Integer // Number of Hints Available Score As Integer // Current Score of Player NumCorrect As Integer // Number of Correct Questions Answered NumIncorrect As Integer // Number of Incorrect Questions Answered End Type The backend Access database contains the following table: Field Question Number Question Answer 1 Answer 2 Answer 3 Answer 4 Correct Answer Media Type Meida Path Bitmap 1 Bitmap 2 Category Media Constant Additional Info Hint 1 Hint 2 Datatype Number VARCHAR(80) VARCHAR(50) VARCHAR(50) VARCHAR(50) VARCHAR(50) VARCHAR(50) VARCHAR(50) VARCHAR(50) VARCHAR(50) VARCHAR(50) VARCHAR(50) Number VARCHAR(120) VARCHAR(120) VARCHAR(120) Comment Primary Key Contains Question Answer Choice 1 Answer Choice 2 Answer Choice 3 Answer Choice 4 Answer Choice Wave OR Avi Flag Path of Wave or Avi file Name of Bitmap to Display Bitmap to Display in AddInfo Question Category Cross References DLL Ref Tidbit Additional Info Hint 1 for Text Answer Hint 2 for Text Answer Note: VARCHAR = STRING The fields are referenced in the game using the DataEnvironment ADO (ActiveX DataObject). For example, to retrieve the question, the following construct is used DataEnvironment1.rsCommand1.Fields(2).Value since Field 2 is the Question field. Pseudocode for Algorithms In main game loop, the game goes through the following algorithm: Initialize all global variables and each player’s record structure Initialize all Question Flags = False // Questions have not been asked player_num = 0 Do Until total points = True If player_num > 1 Then // if there is more than one player, go to next player player_num = player_num + 1 End If 19 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON If player_num > 4 Then // it is player’s 1 turn again player_num = 1 End If Refresh Picture Control If wave or avi files playing // playing from previous question Stop playing Reset wave and video player End If QuestionNum = RandomNumber(1 To RecordCount) If Question Flag = True Do Until Question(questionNum).Flag = False questionNum = Random Number(1 to RecordCount) Loop End If Move to Record questionNum // go to question # questionNum Start Timer // start timing of question Display Question(questionNum) Question(questionNum).Flag = True // Question has been asked Question_cnt = Question_cnt + 1 // increment number of questions asked // Randomly Display Answers Display Answer 1 Display Answer 2 Display Answer 3 Display Answer 4 // Check whether to play a wave or avi file If DataEnviroment.rsCommand.Field(8).Value = “wav” or “avi” If Database.Field(8).Value = “wav” Then Retrieve wave file name //in DataEnvironment.rsCommand.Field(9).Value Load and open wave file with Wave Player object Play wave file End If If Database.Field(8).Value = “avi” Then Retrieve avi file name // in DataEnvironment.rsCommand.Field(9).Value Load and open avi file with Video Player object Play avi file End If // Check whether to display a bitmap If DataEnvironment.rsCommand.Field(10).Value <> Null Retrieve Bitmap File // in DataEnvironmentl.rsCommand.Fields(10).Value Load Picture End If // Get Player’s Response If Timer <> 0 Then If play_mode = Multiple Choice Then If Player(player_num).Choice = Correct Answer Player(player_num).Score = Player(i).Score + 5 20 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON Player(player_num).NumCorrect = Player(player_num).NumCorrect Display Correct Message Else If penalty_mode = True Then Player(i).Score = Player(i).Score – 2 End If Player(player_num).NumIncorrect = Player(player_num).NumIncorrect + 1 Display Incorrect Message + Incorrect Answer End If Else // play_mode =Text Answer If Player(i).TextAnswer = Correct Answer Player(i).Score = Player(i).Score + 5 Player(i).NumCorrect = Player(i).NumCorrect Display Correct Message Else If penalty_mode = True Then Player(i).Score = Player(i).Score – 2 End If Player(i).NumIncorrect = Player(i).NumIncorrect + 1 Display Incorrect Message + Correct Answer End If Else Display Time Up Message Display Correct Answer End If Loop Display Winner Animation and Results Form The game incorporates the following simplified algorithm1 for the computer AI // computer is behind, so make sure it guesses the corret answerIf Player(player_num 1).Score - Player(player_num).Score >= 15 Then i = correct_ans Choose MultChoice (i) Else Select computer_skill level “Novice” : num = random number between 1 and 4 // 25% chance of being correct Choose answer num “Smart” : num= random number between 1 and 3 Check that correct answer is one of the answers in 1 to 3 // 33.3% chance Choose answer num “Expert” : num = random number between 1 and 2 Check that correct answer is one of the answers in 1 to 2 // 50% chance Choose answer num End If 1 The actual code is quite long and somewhat complex so I have included a simplified version. 21 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON The game form display flow and game logic flow diagrams are shown below: Flow of Game Forms Splash Form Display Splash Screen Form1 Form2 Display Multimedia Trivial Pursuit Animation with Flash Player Choose Number of Players in List Box Form3 Enter Player Information Text Box Option Buttons Enter Play Mode Options Player Name Play Mode: Multiple Choice or Text Choose Player Skill Option Buttons Option Buttons Penalty Mode Computer Play Option Buttons Computer Skill Option Buttons Play-All Levels Check Box Form 4 Check boxes Form 6 Choose Timer Options Choose Categories Tidbits without Picture Timer Mode Option Buttons Speed Play Option Buttons Form 5 Game User Interface Form 7 Tidbits with Picture Form 8 Display Winner with Flash Player Form 9 Results Form 10 Credits 22 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON Flow Chart of Game Logic Initialize all global variables and play settings No Generate random question number Yes Has Question been asked before ? No Display Did you Know ... Tidbits About Question No Yes Yes Load and Display question and answers (if multiple choice mode) Does question have any tidbits info? Update Players Score += 5 Update Num Questions Correct += 1 Are wav or avi files used with question? Yes Is player's answers correct? No Update Num Questions Incorrect += 1 No No Display Winner Animation and Results Is penalty mode on? Is player's score >= total_score Yes 23 Yes Update Players Score -= 3 Update Num Questions Incorrect += 1 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON The game uses two main structures for playing video and wave files: a Video Player class and a Wave Player class2. Each class contains properties (attributes) and methods which make use of Win32 API functions: (1) Private Declare Function mciSendCommand Lib "winmm.dll" Alias "mciSendCommandA" (ByVal wDeviceID As Long, ByVal uMessage As Long, _ ByVal dwParam1 As Long, dwParam2 As Any) As Long (2) Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long GetClienmtRect is used in the Center Function and mciSendCommand is used to open, close, play, pause, and stop the Video Player with MCI_ commands. For example, in the Play Function MCI_PLAY is passed in. Private mlngDevID As Long // Device ID Public Sub Play() Dim lngRet As Long Dim mpp As MCI_PLAY_PARMS If mlngDevID Then lngRet = mciSendCommand(mlngDevID, MCI_PLAY, 0&, 0&) // command to play If lngRet <> 0 Then Err.Raise lngRet, "VideoPlayer::Play", _ // traps error dhMCIError(lngRet) End If End If End Sub The complete Video Player class is: Class Video Player { Methods: Private Sub OpenDevice(Optional strFile As String) // opens device Private Sub Class_Initialize() // calls open device Private Sub CloseDevice() // closes device Public Sub OpenFile(AVIFile As String) // opens AviFile Public Sub Play() // plays video clip Public Sub StopPlaying() // stops the play of video clip Public Sub Center() // centers video clip in center of form Properties: Property Get Filename() As String // gets name current playing file 2 The classes are reusable classes developed by Ken Getz and Mike Gilbert from the VBA Developer's Handbook, Sybex (1997). 24 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON Property Get IsPlaying() As Boolean // determines if video clip is playing Property Get Length() As Long // gets length of video clip Property Get hwnd() As Long // gets current window handle of videoplayer Property Let hwnd(hwnd As Long) // sets current window handle Property Get Stretch() As Boolean // tests if video clip gets stretched when window resized Property Let Stretch(fStretch As Boolean) // sets stretch property } The class definition for the Wave Player is: class Wave Player { Methods: Private Sub OpenDevice(Optional strFile As String = "") // open wave player device Public Sub OpenFile(WaveFile As String) // Open wave file Public Sub Play(Optional StartTime As Long, Optional StopTime As Long) // Play wave Private Sub CloseDevice() // close wave player Public Sub Reset() // reset wave player by calling OpenDevice Private Sub ChangeSetting(lngSetting As Long, lngNewValue As Long) // change // bitsperchannel Properties: Property Get Wait() As Boolean // gets wait flag Property Let Wait(bWait As Boolean) // sets wait flag Property Get Position() As Long // gets position of Property Get Length() As Long // gets length of wave file Property Get Filename() As String // gets wave file name Property Get Channels() As Byte // gets number of channels Property Let Channels(byteChannel As Byte) } The Wave Player makes a lot of use of the dhMCIStatus function: Function dhMCIStatus(lngDevID As Long, lngItem As Long, Optional lngAddlFlags As Long = 0, Optional bytTrack As Byte = 0) As Long ' Returns the results of the MCI_STATUS command. ' In: ' lngDevID ' Valid MCI device ID. ' lngItem ' MCI_STATUS item (e.g. MCI_STATUS_POSITION). ' lngAddlFlags (Optional, default = 0) ' Additional flags to pass (e.g. MCI_TRACK). ' bytTrack (Optional, default = 0) ' If status applies to a track, the track number. ' Out: ' Return Value: 25 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON ' Status value as a long integer. ' Note: ' Refer to the list of MCI constants for status items. ' Example: ' lngPosition = dhMCIStatus(lngDevID, MCI_POSITION) Dim mst As MCI_STATUS_PARMS Dim lngRet As Long ' Make sure device ID is valid If lngDevID Then ' Set values of MCI_STATUS_ITEM structure With mst .lngItem = lngItem .lngTrack = bytTrack ' Call mciSendCommand lngRet = mciSendCommand(lngDevID, MCI_STATUS, _ MCI_STATUS_ITEM Or lngAddlFlags, mst) ' If successful, return lngReturn ' member of MCI_STATUS_ITEM structure If lngRet = 0 Then dhMCIStatus = .lngReturn End If End With End If End Function ErrorHandling: The game incorporates an error handling function, dhError,throughout the game, rather than just use Goto OnError statements—when loading questions, answers, wave files, avi files, and bitmap: Function dhError( _ Optional strProc As String = "<unknown>", _ Optional fRespond As Boolean = False, _ Optional objErr As ErrObject) _ As Boolean Dim strMessage As String Dim strTitle As String Dim intStyle As Integer 'If the user didn't pass an ErrObject, use Err If objErr Is Nothing Then 26 MULTIMEDIA TRIVIAL PURSUIT JUSTIN LONDON Set objErr = Err End If 'If there is an error, process it 'otherwise just return True If objErr.Number = 0 Then dhError = True Else 'Build title and message strTitle = "Error " & objErr.Number & _ "in " & strProc strMessage = "The following error has occured:" & _ vbCrLf & vbCrLf & objErr.Description 'Set the icon and buttons from MsgBox intStyle = vbExclamation If fRespond Then intStyle = intStyle Or vbOKCancel End If 'Display message and return result dhError = (MsgBox(strMessage, _ intStyle, strTitle) = vbOK) End If End Function This allows more customization and control of the error message. Development Environment The game was developed in Visual Basic 6.0 Enterprise Edition. All forms were developed in the Visual Basic Design Environment. Microsoft Access was used for the back-end database. Flash 4.0 was used to design the animations in the introduction, winner, and credit forms by embedding a FlashPlayer ActiveX control. Other ActiveX components used in the game are timers in conjunction with timer events and a slider control for the volume. RAD Game Video and Sound Editing Tool was used to convert Quicktime mov files to avi video format and to convert mp3 sound files to wave format. Microsoft Paint was used to edit all the bitmap images. 27