1. Trang chủ
  2. » Công Nghệ Thông Tin

microsoft visual basic game programming with directx phần 6 pdf

57 1,1K 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 57
Dung lượng 3,99 MB

Nội dung

.NET Game Programming with DirectX 9.0 by Alexandre Santos Lobão and Ellen Hatton ISBN:1590590511 Apress © 2003 (696 pages) The authors of this text show how easy it can be to produce interesting multimedia games using Managed DirectX 9.0 and programming with Visual Basic .NET on Everett, the latest version of Microsoft's Visual Studio. Table of Contents .NET Game Programming with DirectX 9.0 Foreword Preface Introduction Chapter 1 - .Nettrix: GDI+ and Collision Detection Chapter 2 - .Netterpillars: Artificial Intelligence and Sprites Chapter 3 - Managed DirectX First Steps: Direct3D Basics and DirectX vs. GDI+ Chapter 4 - River Pla.Net: Tiled Game Fields, Scrolling, and DirectAudio Chapter 5 - River Pla.Net II: DirectInput and Writing Text to Screen Chapter 6 - Magic KindergarteN.: Adventure Games, ADO.NET, and DirectShow Chapter 7 - Magic KindergarteN. II: Animation Techniques and Speech API Chapter 8 - .Netterpillars II: Multiplayer Games and Directplay Chapter 9 - D-iNfEcT: Multithreading, Nonrectangular Windows, and Access to Nonmanaged Code Bonus Chapter Porting .Nettrix to Pocket PC Appendix A - The State of PC Gaming Appendix B - Motivations in Games Appendix C - How Do I Make Games? Appendix D - Guidelines for Developing Successful Games Index List of Figures List of Tables Technical Tips for Coding Adventure Games As we've discussed previously, before writing the first line of code in any game, it's very important to generate a project in which we describe the game goals, details about the gameplay, design, etc. But when coding an adventure game, this kind of work is even more important. Possibly the most critical item we must take into account when planning an adventure is the story. Of course the interface must be user friendly, or users may abandon the game before they've had enough time to understand the story, but the story is what will keep the user playing until the end of the game and produce enough interest to justify sequel games. Many factors contribute to create a good story: the story flow, a good ending, deep characters with strong personality, well-thought-through and logical puzzles (neither too easy, nor too hard), and good dialogs. Making a good adventure game is a challenge that can be compared to making a good movie. Here's a summary of the ten steps necessary to creating an adventure game. Of course this is not an exhaustive list, but it'll help you when creating your first adventure. After that, you'll be able to incorporate the extra steps you think are necessary, according to your own experience. Define the main focus of your story: comedy, drama, terror, or what? 1. Define the game's goal: Will the player save the world? Will he or she defeat an enemy? Will the player find a treasure? 2. Choose the genre of graphics you'll use: Will they be realistic, cartoonish, or surreal? Defining the graphics genre early on will help your artistic team to start thinking about different possibilities when the next steps are discussed. 3. Write the game flow: How will the story go from beginning to end? 4. Describe game characters: Which characters will be presented? Which ones will be there to give playing tips? Which ones will only add color to the surroundings? Which will be friendly and which will be hostile? For each important character, you must define the character's background: What is his or her main motivation? What are his or her most important characteristics? 5. Specify the screens or rooms: What will be the game locations that the player will move across? Basically, we must read the game story and create "shots," breaking it into discrete pieces, one for each location. 6. Create the puzzles and objects: These objects are usually very closely related. Logical puzzles are the key to a good adventure. You know that a specific adventure fails when you see the user is stuck, trying each object in the inventory with all objects on screen to find a solution. This is very common, and the game developer must create a balance between logical puzzles and easy ones to make the game more appealing. 7. Write the game dialogs: It's in these dialogs that the player will discover the background of each of the characters. In some games a player might run into a muscly, angry-faced character and, upon talking to him, discover that in fact he is a friendly guy. This kind of surprise makes the game more interesting. Good dialog requires the development team to write different dialog paths in order to give the player a flexible approach when talking to the characters. Also, in some games the dialogs are part of the puzzles: You can solve a puzzle only by choosing the right words when speaking. 8. Define a table describing the result for each action over each active object and character, and a table describing which objects will act with others: It's important not only to define the actions that will help with the game solution, but also extra actions that will add fun to the game's story. 9. Add the final touches: Think about cut-scenes (short movies used on introduction and between different game phases) that go deeper into the characters' backgrounds and the story flow. Create extra puzzles and characters. Define some easter eggs (hidden actions or screens that will only 10. .NET Game Programming with DirectX 9.0 by Alexandre Santos Lobão and Ellen Hatton ISBN:1590590511 Apress © 2003 (696 pages) The authors of this text show how easy it can be to produce interesting multimedia games using Managed DirectX 9.0 and programming with Visual Basic .NET on Everett, the latest version of Microsoft's Visual Studio. Table of Contents .NET Game Programming with DirectX 9.0 Foreword Preface Introduction Chapter 1 - .Nettrix: GDI+ and Collision Detection Chapter 2 - .Netterpillars: Artificial Intelligence and Sprites Chapter 3 - Managed DirectX First Steps: Direct3D Basics and DirectX vs. GDI+ Chapter 4 - River Pla.Net: Tiled Game Fields, Scrolling, and DirectAudio Chapter 5 - River Pla.Net II: DirectInput and Writing Text to Screen Chapter 6 - Magic KindergarteN.: Adventure Games, ADO.NET, and DirectShow Chapter 7 - Magic KindergarteN. II: Animation Techniques and Speech API Chapter 8 - .Netterpillars II: Multiplayer Games and Directplay Chapter 9 - D-iNfEcT: Multithreading, Nonrectangular Windows, and Access to Nonmanaged Code Bonus Chapter Porting .Nettrix to Pocket PC Appendix A - The State of PC Gaming Appendix B - Motivations in Games Appendix C - How Do I Make Games? Appendix D - Guidelines for Developing Successful Games Index List of Figures List of Tables appear when the player does some specific action). Decide whether the game will have cheats or not, like secret codes to give extra power to the player character, or specific keyboard sequences that allow the player to go to the next the game level. 10. Note One important thing to remember when writing your games is that it's almost impossible to define ALL of your game details at the planning stage. When coding, new ideas will arise about how to increase character appeal, or new puzzles and extra features to be created; so it's up to you to create the perfect balance between planning too much and planning too little. An extreme in either category will usually lead to disaster. Another important point to stress is that the planning documents (scripts, storyboards, technical projects, spreadsheets, etc.) are not static, but living, and they get updated with more details and corrections as the project evolves. On the technical side, you must think about the game interface: Will your game follow some interface pattern common to other games, or will you create something totally new? Where on screen will dialogs take place (below or above characters' heads, within balloons, etc.)? How can the user distinguish between background objects and active objects—with status text tips, highlights, or mouse pointer changes? Which actions will the game deal with? Will the mouse pointer change to reflect different action verbs chosen by the player? How many objects can be carried by the player? How will the player access these objects—through a game inventory? .NET Game Programming with DirectX 9.0 by Alexandre Santos Lobão and Ellen Hatton ISBN:1590590511 Apress © 2003 (696 pages) The authors of this text show how easy it can be to produce interesting multimedia games using Managed DirectX 9.0 and programming with Visual Basic .NET on Everett, the latest version of Microsoft's Visual Studio. Table of Contents .NET Game Programming with DirectX 9.0 Foreword Preface Introduction Chapter 1 - .Nettrix: GDI+ and Collision Detection Chapter 2 - .Netterpillars: Artificial Intelligence and Sprites Chapter 3 - Managed DirectX First Steps: Direct3D Basics and DirectX vs. GDI+ Chapter 4 - River Pla.Net: Tiled Game Fields, Scrolling, and DirectAudio Chapter 5 - River Pla.Net II: DirectInput and Writing Text to Screen Chapter 6 - Magic KindergarteN.: Adventure Games, ADO.NET, and DirectShow Chapter 7 - Magic KindergarteN. II: Animation Techniques and Speech API Chapter 8 - .Netterpillars II: Multiplayer Games and Directplay Chapter 9 - D-iNfEcT: Multithreading, Nonrectangular Windows, and Access to Nonmanaged Code Bonus Chapter Porting .Nettrix to Pocket PC Appendix A - The State of PC Gaming Appendix B - Motivations in Games Appendix C - How Do I Make Games? Appendix D - Guidelines for Developing Successful Games Index List of Figures List of Tables ADO.NET and Data Access in Games It's not our goal in this section to discuss everything about data access or about ADO.NET; we'll only see the basic information we need to create a simple program that reads data from a given data source, and then use these concepts later in the chapter. We also won't see any details about how to update data or making searches on a database. Game development teams usually choose to create their own data structures, not only for in-memory handling but also to store information on disk using their homemade data access routines. This approach is especially valuable when coding games of high graphical intensity, when you need to achieve the best performance results possible in every aspect of the game. But in other games (like most adventures), we don't think this is imperative, because extra time is spent writing data access routines instead of improving other aspects of the game. Tip Using simple data access methods-such as reading text files or using premade data access routines, like ADO.NET-will also give your game extra appeal to international audiences: The easier the game is to translate (we are not talking about real localization, just translation), the better. A good example of this is the first game of Sid Meyer's Civilization series: Much of the game's text was in text files and you could find, some time after the game was released, translated files (French, Portuguese, etc.) for this game on fan sites throughout the Internet. In the gaming world, ADO.NET can be used to read configuration files written with XML, read game data, and even save game files. Although writing your own read and save routines will always provide faster code, it is important to balance speed with the effort it takes to write your customized routines for each type of data access used in each new game. ADO.NET has better XML integration (it can read and write XML files easily), better support to work with disconnected data (ideal for accessing remote data), better performance, and good integration with the .NET Framework, allowing you to navigate and retrieve data using arrays and collections, for example, thereby making the programs easier to write and maintain. Note If you don't understand or don't care about XML and disconnected data, all you need to know is that ADO.NET is an evolution of the previous ADO library, and that it's faster and easier to use. ADO.NET offers two basic ways to manipulate data from a data source: using a DataSet , which allows us to read, navigate, and update data in the database, or reading the data directly from the database using a DataReader . Choosing the object to access data is a matter of balancing flexibility against speed: DataSet s are in- memory database representations that maintain synchronization with the database through a DataAdapter object and allow the program to update and navigate freely through the data read. With the DataReader object, the program can only read the data in a sequential way, but it is a lot faster. On any of these approaches, our program must use a Connection object to make a link with the database, and a Command object to perform a data-retrieving operation. Usually the operations of opening a connection and executing a command consume a lot of time, so we must plan carefully how many times we'll open the connection and issue new commands. Here is an explanation of the main ADO.NET objects: The Connection object handles the connection to the data source and controls the database transactions. The Command object represents a command to be executed upon a data source and includes explicit functionality such as the ExecuteNonQuery method for commands that do not return arguments, and the ExecuteScalar method for queries that return a single value rather than an argument set. .NET Game Programming with DirectX 9.0 by Alexandre Santos Lobão and Ellen Hatton ISBN:1590590511 Apress © 2003 (696 pages) The authors of this text show how easy it can be to produce interesting multimedia games using Managed DirectX 9.0 and programming with Visual Basic .NET on Everett, the latest version of Microsoft's Visual Studio. Table of Contents .NET Game Programming with DirectX 9.0 Foreword Preface Introduction Chapter 1 - .Nettrix: GDI+ and Collision Detection Chapter 2 - .Netterpillars: Artificial Intelligence and Sprites Chapter 3 - Managed DirectX First Steps: Direct3D Basics and DirectX vs. GDI+ Chapter 4 - River Pla.Net: Tiled Game Fields, Scrolling, and DirectAudio Chapter 5 - River Pla.Net II: DirectInput and Writing Text to Screen Chapter 6 - Magic KindergarteN.: Adventure Games, ADO.NET, and DirectShow Chapter 7 - Magic KindergarteN. II: Animation Techniques and Speech API Chapter 8 - .Netterpillars II: Multiplayer Games and Directplay Chapter 9 - D-iNfEcT: Multithreading, Nonrectangular Windows, and Access to Nonmanaged Code Bonus Chapter Porting .Nettrix to Pocket PC Appendix A - The State of PC Gaming Appendix B - Motivations in Games Appendix C - How Do I Make Games? Appendix D - Guidelines for Developing Successful Games Index List of Figures List of Tables The DataSet and DataReader objects are in-memory representations of a data source. The former provides a dynamic connection to the database, helping you update the data as necessary, and also provides some methods to read relational data as an XML hierarchy and transform it using XSL and XPath. The latter of these provides less functionality and fast read-only serial access to data, in a disconnected manner. The last object, DataAdapter , provides a bridge between the DataSet and the data source, hiding any specific details about the source from the DataSet and handling updates on the data sent back to the data source. Visual Studio help is filled with explanations and simple examples, so we won't include additional details about ADO.NET; but we will instead provide the basic information to help us understand the data access code used in this chapter's sample game, Magic KindergarteN. Tip If you want to learn more about .Net, refer to William R.Vaughn's book, ADO.NET and ADO Examples and Best Practices for Visual Basic Programmers , which is one of the best sources on the subject. Since we only need to read data sequentially, our program will follow three steps: Create a Connection object and connect to the data source. 1. Create a Command object to execute a command-such as Select * from ActiveObjects , or, in common language, "read all information in the Active Objects table." 2. Create a DataReader to retrieve the result of the command and write the data into our game internal structures. 3. The following listing shows a complete sample of code for retrieving data from the Northwind.mdb database, the sample database that comes with Microsoft Access and Visual Studio, including the error trapping code: Dim StrCategories as string = "Categories: " Dim Conn As OleDbConnection Dim Cmd As OleDbCommand Dim DataReader As OleDbDataReader Try ' Open the connection with the database ' (it must be in the application directory) Conn = New OleDbConnection(_ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _ Application.StartupPath & "\NorthWind.mdb") Conn.Open() ' Create and execute the command that will retrieve the data Cmd = Conn.CreateCommand() Cmd.CommandText = "SELECT CategoryName from Categories" ' Fill the DataReader with the command data DataReader = Cmd.ExecuteReader() ' Display all category names in a message box Do While DataReader.Read() If (DataReader.IsDBNull(0)) Then StrCategories = StrCategories & _ "-" & DataReader.GetString(0) End If Loop MessageBox.Show(strCategories, "NorthWind Categories") Catch e As Exception .NET Game Programming with DirectX 9.0 by Alexandre Santos Lobão and Ellen Hatton ISBN:1590590511 Apress © 2003 (696 pages) The authors of this text show how easy it can be to produce interesting multimedia games using Managed DirectX 9.0 and programming with Visual Basic .NET on Everett, the latest version of Microsoft's Visual Studio. Table of Contents .NET Game Programming with DirectX 9.0 Foreword Preface Introduction Chapter 1 - .Nettrix: GDI+ and Collision Detection Chapter 2 - .Netterpillars: Artificial Intelligence and Sprites Chapter 3 - Managed DirectX First Steps: Direct3D Basics and DirectX vs. GDI+ Chapter 4 - River Pla.Net: Tiled Game Fields, Scrolling, and DirectAudio Chapter 5 - River Pla.Net II: DirectInput and Writing Text to Screen Chapter 6 - Magic KindergarteN.: Adventure Games, ADO.NET, and DirectShow Chapter 7 - Magic KindergarteN. II: Animation Techniques and Speech API Chapter 8 - .Netterpillars II: Multiplayer Games and Directplay Chapter 9 - D-iNfEcT: Multithreading, Nonrectangular Windows, and Access to Nonmanaged Code Bonus Chapter Porting .Nettrix to Pocket PC Appendix A - The State of PC Gaming Appendix B - Motivations in Games Appendix C - How Do I Make Games? Appendix D - Guidelines for Developing Successful Games Index List of Figures List of Tables MessageBox.Show("Unpredicted error when loading data: " & e.Message, _ "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Finally ' Close the DataReader and free the command DataReader.Close() Cmd.Dispose() Conn.Close() End Try In the next section we'll explore DirectShow, the object library that provides access to streaming media. .NET Game Programming with DirectX 9.0 by Alexandre Santos Lobão and Ellen Hatton ISBN:1590590511 Apress © 2003 (696 pages) The authors of this text show how easy it can be to produce interesting multimedia games using Managed DirectX 9.0 and programming with Visual Basic .NET on Everett, the latest version of Microsoft's Visual Studio. Table of Contents .NET Game Programming with DirectX 9.0 Foreword Preface Introduction Chapter 1 - .Nettrix: GDI+ and Collision Detection Chapter 2 - .Netterpillars: Artificial Intelligence and Sprites Chapter 3 - Managed DirectX First Steps: Direct3D Basics and DirectX vs. GDI+ Chapter 4 - River Pla.Net: Tiled Game Fields, Scrolling, and DirectAudio Chapter 5 - River Pla.Net II: DirectInput and Writing Text to Screen Chapter 6 - Magic KindergarteN.: Adventure Games, ADO.NET, and DirectShow Chapter 7 - Magic KindergarteN. II: Animation Techniques and Speech API Chapter 8 - .Netterpillars II: Multiplayer Games and Directplay Chapter 9 - D-iNfEcT: Multithreading, Nonrectangular Windows, and Access to Nonmanaged Code Bonus Chapter Porting .Nettrix to Pocket PC Appendix A - The State of PC Gaming Appendix B - Motivations in Games Appendix C - How Do I Make Games? Appendix D - Guidelines for Developing Successful Games Index List of Figures List of Tables Introducing DirectShow DirectShow is the set of components within the DirectX architecture that enables capture, editing, and playback of multimedia streams. The full set of features of DirectShow is very wide, but in the first version of managed DirectShow—for use inside the .NET Framework—we only have access to basic playback capabilities for streaming media, which can help us a lot if all we need is to play sound files like MP3 and WAV and video files such as MPEG, ASF, and AVI. As with all other DirectX components, DirectShow will take advantage of any video or audio acceleration hardware to improve its performance. Since we don't have access to many features of DirectShow with this first managed version, it'll suffice for us to have a simple class, with a New method, where we'll perform the initialization, a Play method to start playing the streaming media, and a StopVideo method to stop playing any streaming media. Note We can't name the stop method "Stop" because this is a reserved word for Visual Basic. To implement these basic methods we'll add a reference to the AudioVideo-Playback interface of DirectX. This interface has only two objects, Video and Audio , which will enable the program to play a video or an audio file. These objects are very simple, with a basic set of methods and properties that help the program to perform streaming media playing operations and check state data. These objects don't support any events, which would be useful to inform the application about the state of any playing operation. In our constructor (the New method) we must receive the control used as a video window, according to the parameters expected by the Video object constructor. The Play method must receive the name of the file to play; all other methods will not require any parameters. Our Video class interface is described in the following piece of code: Imports Microsoft.DirectX.AudioVideoPlayback Public Class clsVideo Public VideoSize As Size Private VideoWindow As Windows.Forms.Control Public IsPlaying as boolean ' The class methods Public Sub New(ByVal WndVideo as Windows.Forms.Control) Public Sub Play(ByVal strFileName As String) Public Sub StopVideo() Public Sub PauseVideo() End Class After we implement this class, all we need to do to play a video is to create an object of this class, passing a reference to a window or form control, and then call the Play method for each file we wish to play. Let's now look at and comment on the code for each method, to uncover some details about the DirectShow AudioVideoPlayback library. The following code sample shows the constructor of our class: Public Sub New(ByVal WndVideo As Windows.Forms.Control) ' Stores the video window control and size for later use VideoWindow = WndVideo VideoSize = VideoWindow.Size End Sub As we can see, all we do in this first method is store the parameters in class properties. All the playing file work .NET Game Programming with DirectX 9.0 by Alexandre Santos Lobão and Ellen Hatton ISBN:1590590511 Apress © 2003 (696 pages) The authors of this text show how easy it can be to produce interesting multimedia games using Managed DirectX 9.0 and programming with Visual Basic .NET on Everett, the latest version of Microsoft's Visual Studio. Table of Contents .NET Game Programming with DirectX 9.0 Foreword Preface Introduction Chapter 1 - .Nettrix: GDI+ and Collision Detection Chapter 2 - .Netterpillars: Artificial Intelligence and Sprites Chapter 3 - Managed DirectX First Steps: Direct3D Basics and DirectX vs. GDI+ Chapter 4 - River Pla.Net: Tiled Game Fields, Scrolling, and DirectAudio Chapter 5 - River Pla.Net II: DirectInput and Writing Text to Screen Chapter 6 - Magic KindergarteN.: Adventure Games, ADO.NET, and DirectShow Chapter 7 - Magic KindergarteN. II: Animation Techniques and Speech API Chapter 8 - .Netterpillars II: Multiplayer Games and Directplay Chapter 9 - D-iNfEcT: Multithreading, Nonrectangular Windows, and Access to Nonmanaged Code Bonus Chapter Porting .Nettrix to Pocket PC Appendix A - The State of PC Gaming Appendix B - Motivations in Games Appendix C - How Do I Make Games? Appendix D - Guidelines for Developing Successful Games Index List of Figures List of Tables is done in the Play method, as we show in the subsequent code sample: Public Sub Play(ByVal strFileName As String) ' Store the path to the file. strFileName = Application.StartupPath & "\" & VIDEOS_PATH & "\" & strFileName DxVideo = Nothing ' Set the control used as a owner to play the videos DxVideo = New Video(strFileName) DxVideo.Owner = VideoWindow ' Start playing DxVideo.Play() ' We must set the video window size again, because ' playing a video resizes the windows to the video's ' default size VideoWindow.Size = VideoSize End Sub The StopVideo method is also very simple; all we need to do is call the Stop method of the Video object, as presented in the following code sample: Public Sub StopVideo() ' If there's no media running, there might be errors. ' -> We'll just ignore them Try DxVideo.Stop() Catch End Try End Sub The PauseVideo method follows the same structure as the previous code sample, using the Pause method of the Video object. The last element of our class is the IsPlaying property. We can calculate it comparing the video's current position with its duration, as we do in the next code example: If they are equal, it means that the video is over. Public ReadOnly Property IsPlaying() As Boolean Get Try If DxVideo.CurrentPosition = DxVideo.Duration Then IsPlaying = False Else IsPlaying = True End If Catch ' Ignore error if DxVideo is not initialized End Try End Get End Property Once this class is finished, we can play a video with three lines of code, as shown in the following code: .NET Game Programming with DirectX 9.0 by Alexandre Santos Lobão and Ellen Hatton ISBN:1590590511 Apress © 2003 (696 pages) The authors of this text show how easy it can be to produce interesting multimedia games using Managed DirectX 9.0 and programming with Visual Basic .NET on Everett, the latest version of Microsoft's Visual Studio. Table of Contents .NET Game Programming with DirectX 9.0 Foreword Preface Introduction Chapter 1 - .Nettrix: GDI+ and Collision Detection Chapter 2 - .Netterpillars: Artificial Intelligence and Sprites Chapter 3 - Managed DirectX First Steps: Direct3D Basics and DirectX vs. GDI+ Chapter 4 - River Pla.Net: Tiled Game Fields, Scrolling, and DirectAudio Chapter 5 - River Pla.Net II: DirectInput and Writing Text to Screen Chapter 6 - Magic KindergarteN.: Adventure Games, ADO.NET, and DirectShow Chapter 7 - Magic KindergarteN. II: Animation Techniques and Speech API Chapter 8 - .Netterpillars II: Multiplayer Games and Directplay Chapter 9 - D-iNfEcT: Multithreading, Nonrectangular Windows, and Access to Nonmanaged Code Bonus Chapter Porting .Nettrix to Pocket PC Appendix A - The State of PC Gaming Appendix B - Motivations in Games Appendix C - How Do I Make Games? Appendix D - Guidelines for Developing Successful Games Index List of Figures List of Tables Public Video As clsVideo Video = New clsVideo(picVideo) Video.Play("MySampleVideo.AVI") In the next section , we'll discuss the proposal for the sample game of this chapter and the next, including the concepts discussed in the previous sections. .NET Game Programming with DirectX 9.0 by Alexandre Santos Lobão and Ellen Hatton ISBN:1590590511 Apress © 2003 (696 pages) The authors of this text show how easy it can be to produce interesting multimedia games using Managed DirectX 9.0 and programming with Visual Basic .NET on Everett, the latest version of Microsoft's Visual Studio. Table of Contents .NET Game Programming with DirectX 9.0 Foreword Preface Introduction Chapter 1 - .Nettrix: GDI+ and Collision Detection Chapter 2 - .Netterpillars: Artificial Intelligence and Sprites Chapter 3 - Managed DirectX First Steps: Direct3D Basics and DirectX vs. GDI+ Chapter 4 - River Pla.Net: Tiled Game Fields, Scrolling, and DirectAudio Chapter 5 - River Pla.Net II: DirectInput and Writing Text to Screen Chapter 6 - Magic KindergarteN.: Adventure Games, ADO.NET, and DirectShow Chapter 7 - Magic KindergarteN. II: Animation Techniques and Speech API Chapter 8 - .Netterpillars II: Multiplayer Games and Directplay Chapter 9 - D-iNfEcT: Multithreading, Nonrectangular Windows, and Access to Nonmanaged Code Bonus Chapter Porting .Nettrix to Pocket PC Appendix A - The State of PC Gaming Appendix B - Motivations in Games Appendix C - How Do I Make Games? Appendix D - Guidelines for Developing Successful Games Index List of Figures List of Tables The Game Proposal In this chapter, we'll create a very simple adventure game named Magic Kinder-garteN. While our adventure is simple, it must still address some of the most common problems encountered when coding a complex adventure: Choosing verbs, or actions, with the mouse pointer (right button changes the mouse pointer icon). We'll use the verbs Walk to, Use, Talk, Take, and Examine. Controlling an inventory to show the objects carried by the player. Using objects from the inventory with other objects on screen. Controlling the dialog between the player's character and nonplayer characters. Controlling the navigation within the game (walking from one screen to another). Initially, our adventure will be much like a book, because we'll use only static images as we build the game in this chapter. In the next chapter , we'll discuss basic animation and incorporate simple animation into our game. As for the dialogs, we'll implement them only in the next chapter , when presenting the basics about the Speech API. The game storyline for our game will be as follows: The main character in our game will be a little boy, a magician's son, who is studying basic tricks in a magic kindergarten. Natanael (that's his name) arrives one day at school and finds no one there, just a big television that can play some movies and a magic book. Looking around, he finds a mud monster. It turns out to be Natanael's teacher, Fiona. Fiona was trying some metamorphosis tricks when she lost her magic wand. She asks Natanael to find it for her. Natanael looks around and can't find the wand, but he does find a magic mushroom, which is able to make him small.When he turns small, he manages to enter a mouse hole inside the school, where he can find the wand, and then help his teacher to get back to her normal form. Based on this storyline, we'll now create the screens, dialogs, active objects, and tables that describe the results of each action over each object. .NET Game Programming with DirectX 9.0 by Alexandre Santos Lobão and Ellen Hatton ISBN:1590590511 Apress © 2003 (696 pages) The authors of this text show how easy it can be to produce interesting multimedia games using Managed DirectX 9.0 and programming with Visual Basic .NET on Everett, the latest version of Microsoft's Visual Studio. Table of Contents .NET Game Programming with DirectX 9.0 Foreword Preface Introduction Chapter 1 - .Nettrix: GDI+ and Collision Detection Chapter 2 - .Netterpillars: Artificial Intelligence and Sprites Chapter 3 - Managed DirectX First Steps: Direct3D Basics and DirectX vs. GDI+ Chapter 4 - River Pla.Net: Tiled Game Fields, Scrolling, and DirectAudio Chapter 5 - River Pla.Net II: DirectInput and Writing Text to Screen Chapter 6 - Magic KindergarteN.: Adventure Games, ADO.NET, and DirectShow Chapter 7 - Magic KindergarteN. II: Animation Techniques and Speech API Chapter 8 - .Netterpillars II: Multiplayer Games and Directplay Chapter 9 - D-iNfEcT: Multithreading, Nonrectangular Windows, and Access to Nonmanaged Code Bonus Chapter Porting .Nettrix to Pocket PC Appendix A - The State of PC Gaming Appendix B - Motivations in Games Appendix C - How Do I Make Games? Appendix D - Guidelines for Developing Successful Games Index List of Figures List of Tables The Game Project Our project will be divided into three main sections: defining the game screens and the flow between these screens; defining what characters will be present, and what will be the result of each action on each character; and defining the results of these actions on all other active objects in our game. Besides these sections, which will help us to define how we'll implement the storyline described in the game proposal , we'll include in our project some technical sections to define the game interface elements, the class diagram, and the database that will store the game data. After we write all the sections in the game project, we'll have enough detail to start coding our game. Since it's very important that the whole team shares the same vision of what the game will be, it's good practice to include as many visual feedback elements in the project phase as possible. This is usually done by including early drafts of screens, characters, and objects, but in our case we'll show the final drawings, since they've already been done. All the drawings for this game (except for the table and the TV used to test DirectShow) were made by Waldivar Cesar ( http://wace.cosmo.com.br ), a Brazilian graphical artist. As for the technical side, we'll create a class diagram depicting the classes we'll use in the coding phase, including the classes we created in the previous chapters, and highlighting the new classes to be created. Creating Game Screens We'll use the storyline described in the section " The Game Proposal " to determine the screens needed for our game. We must imagine the story as a comic book, with as few scenes as possible, to define our screens. This technique is also used when defining the cut-scenes in many games, and is usually called storyboarding . Let's read our little story again and start creating the game screens and composing the presentation text used in each screen, which will be displayed every time the player enters each screen. The main character in our game will be a little boy, a magician's son, who is studying basic tricks in a magic kindergarten. Natanael (that's his name) arrives one day at school and finds no one there, just a big television that can play some movies and a magic book. The first sentence describes the player's character, while the second one describes the first location: a school. Figure 6-6 shows the first game screen. Figure 6-6: The magic kindergarten school To adapt the story to presentation text, we must use shorter sentences, since the player will be reading them on screen. And since we won't implement dialogs with the game characters in this first version, we'll substitute the dialog with fixed sentences on each screen. One possible approach to the text of this screen is as follows: Natanael arrives on his first day at magic kindergarten, but he doesn't find anyone waiting for him [...]... Figure 6- 18 NET Game Programming with DirectX 9.0 by Alexandre Santos Lobão and Ellen Hatton Apress © 2003 (69 6 pages) ISBN:1590590511 The authors of this text show how easy it can be to produce interesting multimedia games using Managed DirectX 9.0 and programming with Visual Basic NET on Everett, the latest version of Microsoft' s Visual Studio Table of Contents NET Game Programming with DirectX. .. .NET Game Programming with DirectX 9.0 by Alexandre Santos Lobão and Ellen Hatton Apress © 2003 (69 6 pages) ISBN:1590590511 The authors of this text show how easy it can be to produce interesting multimedia games using Managed DirectX 9.0 and programming with Visual Basic NET on Everett, the latest version of Microsoft' s Visual Studio Table of Contents NET Game Programming with DirectX 9.0 Foreword... mouse pointers, including one extra pointer can a "wait" state, are displayed in Figure 6- 16 interesting multimedia games using Managed DirectX 9.0 and programming with Visual Basic NET on Everett, the latest version of Microsoft' s Visual Studio Table of Contents NET Game Programming with DirectX 9.0 Figure 6- 16: Mouse pointer icons for each action Foreword Preface The mouse pointers must cycle when... new details that were not new ones multimedia games using Managed DirectX 9.0 and programming with Visual Basic NET on Everett, the latest clear when planning version of Microsoft' s Visual Studio The next code listing shows the Screen class interface: Table of Contents NET Game Programming with DirectX 9.0 Imports Microsoft. DirectX. Direct3D Imports Microsoft. DirectX Foreword Preface Public Class ClsScreen... learn Figure 6- 12 shows the graphical artist's view of our character NET Game Programming with DirectX 9.0 by Alexandre Santos Lobão and Ellen Hatton Apress © 2003 (69 6 pages) ISBN:1590590511 The authors of this text show how easy it can be to produce interesting multimedia games using Managed DirectX 9.0 and programming with Visual Basic NET on Everett, the latest version of Microsoft' s Visual Studio... Apress © 2003 (69 6 pages) The Sub DrawText() authors of this text show how easy it can be to produce Dim i As interesting multimedia games using Managed DirectX 9.0 and Integer programming with Visual Basic NET on Everett, the latest For i = 0 To 3of Microsoft' s Visual Studio version Text(i).Draw() Next Table of Contents End Sub NET Game Programming with DirectX 9.0 Foreword Figure Preface 6- 21 shows the... multimedia games using Managed DirectX 9.0 and view of the school programming with Visual Basic NET on Everett, the latest version of Microsoft' s Visual Studio Table of Contents NET Game Programming with DirectX 9.0 Foreword Preface Introduction Chapter 1 - Nettrix: GDI+ and Collision Detection Chapter 2 - Netterpillars: Artificial Intelligence and Sprites Chapter 3 - Managed DirectX First Steps: Direct3D Basics... Apress © 2003 (69 6 pages) ReDim Text(3) The authors ReDim Screen(5) of this text show how easy it can be to produce interesting multimedia games using Managed DirectX 9.0 and programming with Visual Basic NET on Everett, the latest Initialize = True version of Microsoft' s Visual Studio ' Start Direct3D, with a full screen 800x600 resolution If Not MyBase.Initialize(WinHandle, True, 800, 60 0) Then Table... it for me? interesting multimedia games using Managed DirectX 9.0 and programming with Visual Basic NET on Everett, the latest version of Microsoft' s Visual Studio Continuing with our story, we have this text: Natanael looks around and can't find the wand, but he does find a magic mushroom that is able to Table of Contents make him small .NET Game Programming with DirectX 9.0 We could Foreword simply... show how easy it can be to produce In Figure 6- 11 weinterestingflow between the screens, and give a number to each one to help us identify show the multimedia games using Managed DirectX 9.0 and them later on in the project with Visual Basic NET on Everett, the latest programming version of Microsoft' s Visual Studio Table of Contents NET Game Programming with DirectX 9.0 Foreword Preface Introduction . multimedia games using Managed DirectX 9.0 and programming with Visual Basic .NET on Everett, the latest version of Microsoft& apos;s Visual Studio. Table of Contents .NET Game Programming with DirectX. multimedia games using Managed DirectX 9.0 and programming with Visual Basic .NET on Everett, the latest version of Microsoft& apos;s Visual Studio. Table of Contents .NET Game Programming with DirectX. multimedia games using Managed DirectX 9.0 and programming with Visual Basic .NET on Everett, the latest version of Microsoft& apos;s Visual Studio. Table of Contents .NET Game Programming with DirectX

Ngày đăng: 12/08/2014, 20:22

TỪ KHÓA LIÊN QUAN