Creating a Graphics Object from a Specified Handle to a Device Context

Similar to the previously mentioned methods, the Graphics. FromHDC method creates a Graphics object that allows the program to draw over a specific device context, given its handle. We can acquire the device handle from another Graphicsobject, using the GetHdc method, as shown in the next code snippet Public Sub FromHdc(e As PaintEventArgs) ' Get handle to device context. Dim hdc As IntPtr e.Graphics.GetHdc() ' Create new graphics object using handle to device context. Dim newGraphics As...

The Game Input Classes

DirectX provides a specific set of objects to handle input from the various input devices. These objects are flexible enough to allow the game to use any advanced game device. This set of objects is called Directlnput. Directlnput basically deals with three different input devices keyboard, mouse, and joystick everything that is neither a mouse nor a keyboard (for example, game pads and steering wheels) is grouped into this last type. Note It makes sense that Directlnput is used for controlling...

Zoning with Bits

If we have a game with many objects but infrequent collisions, we can minimize the number of calculations dividing our screen in zones, and only calculate collisions for objects that are on the same zone (this is what's known as zoning). To divide a screen in zones, we'll create an array to store information about each zone's y and x axis. So, if we divide our screen into 64 zones (8 * 8), we'll need one array with 8 elements to store information about the y axis of each zone, and another array...

Direct Input Basics

Getting back to Directlnput, the basic routine to initialize and get data from input devices is very simple, and car be expressed in the following steps 2. Create the input device object, according to the input device desired. 3. Set the data format to be read from the device object. 4. Set the cooperative level for the device (how our application will interact with other applications, in regard to the input device). 5. Enter a loop (in an extra thread) that will check if the application can...

Collision Detection

As we said at the start of the chapter, one of the most important concepts in game development is the collision detection algorithm. Some commercial games have gathered significant market shares just because their collision detection routines are faster, leaving more time for the graphics routines and allowing more responsive game play. Just try to imagine some games without collision detection a pinball game where the ball won't bounce a 3-D labyrinth where players go through the walls and the...

First Draft Including Direct Input for the Joystick and Keyboard

IncludingDirectInput to add support for joysticks and keyboards is very simple We just need to define the objects we have previously created, and code the events for them. When declaring the objects private to the RiverEngine class, we mustn't forget to use the withEvents keyword to allow our objects to wnrk with events. Private Shared WeLthEvents Joystick As nlsJoystick Private Shared WithEvents Kayboard As ClsKeyboard In the initialize procedure, we'll create these objects, passing the window...

Zoning with Arrays of Bits

If we have a limited number of objects on screen, we can use two arrays, instead of variables, to define our zones. Eash objeot will correspond to a specific bit in the array elements, so we'll use byte arrays to control 8objects. intl6 arrays to control 16 objects, and so on, and create a mapping table linking each bit with a specific object The size of each array will define the number of pixels in a zone for each dimension. eor example, creating two arrays each with 10 positions in a 640*480...

Peerto Peer Connections

In peer-to-peer connections, every player is aware of every other player in the game, sending messages to and receiving messages from all players, as illustrated in Figure 8-2. The most obvious benefit of using this network organization is that we don't need a dedicated server to play the game, so players within a group can play it within their own local area network (LAN), or even through the Internet, as long as they know the addresses of the other members of the group. In this type of...

The Game Engine Class

To code the interface of the GameEngine class, we must refer to the class diagram we created in the game project phase and include the implementation details. The GameEngine class interface is presented in the following code listing Public Width As Integer 25 Public Height As Integer 25 Public Shared Backgroundlmage As Image ' This array and enum controls the object collision Protected Shared arrGameField(,) As enGameObjects Protected Enum enGameObjects Mushroom 0 Empty 1 Branch 2 Netterpillar...

Direct Audio Classes

There are two different sets of components for audio input and output DirectMusic, for background music playback, and DirectSound, for sound effects. These two sets together are sometimes called DirectAudio, although they are separate things. DirectMusic doesn't have a managed version, but we can access its features through COM interoperability. NEW IN .NET is kind of an evolution from COM architecture but we still can use COM objects from .NET .NET programs, and more The .NET programs generate...

The Game Proposal

When creating games, remember that the very first step is to write a clearly defined game proposal. This ensures that everyone involved in the game creation process can understand and agree with the game objectives. Even very sophisticated games must start with a simple proposal, so the programmers can build the project upon a previously established goal. As mentioned in the introduction to this chapter, we'll create a fast-action arcade game called .Netterpillars. Here are some details about...

The Game Project

In a commercial game project, the game project starts with a complete game proposal (not just some simple phrases like ours) and continues with a project or functional specification. Although the proposal is written in natural language-so anyone can understand and approve it (including the Big Boss, who will approve or reject the budget for the project)-the project includes programming details that will guide the development team through the coding phase. It's not our objective here to explain...

The Class Diagram

Since we already have all base classes for the game engine, sprite, game music, and sound, all we need to do is to create derived classes that will supply specific characteristics, according to the game's special needs. Looking at the game proposal, we can only see two candidates for new classes Player and Tile, which will be derived from the Sprite class. Of course, we'll need a class derived from the game engine, too (let's call it the RiverEngine class), to implement the game code. After a...

Testing the Block Class

The new stub for the GameField class must include the properties and methods accessed by the Block class, as shown in the next code listing Public Shared backcolor As Color Public Shared WinHandle As System.IntPtr Public Shared Function IsEmpty(x As Integer, y As Integer) As Boolean Public Shared Function StopSquare(Square As ClsSquare, _ x As Integer, y As Integer) As Boolean StopSquare True End Function End Class TheisEmpty and StopSquare methods always return True we'll add code for these...

Testing the Square Class

Now we are ready to test our program. To do this, we'll need to create a driver to call the class (a window with a button and a pictureBox will suffice), and a stub for the GameField class, since our square class uses the backcolor property of this class. The stub is very simple, just a new file composed of the code lines shown in the next sample Public Shared backcolor As Color End Class The driver will be replaced by the main program in the final version, so we can implement it as code on the...

Final Version Coding the Game Over Screen

Our goal for the game over screen in a death match is to present the local and remote player's names, showin< which one is the winner. We can also use the code from the previous game over screen to include the length o' a player's netterpillar on screen. The first thing we must do is to create a new property in the NetworkNetterpillar class to store the remote player name. We'll need to set this property properly. On the host, we'll receive the remote player's name in the NewPlayer event,...

Coding for Game Over

Looking back at our game proposal, we stated that the game is over when all the players die (computer or human ones), or when the last mushroom is eaten. Since we have a property stating whether a player is dead or not, and a property that stores the number of mushrooms (that is already reduced every time a mushroom is eaten), all we need to do is include the code in theRender procedure to test the preceding conditions and set the GameOver property to True if one of the requirements is met. Dim...

Animating the Mouth

To provide a realistic animation of our characters when speaking is one of the most challenging tasks in a game. The easy part is synchronizing the mouth animations with the sound of the voice a lot of references (usually cartoon animation books) are available that will help you in associating the correct mouth position with each syllable. The hard bit is including the gestures that reinforce the words, since every character must make gestures when speaking (unless. of course, it is a mummy or...

Updating the Render Method

We'll also nred to update the Render procedure to reflect the changes for multiplayer games. This method wil be core to the game rynchfonization, and we'll depend heavily on the guarantee that TCP delivers all messages, and that they will be deliveeed in the same order they where sent. We'll also not include any special treatment to hide the latency. Let's suppose this game will run on a local network, and forget about this problem to make the code simpler. Even with a.l these assumptiops, the...

Tempo

The music, the environmental feel, and the action or tranquility of the game is the tempo. The important part is to change between fast exciting and slow relaxing. Otherwise each will lose its strength. The contrast is actually vital to uphold each extreme's meaning. Even by itself the tempo can be very powerful in capturing the player for hours. There is a lot to be learned from the movies industry. Did you know the best way to describe silence is to have a distant and small sound that reminds...

Creating Gradients

In the previous section, we saw some code samples used to create solid red rectangles via a solidBrush object. GDI+ allows the programmer to go beyond flat colors and create linear and path gradients, using special gradient brushes that provide very interesting effects. GDI+ has features to create horizontal, vertical, and diagonal linear gradients. We can create linear gradients in which the colors change uniformly (the default behavior), or in a nonuniform way by using the Blend property of...

Adaptable Percentage Tables

A neural network can be simplified as a table with adaptable results, represented by percentages. For example, when coding a war game, we can create a table to help the AI choose the tactics with which to attack the other players. The AI will use each tactic a set percentage of the time depending on the success rate that is represented by the percentage. The greater the success rate, the more often this tactic will be used. The table can be filled with some initial values, as shown in Table...

Animating Anticipation

Anticipation is an animation concept based on observation of real movements. Although it sounds like an obvious concept, even today we see many commercial games that fail to include anticipation in their characters' animation. The basic idea is simple Before starting any movement, a character will always do a preparation movement, usually in the opposite direction. For example, if the character is sitting down, before it stands up it will lower its head and shoulders a little, just like we...

Path Finding

Like the line of sight problem, there are also many different algorithms to solve the problem of path finding. If we don't know in advance how the game field will take shape, we could employ some of the following methods Mark some milestones along the path the character is walking. If it hits an obstacle, return to the last milestone and try another way. This algorithm is useful when we have labyrinths or tiled game fields. Use invisible bumpers around the game characters The program checks for...

Processing the Keyboard Input

In the GetKeyBoardState method, we'll have to translate the KeyboardState byte array into keycodes from the Keys enumeration. When a key is pressed, its corresponding array element returns with the seventh bit (128, or 80 in hexadecimal notation) set so all we have to do is to loop through all elements in the array and check the bits of each element. Since the array position has no relation at all with the ASCII values or any other character table (they just start with 1 for the Esc key, and go...

Fifth Step Using Colored Lights

We can use the same code we created for testing DirectX in windowed mode to also do our diffuse colored ligh test. Although all we need to do to test the use of diffuse light is change the flexible vertex format to support a color value per vertex, and set such values for the vertices, we'll stick to our project and create a light control window in which we can choose the RGB components for the light color on each vertex. The light control window, shown in Figure 3-18, is composed of four tabs,...

Defining the Game Screens

Although the windows implementation will be done in the code phase, it's good practice to create at least a draft of the screens in the project phase, because when drawing the screen we usually remember more details that can be added to the class diagram. Ifwe can imagine how the previously discussed classes will work in each screen, then there's a good chance we haven't missed any important details. Since Visual Basic allows us to create screens quickly, the best sketches are the ones done...

First Draft Loading and Drawing the Game Field

Our main objective in this first draft is to load the text file and convert it into a graphical game field. For this, we'l code the Tile class, some basic methods oHhe RiveoEngine clacs, and our main program. TheTile class, as we saw In the game puoject phase, will be very simple and will only add a specific Type attribute to tSe base class Sprite, as shown in the following code sample Imports Microsoft.DirectX.Direct3D Public Class ClsTile Ship 4 Plane 5 Bridge 6 End Enum Sub New strImageName...

Defining the Game Tiles

River Pla.Net is one o.tlrose games that hllows its to design the whttie game field based on tiles. We can create the game field map file with a text editot, using the game program to translate the set of characters in the file to a set of tiles on screen. Maybe the first thing we must think about when creating a tile-based game is what size our tiles will be. They aren't required to be square ones, but using squares is the best approach, since we can put the tiles together in any direction,...

Third Draft Including the Shooting Feature

To include a shooting feature in a game requires a series of steps, even in a simple 2-D game like ours. We'll have to do the following 1. Create some kind of structure to hold the bullets. Since we already have the Sprite class, which stores information such as the image and the current position, we can use an array with 16 elements, as state in the game proposal . 2. Add some code to the input device handlers to inform the player that he or she must shoot. 3. Add code to the player's movement...

Drawing Primitives and Texture

We're ready to start working now We know what adapters and devices are, we understand what display modes are, we know the basic Direct3D program structure, and we know all we need to know for now about projections, cameras, and transformations. The stage is all ready for the play. All we need now is to meet the actors the drawing primitives. Drawing primitives, or 3-D primitives, are vertex collections that define single 3-D objects. Direct3D uses the simplest polygon-a triangle-as a base to...

Defining the Game Classes and the Game Engine

The game characters are the first natural candidates for game objects, based on our library's Sprite class. So we can take the nouns on the list of topics from the game proposal and create a first draft of our class diagram, as shown in Figure 2-6. Figure 2-6 The class diagram first draft Figure 2-6 The class diagram first draft This looks fine for a fi os dr aft. We see here an extra class, not mentioned in the game proposal the Branch class. We include itrust for fun, in order to improve the...

Creating the Joystick Initialization Code

Coding for joystick devices is far more complex than for keyboards and mice, since we'll have a large variety of devices that will be handled as joysticks. A drawback to this flexibility is more complex initialization and data-processing routines. To initialize the joystick, we'll need to discover the specific GUID to be passed to the Device function, which wi vary depending on the devices attached to the computer. To recover this GUID, we'll need to call the GetDevices method on a for-each...

Second Step Coding Our First Windowed Test

This first test is very important, because it will establish the base of all future tests and programs. So we'll make it very simple Let's just initialize the Direct3D, create the device, draw a simple image, and count the frame rate. In order to allow us to see something happening, let's load an array of images loaded as textures and render them one at a time, over a square composed of two triangles , so we'll see the illusion of a walking guy We'll use the basic Direct3D program structure,...

Understanding Matrices and 3D Transformations

Translation

Knowing how to work with transformation matrices is possibly the most important point when dealing with Direct3D. Using matrices, we can perform rotation, scaling, or translation of any object on the 3-D world or in the 2-D world, if we choose to ignore the z component , and these operations, correctly applied, will heilp gt u to define our projection type as shown in the previous section or even move the camera to see the same scene from different points. Let's discuss the use of...

Introducing Speech API

Application programming interfaces APIs are present all over the Windows environment, offering high-level interfaces that allow applications to access device features. By device, we mean not only physical devices, such as joysticks or graphics acceleration boards, but also logical devices, like the ODBC or OLE DB devices for data access, or the focus of this section, the interface for speech engines. Speech engines are special drivers that control speech recognition and or speech generation...

Reward

There are many different levels of rewarding, and they are related to one another. If you achieve the right balance of rewarding, depending on your game goal and type, you will succeed in capturing the player. Now that, my friend, is a bold statement. Let's look at this as some rules within a specific time span, say between two character levels, or between the first upgrade and the second. First the different aspects, and then some more comments on each. The player needs to be rewarded often...

The Sprite Class

Here we'll attempt to create a generic Sprite class, which can be improved upon as needed, and can be use lt to create derived classes that can hold specific properties and methods according to the game being created. We can use the basic interface for sprites defined in Chapter 2, with the New,Draw, and Load methods, and some simple properties. Looking back at Chapter 3, we can list some suggestions for other interface elements values for the translation, scaling, and rotation operations in...

Presenting the DirectX Top Level Objects

When programming DirectX 9.0 or earlier with nonmanaged pre-.NET languages, we have to create a maste object of type DirectXn where n is the main number of the DirectX version, for instance, DirectX8 for the 8.1 version , and everything can be created from this object. In the managed version of DirectX 9.0, we can directly create the second-level objects, as listed here Direct3D for access to the 3-D acceleration layer. Direct3DX for access to utility functions to make coding easier such as...

Creating the Mouse and Keyboard Initialization Code

TheKeyboard class interface is shown in the next code listing the interface for the mouse devices is very similar, with a few differences discussed later. Imports Microsoft.DirectX.DirectInput Imports Microsoft.DirectX Imports System.Threading ' General use properties and enumerations Private InputDevice As Device Nothing Private InputThread As Thread Nothing Public Shared keyboardState As keyboardState Public Event Keypress Keycode As Keys Public Sub New Parent As Window.Control.Forms Public...

Creating the Class Diagram

In our project we'll ose the base classes for the vame engine1 svrite, and mouse control, and then create derived classes according to our garnet specific needs. Well also create a new class to control DirectShow sreaming media paying features. Using the experience we gained in the last chapter, wet ran devire three new classes a game control class, derived trom clsGameEngine, that will be called clsKinderEngine an active objects control class, derived from clsSprite, named clsActiveObj ect and...

Coordinate Systems and Projections

Projection Parallel Perspective

Even if we have no interest in creating 3-D games, we must understand the basic concepts of a 3-D coordinate system, because everything we do in Direct3D is defined by points and images in a 3-D world. Of course we can ignore the z axis and pretend that we are in a 2-D world and we'll see how to do this but the z zeroed value will still be there. When we are dealing with three Cartesian dimensions, there are two types of coordinate systems left-handed and right-handed. These names refer to the...

Adding the Final Touches

Given the sample game's simplicity, there is little room for improvement in this chapter, but we can always add some extra touches to our games to improve payability. In this chapter's sample game, after playing a few dozen times, we feel that using the Pocket PC buttons interface is not as simple as using a keyboard, since on a keyboard we can use more than one finger at once on the navigation keys to control the blocks. We can't solve this issue, but we can increase the game rewards so...

Fiit

Figure 7-6 The same bouncing movement, without squash and stretch We must use this same idea when animating characters, especially in jumping sequences and when hitting or being hit by an obstacle. Figure 7-7 shows the same concept used for a jumping rabbit character. Figure 7-7 A squashing and stretching jumping rabbit Figure 7-7 A squashing and stretching jumping rabbit Although we can create a jump by just moving a character up and down, including squashing and stretching will make that...

Proximity Algorithms

Another type of algorithm commonly used to calculate object overlapping is the proximity algorithm. Proxy algorithms are somewhat similar to the bounding boxes algorithm, depending on the formula used. The basic idea behind such algorithms is to calculate the distance between the centers of two objects, and then check the value against a formula that describes approximately the objects' shapes. This method is as p recise as the formula used to approximate the object shape for example, we can...

The Netterpillar AI Class

As we decided in the game proposal a net in thu game project, we only need to use a simple form of artificial intelligence. Just avoid walls and eat mushrooms if they are near, that's all. Public Class clsAINetterpillar Inherits clsGameEngine Private andomfercent As Integer 5 Function As Point, _ CurrentDirection As clsSprite.enDirection As clsSprite.enDirection Function RandomDirection CurrentLocation As Point, _ ChoosenDirection As clsSprite.enDirection As clsSprite.enDirection End Class...

The Netterpillar Class

TheNetterpillar class will control the drawing of the netterpillar characters on screen, both for human-controlled and computer-controlled ones. It'll have some methods for making the netterpillar bigger when it eats a mushroom and to store the bitmaps and current status for the character. Table 2-7 lists the initial suggestion for the members of this class, along with a short description. Table 2-7 The Members of the Netterpillar Class Table 2-7 The Members of the Netterpillar Class We'll have...

Overview

In this chapter, we'll improve the .Netterpillars game created in Chapter 2 to include multiplayer features seeFigure 8-1 . We'll create two new options Host a Death Match and Join a Death Match, which will respectively set up a DirectPlay session to receive connections from other computers and connect to a DirectPlay session on a remote computer, allowing two players to compete against one another across the network. Figure p-1 .Netterpillars I this chapters fample gam In the coming sections,...

The Sprites New Method

As for the constructor of the class, we can define many different overloaded functions for it a method that receives no parameters to be implemented by the derived classes, if needed , a method that receives the sprite image name, and two others that receive the initial position of the sprite and the color code to be used as a transparent color. If we need more overloads, we can create them as the project evolves. Observe that, in order to simplify the New code, we create a private Load method,...

Creating Nonrectangular Windows

Creating nonrectangular windows can help usto come up with customized window shapes that may improve the visual appearance of our game. Perhaps the most common example of a program that uses this resource is Windows Media Player, in which each skin we choose implies in a different window shape. To change a window's shape, all we need to do is to set the Region to a previously created graphics path. We talked about graphics paths when introducing GDI in Chapter 1, and used them to draw...

Create Border Tiles

To create border tiles, we must separate the tiles into groups that will have connections with each other, and then create the borders for the tiles in each group. We must do this because usually some tiles won't need to have borders with some of the others for example, the tiles that will create internal parts of a building don't need to have any special border with the outside tiles. Within every group, create the border tiles between each type of terrain. There are basically three types of...

Understanding Devices

DirectX offers a special object type, Device, which allows us to have access to the 3-D acceleration layer. We can choose up to three types of devices for each adapter Hardware Hardware Abstraction Layer When creating HAL devices, we have direct access to the hardware acceleration features and increased speed . If we try to create a device of this type but have no 3-D acceleration board, DirectX will raise an error and won't create the device. Reference Reference Rasterizer This type of device,...

What Is E-gaming Programming

BcrJc-r -i .yjg IwiderS.hp boidciiHU.t j boiSciiill. Hp OnUlcr .H ti rie c Si J bcrJtcihl . ip bo df .b-p baTdcrSwj.bifj Figure 4-12 The names of the border tiles The N, S, W, and E borders are used as island borders and as lake borders by just exchanging positions. We can remake the screen from Figure 4-10 to add the borders, resulting in the screen shown in Figure 4- Figure 4-13 A second screen, based on a larger set of tiles Initially it may seem as toou these are the only tiles we'll ever...

Texturing and Coloring with Flexible Vertex Formats

Direct3D gives us the power to choose how we can define the vertices that will compose our drawing primitives, using the so-called flexible vertex formats FVF . Before creating a vertex buffer explained in the previous section , we must specify which kind of information each vertex will hold, creating a custom vertex structure and using it when creating a new vertexBuffer object, as presenUed in t he next code sample Vbuffer New VtrtexBuffer VertSize, VertNum, Deviue, Usage, VertexFormat, Pool...

Polling the Devices

As we saw earlier in the section Defining the Input Classes, the initialization code for each device must start a new thread, which will be responsible for gathering data from the device in a continuous loop. On the polling loop, shown later in this section, we'll go through the following steps 1. Poll the device to check if we have access to it using the Poll method of the inputDevice object . 2. If we dont have access, try to acquire it using the Acquire method of the inputDevice object . 3....

Processing the Joystick Input

The last input device method, GetJoystickState, will deal with the JoyState structure. As mentioned before, this structure has many attributes that will be filled according to the joystick type. In order to guarantee that our class will work even with the simplest joysticktype peripheral, we'll keep it as simple as possible but some processing will still be needed. We'll generate the JoystickPressed event according to the Buttons array, simply by passing the button index to the application and,...

Adding Support for Force Feedback Joysticks

When dealing with joysticks, an interesting feature is to include force-feedback control in our games, so the user can enjoy a more interactive experience. When creating force effects, there are two basic approaches loading the effects from a previously created effect file, or creating the effect from scratch for our program. The effect files are created with the Force Editor, a tool that comes with the DirectX SDK for creating and testing force-feedback files. It saves the effects into files,...

Creating a Speech Generation Game Class

To add extra functionality to our speech generation class, besides the speech generation and events we saw in theprevious section, we'll create a method that translates the viseme codes into actual player images, chosen among predefined mouth positions stored as images. To generate these images, we'll simply apply the mouth positions we saw in Figure 7-15 to our character's head. Since the speaking head won't move its shown in a square at the bottom of the screen , we won't have to deal with...

Further Improvements

We saved the best fot 'ast What about creatiug new intelligent characters for our game, maybe some opposition like a spider who eats the netterpiliars In the code for this chapter on the ramples CD-ROM, you will find an almost fully working spider character. We already did all the dirty work the Spider and AISpider class interfaces, the call to the moving functions at th MoveComputerCharacters routine and at the Render and Redraw method of the objGameEngine almc everything is there. The code...

Updating the Game Form

After updating the game classes, we'll seed to modify the game form to adapt to these updates. We'll need to update the form Load event, the Click event of the Start button, and the Tick event of the timer. Besides these changes, we'll have to add code for the extra interface buttons we created for the Pocket PC version. Let's look at each os these updates in detaN. Starting with the norm's LoaM event, we need to include a call to the initialize method of the GameEngine class so the back...

Include Extra Transition Tiles

For those transitions fhat w ll be presented most of the time to the player, include some different tiles for each transition and for the basic pet1 which will be used sparingly to brea k down the feeling of patterns of repetition. For example, when creating tiles between water and land, include some rocks, a bay, or a larger beach, so you can use them eventually to give more variation to the game visual. Examples of simple variations are shown in Figure 4-4. .hnji .hnji

First Step Coding the Main Window

Let's start coding the main window, which will allow us to see our hardware capabilities, and then we can code the tests one by one, from the simpler to the most complex ones. After creating the main window, as shown in the visual prototype in the project phase, we need to know the functions that list the adapters, devices, display modes supported, and capabilities. A quick look in SDK help shows us these methods and properties of the Manager object s Adapters. Count l Returns the number...

API for Converting Text to Speech

To control text-to-speech TTS devices, after setting the proper reference to the speechLib reference, all we need to do is to create an spVoice object and call the speak method to generate the speech from text data. The complexity of the speech generation is so well hidden from the application that we can create a Hello World speaking application with only three lines, as shown in the next code sample Dim voice As SpeechLib.SpVoice Set voice New SpeechLib.SpVoice voice.Speak Hello World,...