1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Game coding complete

959 1.4K 1

Đ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

Cấu trúc

  • Cover

  • Contents

  • Introduction

  • Chapter 1 What Is Game Programming Really Like?

    • The Good

      • The Job

      • The Gamers

      • Your Coworkers

      • The Tools—Software Development Kits (SDKs)

      • The Hardware

      • The Platforms

      • The Show

    • The Hard Work

      • Game Programming Is Freaking Hard

      • Bits and Pieces

      • That’s Not a Bug—That’s a Feature

      • The Tools

    • The Dark Side

      • Hitting a Moving Target

      • Crunch Mode (and Crunch Meals)

      • Bah Humbug

      • Operating System Hell

      • Fluid Nature of Employment

    • It’s All Worth It, Right?

  • Chapter 2 What’s in a Game?

    • Game Architecture

    • Applying the Game Architecture

    • Application Layer

      • Reading Input

      • File Systems and Resource Caching

      • Managing Memory

      • Initialization, the Main Loop, and Shutdown

      • Other Application Layer Code

    • Game Logic

      • Game State and Data Structures

      • Physics and Collision

      • Events

      • Process Manager

      • Command Interpreter

    • Game View for the Human Player

      • Graphics Display

      • Audio

      • User Interface Presentation

      • Process Manager

      • Options

      • Multiplayer Games

    • Game Views for AI Agents

    • Networked Game Architecture

      • Remote Game View

      • Remote Game Logic

    • Do I Have to Use DirectX?

      • Design Philosophy of DirectX

      • Direct3D or OpenGL

      • DirectSound or What?

      • DirectInput or Roll Your Own

    • Other Bits and Pieces

    • Further Reading

  • Chapter 3 Coding Tidbits and Style That Saved Me

    • General Coding Styles

      • Bracing

      • Consistency

    • Smart Code Design Practices

      • Avoiding Hidden Code and Nontrivial Operations

      • Class Hierarchies: Keep Them Flat

      • Inheritance Versus Composition

      • Virtual Functions Gone Bad

      • Use Interface Classes

      • Consider Using Factories

      • Encapsulate Components That Change

      • Use Streams to Initialize Objects

    • Smart Pointers and Naked Pointers

      • Reference Counting

      • C++’s shared_ptr

    • Using Memory Correctly

      • Understanding the Different Kinds of Memory

      • Optimizing Memory Access

      • Memory Alignment

      • Virtual Memory

      • Writing Your Own Memory Manager

    • Grab Bag of Useful Stuff

      • An Excellent Random Number Generator

      • Pseudo-Random Traversal of a Set

      • Memory Pools

    • Developing the Style That’s Right for You

    • Further Reading

  • Chapter 4 Building Your Game

    • A Little Motivation

    • Creating a Project

      • Build Configurations

      • Create a Bullet-Proof Directory Structure

      • Where to Put Your Game Engine and Tools

      • Setting Visual Studio Build Options

      • Multiplatform Projects

    • Source Code Repositories and Version Control

      • A Little History—Visual SourceSafe from Microsoft

      • Subversion and TortoiseSVN

      • Perforce by Perforce Software

      • AlienBrain from Avid

      • Using Source Control Branches

    • Building the Game: A Black Art?

      • Automate Your Builds

      • The Build Machine

      • Automated Build Scripts

    • Creating Build Scripts

      • Normal Build

      • Milestone Build

    • Multiple Projects and Shared Code

    • Some Parting Advice

  • Chapter 5 Game Initialization and Shutdown

    • Initialization 101

    • Some C++ Initialization Pitfalls

    • The Game’s Application Layer

      • WinMain: The Windows Entry Point

      • The Application Layer: GameCodeApp

      • InitInstance(): Checking System Resources

      • Checking for Multiple Instances of Your Game

      • Checking Hard Drive Space

      • Checking Memory

      • Calculating CPU Speed

      • Do You Have a Dirtbag on Your Hands?

      • Initialize Your Resource Cache

      • Loading Text Strings

      • Your Script Manager and the Events System

      • Initialize DirectX and Create Your Window

      • Create Your Game Logic and Game View

      • Set Your Save Game Directory

      • Preload Selected Resources from the Cache

    • Stick the Landing: A Nice Clean Exit

      • How Do I Get Out of Here?

      • Forcing Modal Dialog Boxes to Close

      • Shutting Down the Game

      • What About Consoles?

    • Getting In and Getting Out

  • Chapter 6 Game Actors and Component Architecture

    • A First Attempt at Building Game Actors

    • Component Architecture

    • Creating Actors and Components

    • Defining Actors and Components

    • Storing and Accessing Actors

    • Putting It All Together

    • Data Sharing

      • Direct Access

      • Events

      • The Best of Both Worlds

  • Chapter 7 Controlling the Main Loop

    • Organizing the Main Loop

      • Hard-Coded Updates

      • Multithreaded Main Loops

      • A Hybrid Technique

      • A Simple Cooperative Multitasker

      • Very Simple Process Example: DelayProcess

      • More Uses of Process Derivatives

    • Playing Nicely with the OS

    • Using the DirectX 11 Framework

      • Rendering and Presenting the Display

      • Your Callback Functions for Updating and Rendering

    • Can I Make a Game Yet?

  • Chapter 8 Loading and Caching Game Data

    • Game Resources: Formats and Storage Requirements

      • 3D Object Meshes and Environments

      • Animation Data

      • Map/Level Data

      • Texture Data

      • Bitmap Color Depth

      • Sound and Music Data

      • Video and Prerendered Cinematics

    • Resource Files

      • Packaging Resources into a Single File

      • Other Benefits of Packaging Resources

      • Data Compression and Performance

      • Zlib: Open Source Compression

    • The Resource Cache

      • IResourceFile Interface

      • ResHandle: Tracking Loaded Resources

      • IResourceLoader Interface and the DefaultResourceLoader

      • ResCache: A Simple Resource Cache

      • Caching Resources into DirectX et al.

      • World Design and Cache Prediction

    • I’m Out of Cache

  • Chapter 9 Programming Input Devices

    • Getting the Device State

    • Using XInput or DirectInput

    • A Few Safety Tips

    • Working with Two-Axis Controls

      • Capturing the Mouse on Desktops

      • Making a Mouse Drag Work

    • Working with a Game Controller

      • Dead Zones

      • Normalizing Input

      • One Stick, Two Stick, Red Stick, Blue Stick

      • Ramping Control Values

    • Working with the Keyboard

      • Mike’s Keyboard Snooper

      • GetAsyncKeyState( ) and Other Evils

      • Handling the Alt Key Under Windows

    • What, No Dance Pad?

  • Chapter 10 User Interface Programming

    • DirectX’s Text Helper and Dialog Resource Manager

    • The Human’s Game View

    • A WASD Movement Controller

    • Screen Elements

    • A Custom MessageBox Dialog

    • Modal Dialog Boxes

    • Controls

    • Control Identification

    • Hit Testing and Focus Order

    • Control State

    • More Control Properties

      • Hot Keys

      • Tooltips

      • Context-Sensitive Help

      • Dragging

      • Sounds and Animation

    • Some Final User Interface Tips

  • Chapter 11 Game Event Management

    • Game Events

      • Events and Event Data

      • The Event Listener Delegates

      • The Event Manager

      • Example: Bringing It All Together

    • What Game Events Are Important?

    • Distinguishing Events from Processes

    • Further Reading

  • Chapter 12 Scripting with Lua

    • A Brief History of Game Programming Languages

      • Assembly Language

      • C/C++

      • Scripting Languages

    • Using a Scripting Language

      • Rapid Prototyping

      • Design Focused

      • Speed and Memory Costs

      • Where’s the Line?

    • Scripting Language Integration Strategies

      • Writing Your Own

      • Using an Existing Language

      • Choosing a Scripting Language

      • Python

      • Lua

    • A Crash Course in Lua

      • Comments

      • Variables

      • Functions

      • Tables

      • Flow Control

      • Operators

      • What’s Next?

    • Object-Oriented Programming in Lua

      • Metatables

      • Creating a Simple Class Abstraction

    • Memory Management

    • Binding Lua to C++

      • The Lua C API

      • tolua++

      • luabind

      • LuaPlus

    • A Crash Course in LuaPlus

      • LuaState

      • LuaObject

      • Tables

      • Globals

      • Functions

      • Calling C++ Functions from Lua

    • Bringing It All Together

      • Managing the Lua State

      • Script Exports

      • Process System

      • Event System

      • Script Component

    • Lua Development and Debugging

    • Final Thoughts

    • Further Reading

  • Chapter 13 Game Audio

    • How Sound Works

      • Digital Recording and Reproduction

      • Sound Files

      • A Quick Word About Threads and Synchronization

    • Game Sound System Architecture

      • Sound Resources and Handles

      • IAudioBuffer Interface and AudioBuffer Class

      • IAudio Interface and Audio Class

      • DirectSound Implementations

      • Sound Processes

      • Launching Sound Effects

    • Other Technical Hurdles

      • Sounds and Game Objects

      • Timing and Synchronization

      • Mixing Issues

    • Some Random Notes

      • Data-Driven Sound Settings

      • Background Ambient Sounds and Music

      • Speech

    • The Last Dance

  • Chapter 14 3D Graphics Basics

    • 3D Graphics Pipeline

    • 3D Math 101

      • Coordinates and Coordinate Systems

      • Vector Mathematics

    • C++ Math Classes

      • Vector Classes

      • Matrix Mathematics

      • Quaternion Mathematics

      • Transformations

      • Geometry

      • Lighting, Normals, and Color

      • Materials

      • Textured Vertices

      • Texturing

      • Subsampling

      • Mip-Mapping

      • Introducing ID3D11Device and ID3D11DeviceContext

      • Loading Textures in D3D11

      • Triangle Meshes

    • Still with Me?

  • Chapter 15 3D Vertex and Pixel Shaders

    • The Vertex Shader and Shader Syntax

    • Compiling the Vertex Shader

    • C++ Helper Class for the Vertex Shader

    • The Pixel Shader

    • C++ Helper Class for the Pixel Shader

    • Rendering with the Shader Helper Classes

    • Shaders—It’s Just the Beginning

    • Further Reading

  • Chapter 16 3D Scenes

    • Scene Graph Basics

      • ISceneNode Interface Class

      • SceneNodeProperties and RenderPass

      • SceneNode—It All Starts Here

      • The Scene Class

    • Special Scene Graph Nodes

      • Implementing Separate Render Passes

      • A Simple Camera

      • Putting Lights in Your Scene

      • Rendering the Sky

      • Using Meshes in Your Scene

    • What’s Missing?

    • Still Hungry?

    • Further Reading

  • Chapter 17 Collision and Simple Physics

    • Mathematics for Physics Refresher

      • Meters, Feet, Cubits, or Kellicams?

      • Distance, Velocity, and Acceleration

      • Mass, Acceleration, and Force

      • Rotational Inertia, Angular Velocity, and Torque

      • Distance Calculations and Intersections

    • Choosing a Physics SDK

    • Object Properties

    • Collision Hulls

      • Requirements of Good Collision Geometry

      • Visible Geometry Versus Collision Geometry

      • Collision Hulls for Human Characters

      • Special Objects: Stairs, Doorways, and Trees

    • Using a Collision System

    • Integrating a Physics SDK

      • Components of the Bullet SDK

      • Initialization

      • Shutdown

      • Updating the Physics System

      • Creating a Simple Physics Object

      • Creating a Convex Mesh

      • Creating a Trigger

      • Applying Force and Torque

      • The Physics Debug Renderer

      • Receiving Collision Events

      • A Final Word on Integrating Physics SDKs

    • But Wait, There’s So Much More

  • Chapter 18 An Introduction to Game AI

    • AI Techniques

      • Hard-Coded AI

      • Randomization

      • Weighted Randoms

    • Finite State Machines

    • Decision Trees

    • Fuzzy Logic

    • Utility Theory

    • Goal-Oriented Action Planning

    • PathFinding

      • A* (A-Star)

      • Dynamic Avoidance

    • Further Reading

  • Chapter 19 Network Programming for Multiplayer Games

    • How the Internet Works

      • Winsock or Berkeley?

      • Internet Addresses

      • The Domain Name System

      • Useful Programs and Files

    • Sockets API

      • Sockets Utility Functions

      • Domain Name Service (DNS) Functions

      • Sockets Initialization and Shutdown

      • Creating Sockets and Setting Socket Options

      • Server Functions

      • Socket Reading and Writing

    • Making a Multiplayer Game with Sockets

      • Packet Classes

      • Core Socket Classes

      • A Socket Class for Listening

      • A Socket Manager Class

    • Core Client-Side Classes

    • Core Server-Side Classes

    • Wiring Sockets into the Event System

    • Gosh, if It’s That Easy

  • Chapter 20 Introduction to Multiprogramming

    • What Multiprogramming Does

    • Creating Threads

    • Process Synchronization

      • Test and Set, the Semaphore, and the Mutex

      • The Windows Critical Section

    • Interesting Threading Problems

    • Thread Safety

    • Multithreading Classes in GameCode4

      • The RealtimeProcess Class

      • Sending Events from Real-Time Processes

      • Receiving Events in Real-Time Processes

    • Background Decompression of a Zip File

    • Further Work

    • About the Hardware

    • About the Future

    • Further Reading

  • Chapter 21 A Game of Teapot Wars!

    • Making a Game

    • Creating the Core Classes

      • The Teapot Wars Application Layer

      • The Game Logic

      • The Game View for a Human Player

    • Game Events

    • Gameplay

      • Loading the Level

      • The Actor Manager

      • Sending and Receiving Events

      • Processes

    • An Exercise Left to the Reader

  • Chapter 22 A Simple Game Editor in C#

    • Why C#?

    • How the Editor Is Put Together

    • The Editor Architecture

      • The Application Layer

      • The Editor’s Logic Class

      • The Editor View

      • Functions to Access the Game Engine

      • Creating the DLL

      • Wrapping Up the Editor Architecture

    • The C# Editor Application

      • Differences Between Managed Code and Unmanaged Code

      • NativeMethods Class

      • Program Class

      • MessageHandler Class

    • The C# Editor User Interface

      • The EditorForm Class

      • The ActorComponentEditor Class

    • Future Work

    • Further Reading

  • Chapter 23 Debugging and Profiling Your Game

    • The Art of Handling Failure

    • Debugging Basics

      • Using the Debugger

      • Installing Windows Symbol Files

      • Debugging Full-Screen Games

      • Remote Debugging

      • Debugging Minidumps

    • Graphics and Shader Debugging

    • Debugging Techniques

      • Debugging Is an Experiment

      • Reproducing the Bug

      • Eliminating Complexity

      • Setting the Next Statement

      • Assembly Level Debugging

      • Peppering the Code

      • Draw Debug Information

      • Lint and Other Code Analyzers

      • Nu-Mega’s BoundsChecker and Runtime Analyzers

      • Disappearing Bugs

      • Tweaking Values

      • Caveman Debugging

      • When All Else Fails

    • Building an Error Logging System

    • Different Kinds of Bugs

      • Memory Leaks and Heap Corruption

      • Game Data Corruption

      • Stack Corruption

      • Cut and Paste Bugs

      • Running Out of Space

      • Release Mode Only Bugs

      • Multithreading Gone Bad

      • Weird Ones

    • Profiling

      • Measuring Performance

      • Optimizing Code

      • Tradeoffs

      • Over-Optimization

    • Parting Thoughts

    • Further Reading

  • Chapter 24 Driving to the Finish

    • Finishing Issues

      • Quality

      • Code

      • Content

    • Dealing with Big Trouble

      • Projects Seriously Behind Schedule

      • Personnel-Related Problems

      • Your Competition Beats You to the Punch

      • There’s No Way Out—or Is There?

      • One Last Word—Don’t Panic

    • The Light—It’s Not a Train After All

      • Test the Archive

      • The Patch Build or the Product Demo

      • The Postmortem

      • What to Do with Your Time

  • Index

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    • I

    • J

    • K

    • L

    • M

    • N

    • O

    • P

    • Q

    • R

    • S

    • T

    • U

    • V

    • W

    • X-Z

Nội dung

[...]... in game development—programming, design, project management, and production Second, being able to explain a point of view on what makes games fun is very important Many game companies go deep here in interviews for almost any position Not only is it to determine if you have the passion to fuel the drive and determination to make it in games, but more importantly, to see if you “get” the product A game. .. two years there and shipped a kid’s game called Barbie Diaries: High School Mystery, where he worked on several minigames and expanded the AI systems The rest of the time, Rez worked on a variety of systems for Rat Race for the PlayStation 3 In early 2008, Rez left Super-Ego Games and spent a year working at Planet Moon, where he worked on a small kid’s game for the Gameboy DS called Brain Quest After... 44 Options 45 Multiplayer Games 45 Game Views for AI Agents 45 Networked Game Architecture 46 Remote Game View 47 Remote Game Logic 47 Do I Have to Use DirectX?... A Game of Teapot Wars! 719 Making a Game 720 Creating the Core Classes 722 xxix xxx Contents The Teapot Wars Application Layer 722 The Game Logic 723 The Game View for a Human Player 733 Game. .. into four parts: n Game Programming Fundamentals (Chapters 1–4): Exposes some stuff that you’ll want in your game programming toolbox, like a good random-number generator It also introduces the major components of games and how they interact After you read the chapters in this part, you’ll have a good working knowledge of the real architecture that game developers use n Get Your Game Running (Chapters... blocks of your game together, including the initialization and shutdown code, the main loop, game actors, user interfaces, and input device code You’ll find your first meaty game code examples Often, many programming books just gloss over this stuff and jump right into the cool 3D code But, in reality, this is the stuff you really need to know to create a successful game, no matter what type of game you... Unity game engine, playing around in C#, and writing mad improvements to the GameCode4 engine If Mike’s fingers aren’t tapping away at a keyboard, he’s probably either “downhilling” on his mountain bike or enjoying good times with his friends in Austin, Texas xvii xviii About the Authors David “Rez” Graham is a self-taught programmer and has been an avid gamer ever since he could pick up a video game. .. been fascinated with games and in 1996, his father gave him his very first programming book Rez devoured that book with passion and immediately began attempting to write his very own game Six months and 5500 lines of code later, Farmer Bill’s Almond Farm was born This was a very simple adventure game with crude graphics written for DOS 6.2 Rez never stopped and kept on writing games In 1998, he managed... the video games industry as a game tester working on Sim City 3000 before going to Microprose to work for its tech support team After the studio shut down in late 1999, Rez worked outside of the industry at Kodak managing a team of IT professionals to keep their tech support group running In late 2005, the time was right to return to the video games industry, and Rez landed a job at Super-Ego Games, first... interview for heaven’s sake! The third thing we noticed was his passion and knowledge of games More than just playing a lot of games, he was extraordinarily thoughtful and articulate about what he liked and why The fourth thing we noticed was Farmer Bill’s Almond Farm This was a demo game that Rez had built to teach himself game programming It had simple graphics and a crude interface for sure, but it was . done. After Super-Ego Games, Rez spent a year at Planet Moon. He worked on a DS game called Brain Quest, which was a small kid’s game. After that he worked on the AI, animation, and save game systems. PTR ApartofCengageLearning Australia • Brazil • Japan • Korea • Mexico • Singapore • Spain • United Kingdom • United States Game Coding Complete, Fourth Edition Mike “MrMike” McShaffry and David “Rez” Graham Publisher and General. a programmer on Martian Dreams, a game I produced for Origin, but by the end of the project, he was the engine that drove that game to the finish line. The game wouldn’t have happened without

Ngày đăng: 23/06/2014, 00:40

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN