• No se han encontrado resultados

Número de animales según finalidad de manera global

III. Número de usos en cada especie animal utilizados según la finalidad de los usos

III.I Número de animales según finalidad de manera global

Game programming means graphics and sound programming. As mentioned in chapter 1, thisbook uses the Screaming Llama LlamaWorks2D game engine and the OpenGL graphics library. For sound, it uses OpenAL. OpenGL and OpenAL are industry standard tools that are well documented and widely available.

What is OpenGL?

The Open Graphics Library (OpenGL) was first invented at Silicon Graphics, Inc. many years ago. OpenGL is an open standard. That means it's a standard library worked out by an industry group. Everyone who creates a version of OpenGL conforms to the standard, so all versions of OpenGL on all types of computers work essentially the same way. The standard allows some differences, but you don't have to worry about them if you don't want to use the features they define.

OpenGL provides you and me with code to do the most important graphics tasks. For example, it enables our programs to easily draw bitmaps and geometric shapes (circles, rectangles, and so forth) into a game's back buffer. When the final frame is ready, our programs can easily switch the front and back buffers to display the frame on the screen. Programming with OpenGL is not difficult. After a bit of introduction, you'll be using it like a pro. Unfortunately, one of the hardest tasks to accomplish when you're using OpenGL is to get it up and running under Windows. However, the LlamaWords2D game engine does that for you. All you have to do is pass the engine some startup information that I'll explain in

chapter 3. The engine takes it from there.

Where Can I Get More Information on OpenGL and OpenAL?

Information on both OpenGL and OpenAL is available from many sources on the Web. Probably your best starting point for OpenGL information is

www.opengl.org. This is the home page for the organization that maintains OpenGL. Here you'll find documentation, articles, and discussion forums where you can ask industry experts your OpenGL questions.

If you want documentation on how to use OpenGL with Windows, you can get it at www.msdn.microsoft.com/library/en-us/dnanchor/html/opengl.asp?

frame=true.if that address is too long for you to type (it is for me too), you can find this documentation set by going to

www.msdn.microsoft.com/library/default.asp and typing OpenGL in the Search box.

For information on OpenAL, I suggest you start with www.openal.org. This site contains documentation, example programs, and links to articles and other Web pages about OpenAL.

What is OpenAL?

Like OpenGL, the Open Audio Library (OpenAL) is an open standard. OpenAL enables our games to play and mix sounds. Mixing sounds is important for proper special effects. If you have two characters firing guns, you want to hear both bangs. To make that happen, your game has to mix the two sounds together in a memory buffer and then play the contents of

the buffer.

With OpenAL, you can play music and special effects at the same time. When you get proficient with it, you can use OpenAL to do 3D sounds. For instance, if there's an explosion off to the player's left, you can get OpenAL to make the sound come from the left speaker. You can also do effects such as diminishing sounds over distance, echoing, and so on. OpenGL, OpenAL, and DirectX

As mentioned in chapter 1, Microsoft provides a library that does graphics, sound, and other game-related tasks. It's called DirectX. The DirectX graphics library is called DirectX

Graphics or Direct3D (Direct3D is by far the more common name). Its sound libraries are called DirectSound and DirectMusic.

Programmers new to game programming often ask, "Which is better, OpenGL and OpenAL or DirectX?"

If you're a beginner, "better" probably means "easier." In that case, OpenGL and OpenAL are by far the better choice. That's why we're using them in this book. DirectX is complex.

There's nothing easy about it.

If you're a proficient C++ programmer with a background in graphics, DirectX is the better choice. It gives you cutting-edge graphics and sound. OpenGL and OpenAL are professional tools used in real games. However, they do not give the screaming performance and bleeding-edge graphics and sound that DirectX provides.

Many great games do not need cutting-edge graphics and sound. Professional games such as Blizzard Entertainment's WarCraft have long used 2D graphics. WarCraft, and games like it, do not depend on blindingly fast graphics and split-second player response times. You can write games just like it with OpenGL and OpenAL.

The long and short of all this is that OpenGL and OpenAL are a better place to start. If you then want to move to top-level graphics and sound, you'll have to learn DirectX. To be a professional game programmer generally requires a strong knowledge of both

Summary

The first step in learning to write games is learning to program in C++ This chapter

provided a brief introduction to writing programs in C++ using the free Dev-C++ compiler provided on the CD that comes with this book. For each program you write, you must create a project file and add source files to it. Your source files contain functions. One of the source files must contain the main() function, which is where every C++ program starts and ends. When you write your program, you must also compile and link it before you can run it. Functions use the various tools that C++ provides. These tools include data types, variables, and streams. Functions such as main() pass information to other functions and get

information back from them using parameter lists and return values. Functions often use the basic C++ math operators to do their work. The most common are addition, subtraction, multiplication, division, increment, and decrement. Functions use loops, such as the while and the do-while loops, to perform repetitive tasks.

Windows programs use a WinMain() function rather than a main() function. They process messages that are generated in response to events. Events are caused by such things as player input. The LlamaWords2D game engine provides a WinMain() function and some message-handling tools for you so that you can more easily overcome the challenge of learning Windows programming.

We've covered a lot of information in one chapter. However, the concepts presented in this chapter are fundamental to game programming in C++. You will use them in every program you write. So if it still all seems a bit overwhelming at this point, don't be concerned.

Because you'll use these concepts in every program, you'll get lots of practice with them. I'll walk you through the process of applying these ideas to your games, beginning in the next chapter.

Part 2: ObjectOriented Programming in Games

Chapter 3. Introducing Object-Oriented Programming Chapter 4. Introducing the LlamaWorks2D Game Engine Chapter 5. Function and Operator Overloading

Chapter 3. Introducing Object-Oriented Programming

Before we start writing games, we should talk a bit more about C++. Specifically, we need to discuss how to create your own data types, how to write conditions, and how to use if- else statements to make decisions. In addition, I'll explain how to keep the type names you create from conflicting with other type names in your game.

Documento similar