"Windows Game Programming Master Skills" (Second Edition) Chapter 1 (on)

zhaozj2021-02-08  489

Chapter 1 Learning Sea Heart "OH, You Want Some Too ?!?" - Hudson, AliensWindows programming is like a war that has been still carried out. Although the game programmer once again refused to develop for the Windows platform, just as the Borg race in "Star Trek": "Resistance is in vain ...", I think this is very suitable. The content of this chapter will bring you quickly patrol all aspects of Windows game development:? History of game? Game type? Game programming elements? Using tool? Example: Freakout History Everything can be traced to the first large computer in the 1960s when. Now, I think that Core Wars running on the UNIX computer is one of the earliest computer games. And when you floating in the 1970s, there is a lot of adventure games on large and small computers in the world. Most of them are based on text and dialogue and have a simple graphical interface. Interestingly, most games are online games in that time! I refer to that 90% of the game is MUD (Multi-User Dungeons, multi-person Dragon and Dungeon Game) or similar simulation games, such as Star Trek (Star Trek) and some war simulation games. However, the public is still waiting for a computer game named PONG to start to appreciate the charm of computer games. Nolan Bushnell designed PONG, this single game has launched the entire video game industry on one night. Atari this brand is also born. Since then, approximately from 1976 to 1978, TRS-80, Apple, ATARI 800-like computers were put into the market, and they were the first generation of computers that consumers can buy. Of course, you can also buy an Altair 8000 assembly machine, but who is willing to carry out their assembly? In any case, these computers have their own advantages and disadvantages. In the middle of these computers, Atari 800 is the most powerful computer at that time (I am convinced that it can develop a runable version of the Wolfenstein (German Command)), the most commercialization of TRS-80, and the availability of Apple Computer is best . Gradually, the games on these computer systems began to impact the market, and there were many more than 10 million millions of Millionaires overnight. At that time, only a good game similar to the "Lunar Lander" or Punching (PONG) type can make it rug! At that time, computer games started like a real computer game, and only a very few people know how to write games. At that time, there was absolutely no book for the game development guide, but from time to time, there were some 50th to 100 pages of booklets from time to time to answer the mystery of game development. It seems that "Byte" magazine has an article, but most of the time you have to rely on yourself. In the 1980s, the game was heated. The first generation of 16-bit computer came out, such as: IBM PC (and its compatible machine), Mac, Atari St, Amiga 500, etc. At this stage, the game screen began to get better, and even 3D games appeared in the market, such as Wing Commander and Flight Simulator (simulated flight). But the PC at that time was still behind the game console. As of 1985, Amiga 500 and Atair ST have almost ruled the game market almost the most powerful game consoles. However, the PC gradually began to be loved by the public with its low price and extensive commercial use. The result is whether the PC will end the rivers and lakes regardless of the technical or quality.

In the early 1990s, IBM PC and its compatible machine were the mainstream of the market. With the release of Microsoft's Windows 3.0, Apple Macintosh is ending. PC is "worker's computer". Users can use it, write programs, or connect a wide variety of devices. I think this can explain why so many computer enthusiasts are fascinated by PC instead of growing more beautiful Mac. In a word, you can't feel fun from using the Mac. But the PC at that time was still behind the image and sound. It seems that the PC is lacking enough horsepower, while the performance of the PC game is always far from the good performance of the game on Amiga or home game consoles. God said, there is light, so there is light ... In the second half of 1993, ID Software issued Doom, as Wolfenstein 3D (German Command 3D, the earliest 3D shared game software, also developed) Continued. At home computer market, PC has become the preferred choice for games and programming - until now. Doom's success demonstrates a little, as long as it is smart enough, people can make the PC do anything. This is very important, remember, there is no thing to replace imagination and determination. If you think one thing is possible, it is possible! Under the impact of DOOM, Microsoft began to re-evaluate their status on the game and game programming. It realizes the huge entertainment industry, and will only become bigger, if you have a hundred points of this industry, there is no harm. So Microsoft has developed a huge plan to enable yourself to be divided into a piece in the game industry. The problem is that the ability to process video audio in real time is still poor, so Microsoft makes a software called Win-g, trying to solve video problems. When promoting, Win-g is said to be the best game programming and graphic subsystem, and in fact it is just a bunch of graphical calls for painting drawings. What's more, Win-g released approximately one year, Microsoft deny its existence, not lie to you! The development of new edible graphics, sound, input, network, and 3D system (95 Microsoft acquired rendermorphics) has already begun, DirectX is born. As in the past, Microsoft issuers claimed that it will solve all the game programming on the world's PC platform, but also the Windows version of the game will run as fast as DOS32 games, even faster. but it is not the truth. DirectX initially two versions have too much poor defects as a complete software product, but this does not refer to technology. Microsoft only underestimates the complexity of video game programming (also underestimating the ability of video game programmers!). Wait until DirectX 3.0, DirectX is better than DOS! But at that time (1996 ~ 1997), most game companies were developed for DOS32 until the DirectX 5.0 released, and people turned to use DirectX to actually develop on Windows. DirectX is now upgraded to version 9.0 (this book contains 7.0 and 8.0 versions), which is an uninterrupted powerful API. That's right, you should think about thinking - using COM (Component Object Model, Component Object Model), programmed on Win32, and no longer has a full direct control of the entire computer - but life is. Just like in the continuous drama "Star Trek", Geordi (Eagle Owl Eagle), which is also unable to control the entire computer system of the spacecraft.

With DirectX technology, you can create a virtual machine with 4GB addressing space (or more), memory linear continuous, imitation DOS. You have a complete reason to make yourself under the DOS environment (if you like). More importantly, now you can quickly join your program support for new technologies for images and sounds. This is attributed to DirectX with visionary design and technology. About DirectX's topic first said, because you will learn it in detail. Let us go back to history now. The earliest appearance is a Doom game, which is only used in software raster technology. As shown in Figure 1.1. Take a look at the Screen performance of the Rex Blade game, it is a cloning version of Doom. Next generation 3D games, such as Quake I, Quake II and UnReal have a major leap. Look at the screenshot of Unreal in Figure 1.2, the performance of this game and its similar game is incredible. They all include software gratings and hardware accelerated code to maximize the advantages of both. Here I can't help but say, if a Pentium 4-generation 2.4GHz computer installed with Geforce 4 Ti graphics is Run Unreal II or Quake III, then the effect is really great. Figure 1.1 Rex Blade: Products for the first generation DOOM technology Figure 1.2 Unreal: Effect! So where will this bring us? Our technology has become more advanced and almost unlimited. However, the "miracle" will always emerge. Although the good games such as Quake and Unreal take a year, I believe you can also create the same charming game! History is temporarily taught, let us go to the core design. One of the most difficult tasks of designing games to write video games is design. Indeed, 3D mathematics is difficult, but planning and designing an interesting game is equally difficult, important. If a game is really fun, who will use the latest volume photon tracking algorithm in the metrics? In fact, it is not particularly difficult to think of a game idea. The key is the details, the ultimate implementation and visual effects These things determine the home of the game, is it covered into the trash can or appears in the cover of "PC Gamer"? Believe some basic concepts and some of my experiences and lessons. The game type is now, the game type is like political promises (some have been touched), but you can classify them into the following types: Similar to the first view of Doom - Most of these games are all 3D games, players are playing roles Observation on the perspective. Doom, Hexen, Quake, Unreal, Duke Nukem 3D, and Dark Forces are leaders in such games. From a technical speaking, they may be the most difficult game, and it is necessary to use excellent techniques to extract out into this game. Sports - sports games can be 2D, or 3D, but the recent 3D sports game is more and more. Usually sports games can be played alone, or you can play with multiple teams. The image quality of sports games has been greatly improved by early first. Although sports games may not be as impressed as adopting the first perspective game, they are catching up. Artificial intelligence levels in sports games are located in the most advanced columns in all game types. Fighting - Fighting games typically play with one person or two, with a side perspective or through an unfixed 3D camera viewing role. The portrait of the game character is generally 2D, 2.5d (series 2D bitmap image) or full 3D model). TEKKEN (Iron Boxing) running on the Sony PlayStation I (PSX) game console promotes the fighting game in the home game machine market. The fighting game is not very popular on the PC, which may be done on the interface problem of the game controller and need two people to play more fun.

Arcade / Gun / Horizontal Edition Class - Such games are similar to Asteroids, Pac-Man (eat beans) and Jazz Jackrabbit games. They are basically 2D old-fashioned games, but they are gradually being reproduced into 3D games. The 3D version of the game rules and 2D versions are roughly the same. Mechanical Simulation - Such games include all kinds of driving, flight, rowing, racing, tank combat simulation, and readers to imagine any other kind. Most such games have been 3D (although until the recent picture of the game is very strong). Ecological simulation class - this game type is quite new, in addition to the real world itself, there is no other similarity. I am talking about Populous (God is also crazy), Simcity, Simant (analog ant) ​​series of games. Such games allow players to play gods who dominate each species, or control some kind of artificial system, whether it is a city, a group of ants, or simulates financial finance like Gazzillonaire (a cool game). Strategy or war class - such games have been divided into many subclasses. But I don't blindly agree with those classification methods, so I will have strategic elements (sometimes turning-off), such as Warcraft (Warcraft), Diablo (Diablo), Final Fantasy VII (Final Fantasy 7 This is this class. I may be a bit biased here, but because Diablo is an instant game, it still contains a lot of strategic factors and thinking. Compared with Diablo, Final Fantasy is a turn-based rather than immediate. Interactive story class - This category includes games similar to Myst (Mystery Island). Basically, the images of these games are pre-rendered, or according to the "path", the game is continuously solving the puzzle. Usually, these games do not allow players to freely walk around, and can only be like playing interactive books. Finally, they are not like a common game program because they are written with Director or similar Director. I want to be Confucian? Verner will definitely criticize that this is too hard. Nostalgic classic class - such games always seem to have come out overnight. Whenever some people always want to play old games, I hope that the plots and difficulties in the game are complicated. For example, Atari has produced approximately 1,000 Tempest versions. I have to recognize that their sales are not particularly good, but you must understand the truth. I am very fortunate to re-produce some old games such as DIG DUG (Golden Drum), Centiped, and Frogger. Pure intellectual puzzles and chess categories - don't need too much introduction. Such games are 2D, 3D or pre-rendered. Tetris (TETRIS), strong hand chess (also named, Monopoly) and Mahjong are a variety of people in such games. Ji Si Guangyi Once you decide which game you want to make (this is a simple thing, because we know what you like), it is time to think about this game. Conception is relying on yourself, no way can guarantee that you can continue to think of a good idea. First, you must think of a game idea you want to make. You will gradually refine this idea to achieve the idea, develop into a game liked to others. Of course, other games can also be inspired as a model or starting point. Another product should not be replicated in sample, but it is acceptable to roughly imitate successful products.

You need a lot of science fiction books and game magazines, and observe what is selling on the market, watching a lot of movies to find a cool story idea, game ideas, or just use movies to visual impact to motivate yourself! I usually do is sitting with friends (or one person), throw a variety of ideas until you have listened to cool ideas. Then I discussed this idea until the vibration is word, or the land of the earth. This sometimes makes people feel discouraged. You may think too much about your thoughts, thus giving up your idea after two or three hours. Don't be discouraged, this is a good thing. To know, if there is a game idea, you will think of you the next day, and you still like it, maybe the opportunity is coming. Warning here I want to remind everyone that a very important thing: Don't be greedy! I have received the email from the newcomer to program a newcomer. These friends have thought of developing a game with Doom or Quake in a short period of time as their vocal work, which is obviously impossible. If an initiator can complete an AsteroIDS cloning version within 3 to 6 months, it is very fortunate, so never feels fanatics. To give yourself a achieved goal, try to consider doing something you can, because it is often only a person who is going to work, and others have left you. Also, remember to make your virgin game as simple as possible. Let us continue to discuss other details. Design documentation and plot series chart When you have a game idea, it should be implemented on paper. Now whenever I have to develop a large game product, I ask yourself to write a decent design document. For small games, the details of a few sheets of paper are enough. Basically design documents are maps to develop this adventure activity. It should be appointed as many details as possible, such as the details of the level and the rules of the game. This way you can know what is doing, so you can work according to the plan. On the contrary, if it is always a modified design when developing, one day you developed will messy. Usually, I like to start from a simple story. For example, use one or two papers to describe this game, who is the protagonist, what is the game ideas, and how the player will play. Then I decide the core details of the game - Game level and rules list, list as much detail as possible. After completing, I can still delete the content, but at least I have a feasible plan. If one day I came up with 100 cool new ideas, I can always join the documentation without forgetting. Obviously, the details of the design are completely decided, but it is still necessary to write the design, at least a game somewhere. For example, it is possible that you don't like a large-scale design document, but prefer some block diagrams of the rough game level and rules. Figure 1.3 is an example of a plot panel prepared for a game. There is no complex detail, only sketches for observation and work. Figure 1.3 A basic episode of a series plate makes the final part of the game's fun game design is an actual verification. As a designer, you are confident that your game is fun and people will people like it? Really not deceived? This is a serious problem. About 10,000 games on the market, 9900 companies are in the game industry, so they should be carefully considered. If this game is completely played with a fascination, it is almost very big. But if the designer himself expresses the idea, imagine what other people will give this game what kind of evaluation! The key is to make a lot of thinking and beta test, increasing a variety of very cool features, because it is finally these details to make a game vivid interesting. This is just like handmade the exquisite craftsmanship of oak furniture - people really appreciate these details. The composition of the game is now looking at what makes a video game program different from the public. Video games are extremely complex software, in fact, they are undoubtedly the most difficult program.

Write MS Word programs Although it is difficult to write Asteroids games, writing unreal games is difficult than any other procedures I know! This means that the reader should learn a new programming method, which is more beneficial to real-time applications and analog programs, rather than you may have learned the single, event-driven or sequential logic. A video game is basically a continuous loop that completes a logical action and draws an image on the screen at 30 frames / sec (or higher) refresh rate. This is very similar to the principle of movies, in addition to the director is yourself. Figure 1.4 is a simplified game loop structure, which describes each of the portions in the figure. Figure 1.4 General Game Cycle Structure Step 1: Initialization In this step, the game program performs standard initialization operations, such as memory allocation, resource acquisition, from disk load data, and more. Step 2: Enter the game loop in this step, the code is running to the interior of the game main cycle. At this time, the various operations start running and run until the user exits the main loop. Step 3: Get the player's input information, the gamer's input information is processed and / or cache to prepare the next manual intelligence and game logic. Step 4: Performing artificial intelligence and game logic This part includes the body part of the game code, such as performing artificial intelligence, physical system, and general game logic, resulting in rendering the next frame image. Step 5: Rendering the next frame of images in this step, the player's input and the result of the game artificial intelligence and game logic in the fourth step, is used to generate the next frame of the game. This image is usually placed in an invisible buffer area, so the player will not see the process it gradually be rendered. The image is then copuy to the display memory and displayed. Step 6: Synchronous display usually because the game complex is different, the speed of the game runs quickly when the computer is running fast. For example, if there are 1,000 objects on the screen in action, the CPU load is much more than only 10 objects. Thus, the picture refresh rate (frame rate, frame rate) of the game is low, and this is unacceptable. Therefore, the game must be synchronized according to a certain maximum frame rate and use timing functions and / or waiting functions to maintain synchronization. Generally speaking, it is very good to reach 30 frames per second. Step 7: The loop is very simple, just return to the entrance to the game cycle and re-executes all steps. Step 8: Close this step is the end of the game, indicating that the main program or game loop will be exited, and return to the operating system. However, before the user ends, the user must release all resources and clean the system, which also do it to any other software. Readers may have questions about many details in the actual game cycle. It is true that the above explanation is a bit too simplistic, but it highlights how to make a focus of game programming. In most cases, the game cycle is an FSM (Finite State Machine, Finite State Automata) containing a large state. Listing 1.1 is a more detailed version, which is basically close to the actual C / C code of the game cycle.

Listing 1.1 A simple game event loop // defines for game loop states # define GAME_INIT // the game is initializing # define GAME_MENU // the game is in the menu mode # define GAME_STARTING // the game is about to run # define GAME_RUN // the game is now running # define GAME_RESTART // the game is going to restart # define GAME_EXIT // the game is exiting // game globalsint game_state = GAME_INIT; // start off in this stateint error = 0; // used To send Errors Back to OS

// main begins here

Void main () {// Implementation of main game loop

While (game_state! = game_exit) {// What state is game loop in switch (game_state) {copy game_init: // the game is initializing {// allocate all memory and resources init ();

//move to menu state game_state = game_menu;} Break;

Case game_menu: // the game is in the menu mode {// call the main menu function and let it switch stats game_state = menu ();

// Note: We Could Force a Run State Here} BREAK;

Case game_starting: // the game is about to run {// this state is optional, but us load before the game is run // you might do a little more housekeeping here setup_for_run ();

// Switch to run statume_state = game_run;} Break;

Case game_run: // The game is now running {// this section steps the entire game loop // clear the display clear ();

// Get theinput get_input ();

// perform logic and ai do_logic (); // display the next frame of animation render_frame (); // synchronize the display wait ();

///////in//// 's user.}

case GAME_RESTART: // the game is restarting {// this section is a cleanup state used to // fix up any loose ends before // running again Fixup (); // switch states back to the menu game_state = GAME_MENU;} break ;

Case game_exit: // the game is in this state the // it's time to bail, kill everything // and cross your fingers release_and_cleanup ();

// set the error word to whatver error = 0;

// Note: we don't have to switch states // Since We are already in this state // on the next loop ity ity // Will Fall out of the main while and // EXIT back to the os}

DEFAULT: BREAK;} // end switch

} // end while // Return Error Code To Operating SystemReturn (Error);

} // End Main Although the list 1.1 has no specific function, it is studied that its game loop helps understand the structure of the entire game. All game cycles are more or less design in this structure. Figure 1.5 shows the state transition diagram of the game cycle logic. Obviously, state transition is very coherent. Figure 1.5 State Conversion Diagram of a game loop About the content of the game loop and finite state automaton will be discussed in more detail in this chapter. Regular Game Programming Guidance Specification The technology commonly used by game programming is discussed below, and the basic principles you should master and use. This will make the game easily. In a word, video games are ultra high performance computer programs. You should not use high-rise APIs in a code segment that requires a particularly stringent code segment for runtime or memory. Especially the code related to the game cycle needs to be manually prepared, otherwise the game will encounter severe speed and performance issues. Of course, this does not mean that you can't trust DirectX, etc., because DirectX's design purposes are the principles of high performance and "Thin". But in general, it should be avoided frequently calling the high-level function. In addition to the above case, more attention should be paid to the programming skills listed below during programming. Tips don't be afraid to use global variables. Many video games do not allow a function of a strict function to use parameters, but use some global variables to deliver parameters, such as a function of the code as follows: Void Plot (int x, int y, int color) {// Plots a Pixel on The screenvideo_buffer [x y * Memory_pitch] = color;} // End PLOT Since the parameter is to be patched and out of the stack, the time required to perform this function is less than the time required to call the function. In this case, the better method can be to set some global variables, then assign values ​​before calling to deliver parameters, as follows: int GX, GY, GZ, GCOLOR; // Define Some Globalsvoid Plot_g (void) {//// Plot A Pixel Using GlobalsVideo_buffer [GX GY * MEMORY_PITCH] = gcolor;

} // end plot_g

Skills use the inline function. You can even improve the previous skills by using the Inline indicator to complete the function call. The Inline indicator indicates that the compiler uses a function code to replace the function call. This will undoubtedly make compiled programs greater, but it effectively improves running speed. Let's take an example: Inline void Plot_i (int X, int y, int color) {// plots a Pixel on the screenvideo_buffer [x y * Memory_pitch] = color;} // end plot_i Note that the global variable is not used, Since the editor effectively executes the same type of data alias. But global variables are still very useful, especially if only one to two parameters are changed when the function is called - the remaining values ​​can be used without reloading. Tips as much as possible with 32-bit variables without 8-bit variables or 16 variables. Pentium and the updated central processor are all 32-bit, which means they don't like the 8-bit or 16-bit data word. In fact, the smaller data may decrease the speed due to the addressing of the cache and other relevant internal memory. For example, you define a structure type as follows: struct cpoint {short x, y; unsigned char C;} // end cpoint pay attention to define this structure looks good, but actually not this! First, the structure itself is a 5-byte long structure - (2 * sizeof (short) sizeof (char)) = 5 bytes. This is too bad, because there is no attention to byte alignment, there will be a big problem when memory is addressed. Better structural forms are as follows: struct cpoint {int x, y; int C;} // end cpoint

C prompt: Structure in C is very like class (Class), in addition to structural default accessibility (Visibility) is except for public. This new structure is much better. First, all structural members have the same size - SizeOf (int) = 4 bytes. Therefore, only one pointer can be accessed by incrementing DWORD (double word, 2 bytes) boundary. The size of this new structure is (3 * sizeof (int)) = 12 bytes, is a multiple of 4, or on the boundary of DWORD. This will significantly improve performance. In fact, if the reader really wants to be safe, you can properly populate all the structures so that the size is a multiple of 32 bytes. 32 bytes are the width of the standard internal cache on the Pentium family central processor, so this is the best length. This requirement can be satisfied by filling in use or using a compiler indicator (the easiest way). It is true that filled will waste considerable memory, but it is often worthwhile to improve the speed. Tips Comment Your code. The game programmer does not comment code is named. Don't make the same mistake, in order to get neat, there is a good note, a little extra typing is definitely worth it. Skills programmed in a way similar to RISC (streamlined intent.). In other words, try to simplify your code instead of making it more complicated. Pentium level processors particularly like simple instructions, not complex instructions. Your program can be longer, but you should try to use simple instructions to make the program more simple relative to the compiler. For example, don't write such a program: if ((x = (2 * buffer [index ))> 10) {// do work} // end if should be written: x = (2 * buffer [index]) INDEX ; if (x> 10) {// do work} // end if there is two reasons for writing code in this way. First, it allows the debugger to place breakpoints between the parties; second, this will easier the compiler to transmit simple instructions to the Pentium processor, which will cause more execution units to handle more in parallel. Code. Complex code is bad in this regard! Skills use binary shift operations to perform a simple integer multiplication of 2 power. Because all data is stored in binary storage in the computer, the multiplication and division operations are equivalent to the multiplication and division of the left or right. For example: INT Y_POS = 10;

// Multiply y_pos by 64Y_POS = (Y_POS << 6); // 2 ^ 6 = 64 Similar: // TO DIVIDE Y_POS BY 8Y_POS = (Y_POS >> 3); // 1/2 ^ 3 = 1 / 8 In this book about the optimization, you will find more similar techniques. Skills design high efficiency algorithm. No compilation language can make an algorithm for complexity O (N2) faster. Better approach is to use clear, high efficiency algorithms rather than brute force and exhaustive algorithms. Tips Do not optimize your code during programming. This is usually just a waste of time. It is recommended that you wait until the main code block or the entire program is completed, it will begin to work with heavy optimization. This will eventually save your time, because you don't have to optimize some of the impact of blurred code. When the game is basically completed, the performance test is available and lookups that you need to optimize. On the other hand, the program code should be paid to the wrong, don't write messy. Tips Do not define too many complex data structures for simple objects. The chain structure is very easy to use, but this does not mean that when you need it, you should use a linked list when you need it, you should use a linked list, you only need to static allocation memory. The 90% of the video game programming is data operation. So the data should be as simple as possible, it can be seen so that it can be used to operate it at will. It should be ensured that your data structure is suitable for your truly solved problem, don't kill the chicken with a cattle knife. Tips use C should be cautious. If you are an experienced C expert, you only do things you want to do, but don't write too much Class, don't overload anything (Overload). Say, simple and intuitive code is the best program, and it is also easier to debug. I personally don't want to see multiple inherits in the game code! Tips If you know your car will open a bumpy stone road, the best practice is to stop, turn around and turn around the road. I have seen many game programmers walk along a very poor programming route until they fune themselves in a bad code. It is possible to realize that the mistakes you make and re-write 500 lines of code are much better than writing a unpleasant code structure. Therefore, if you find problems in your work, you have to re-evaluate and make sure that your saving time is worth it. Tips often back up your work. When writing a game code, you need to lock the code in the code base very frequently. Rewriting a sorting algorithm is relatively easy, but it is difficult to rewrite role Ai or rewrite collision detection. Tips Before starting your game project, you should work. Using reasonable file names and directory names, a consistent variable naming agreement is proposed, try to use separate directories for graphics and sound data, rather than putting all things in the same directory. Use tools to write video games often only need a text editor, perhaps there is a homemade drawing program. But now things have become more complicated. At least, you need a C / C compiler, a 2D drawing program and a sound handler. In addition, if you want to write a 3D game, you may need a 3D modeling software, and if the reader wants to use any MIDI device, you need to prepare a music sort program. Let's browse the currently popular product and its functions. The C / C compiler has not been a better compiler than the MS VC 6.0 on the development of the Windows 9x / NT platform. It can do anything, even more. It produces the fastest .exe executable code. The Borland compiler can also work very well (and it is much cheaper), but its characteristic setting is less.

Whether it is MS or Borland, you do not have to need the full version of any of the above compilers, a student version of the .exe file under the Win32 platform is already enough. 2D Art Software You can buy graphics software, drawing software, and image processing software. You can draw and process pictures by pixels one by one by graphics. As far as I know, JASC's Paint Shop Pro is an excellent image package. Procreate Painter is also very good, but it is more suitable for traditional artists, and it is very expensive. I personally like to use Corel Photo-Paint, but for novice needs, it is a bit too much. On the other hand, the drawing software allows the reader to create images mainly composed of curves, straight lines, and basic 2D geometry. Game development is not often used in such software, but if you need, Adobe Illustrator is a good choice. The last class of 2D art software is used for image processing. These programs are mostly used in the later production of the product, not the preliminary artistic creation. Adobe Photoshop is the software that most people like, but I think Corel Photo-Paint is better. The so-called benevolent sees benevolence, the wise is witness. Sound processing software is currently using all of the sound effects (SFX) of the game to be digital samples, using this type of sound data to work, readers should need a digital sound processing software. The best program in this category is Sound Forge XP. It has a fairly complex sound processing function, which is also very simple to use. 3D modeling software This is the software that challenges economic strength. 3D styling software may be worth tens of thousands of dollars. However, there are recent low-priced 3D modeling software, and their functions are also strong enough to make a movie. I mainly use simple to medium complex levels of 3D styling and animation software - Caligari Truespace. In the corresponding price, this is the best 3D modeling software, only a few hundred dollars, and has the best interface. If you want is a more powerful and pursuit of pictures, you can do it like you like, 3D Studio Max can help you. But its price is about $ 2500, so we should consider it carefully. However, if we use these styling software to create 3D modeling (Mesh), not the picture rendering, then other advanced features are not required. This turespace is enough to cope. There are two types of music and MIDI sort programs: pure digital (like CDs) and MIDI (Musical Instrument Digital Interface, MIDI), MIDI is a synthetic sound effect recorded. If you want to make MIDI information and song, you need a sorting software (also known as the sequencer software). The best cost-effective package is Cakewalk, so if you intend to record and make MIDI music, it is recommended to learn about this software. In Chapter 10, "DirectSound and DirectMusic playing music", we will discuss MIDI data. Good news, some of my software vendors mentioned above allow me to add their software sharing or trial version, I suggest you have to try it! From preparation to completion - a most discouraged thing to use the compiler to learn Windows game programming is learning to use the compiler.

It is common that beginners are so excited to start writing a game program, so that they will try to compile them in the IDE (integrated development environment), then thousands of compile and connection errors! In order to avoid this problem, let's take a look at some basic concepts about the compiler. 1. Be sure to read the instructions attached to the compiler! 2. Be sure to install DirectX SDK (DirectX Software Development Kit) in the system. What you have to do is to find a directory on the disc, read the readme.txt file, and operate according to the instructions (actually just "Double-click Install.exe program" in DirectX SDK).

3. We want to develop a Win32 .exe program, not a .dll file or ActiveX component, and more. So if you want to compile the pass, the first thing you need to do is to create a new engineering or work area using the compiler, and then set the target output file to the Win32 environment .exe. This step is made using the VC 6.0 compiler as shown in Figure 1.6.

Figure 1.6 Creating a Win32 .exe file using Visual C 6.0

4. Use the Add files command to add a source code file to the project from the main menu or the project itself. For the VC 6.0 compiler, its operation is shown in Figure 1.7.

Figure 1.7 Adding a file to a project with VC 6.0

5. From the chapter of DirectX, you must include most DirectX COM interface library files shown in Figure 1.8 in the project.

o DDRAW.LIB

o dsound.lib

o DINPUT.LIB

o DINPUT8.LIB

o dsetup.lib *

Note: Unless you are using DirectSetup, you don't need dsetu.lib.

Figure 1.8 Creating the resources required by Win32 .exe application

o

These DirectX .lib files are located in the lib subdirectory under the installed DirectX SDK directory. These .lib library files must also be added to the reader's engineering or workspace. You cannot add only a search path because the search engine may discover the old DirectX 3.0 .lib file in the library files comes with the compiler. If this is done, you will need to add Windows Multimedia Extensions --winmm.lib to the project. This file is located in the librarial in the compiler installation directory.

6. Ready, start to compile your program.

caveat

If you are a Borland user, there is a separate directory in the DirectX SDK to store the Borland library file. Therefore, be sure to add these .lib files instead of the MS compatible files in the directory tree to the project.

If you still have questions about this, please don't have to worry. These steps will be heard multiple times when discussing Windows programming and first contact DirectX.

转载请注明原文地址:https://www.9cbs.com/read-278.html

New Post(0)