| Foreword | | xix | |
| PART 1 INTRODUCTORY PROGRAMMING |
| | 1 | |
| | 3 | |
|
| | 4 | |
| | 5 | |
| | 6 | |
| | 7 | |
| | 8 | |
| .NET Languages (Specifically C# and Visual Basic) |
| | 10 | |
| | 12 | |
| | 13 | |
| | 14 | |
| | 15 | |
| | 15 | |
| | 15 | |
| Other Languages Worth Mentioning |
| | 16 | |
| | 16 | |
| | 17 | |
| | 17 | |
| | 19 | |
|
| Writing Code That Is Clean and Efficient |
| | 20 | |
| | 21 | |
| | 23 | |
| | 24 | |
| | 25 | |
| | 26 | |
| Writing Code That Is Easy to Understand |
| | 27 | |
| Use Unique and Descriptive Variable Names |
| | 27 | |
| Do Not Use ``Magic Numbers'' or ``Magic Strings'' |
| | 29 | |
| Use Enumerated Data Types Wherever Possible |
| | 30 | |
| Writing Code That Can Be Reused and Maintained |
| | 31 | |
| | 32 | |
| Why Over-Zealous Commenting Still Has Potential |
| | 33 | |
| | 33 | |
| | 34 | |
| | 36 | |
| Using PDL for Code Design and Documentation |
| | 37 | |
|
| | 38 | |
| | 40 | |
| Debugging in Visual Studio---Part 1 |
| | 43 | |
| Richard ``Superpig'' Fine |
|
| | 45 | |
| | 47 | |
| Visual Studio Debugging: Execution Flow Tools |
| | 48 | |
| Visual Studio Debugging: State-Inspection Tools |
| | 52 | |
| Visual Studio Debugging: Other Tools |
| | 60 | |
| Diagnosis and Prescription |
| | 61 | |
| | 63 | |
| | 63 | |
| Dealing with a Couple of Common Runtime Bugs |
| | 64 | |
| | 64 | |
| | 66 | |
| | 67 | |
| Prevention, Not Prescription |
| | 67 | |
| | 69 | |
| Rolling Your Own Debugging Facilities |
| | 70 | |
| | 71 | |
| | 73 | |
| | 74 | |
| | 75 | |
| Extended Graphical Templates for Sprite Management |
| | 77 | |
|
| | 77 | |
| | 77 | |
| | 78 | |
| | 78 | |
| | 82 | |
| Isometric and Hexagonal Maps |
| | 83 | |
|
| | 83 | |
| | 84 | |
| | 88 | |
| | 88 | |
| | 91 | |
| | 93 | |
| Mouse Maps for Isometric Height Maps |
| | 95 | |
|
| Experiment 1: One Color per Tile |
| | 96 | |
| Experiment 2: Adapting the Mouse Maps to Be Tile Independent |
| | 96 | |
| Explanation of How To Use My Method |
| | 98 | |
| The Code for the Mouse Maps |
| | 100 | |
| A Slight Problem with the Previous Techniques |
| | 106 | |
| Bezier Curves and Surfaces |
| | 109 | |
|
| | 109 | |
| | 110 | |
| | 115 | |
| | 125 | |
| Direct3D vs. Open GL: Which API to Use When, Where, and Why |
| | 127 | |
|
| | 128 | |
| | 128 | |
| | 129 | |
| | 130 | |
| | 131 | |
| | 131 | |
| | 132 | |
| | 132 | |
| | 132 | |
| | 133 | |
| | 133 | |
| | 134 | |
| | 135 | |
| | 135 | |
| | 135 | |
| | 136 | |
| | 136 | |
| | 136 | |
| Performance and Quality Factors |
| | 137 | |
| | 137 | |
| | 138 | |
| But We Can't Use Direct3D! John Carmack Denounced It! |
| | 138 | |
| | 138 | |
| | 139 | |
| | 141 | |
| | 143 | |
|
| | 143 | |
| Enough Insights and Rants |
| | 145 | |
| Hey, I Thought You Said Enough Rants |
| | 146 | |
| State of the Union (or Who's Got a VM?) |
| | 146 | |
| Doing Something Useful with Lua |
| | 149 | |
| | 154 | |
| Integrating with Your Code |
| | 157 | |
| | 158 | |
| | 160 | |
| Final Words and References |
| | 163 | |
| Introduction to GameMonkey Script |
| | 165 | |
|
| | 166 | |
| What Is GameMonkey Script? |
| | 166 | |
| | 167 | |
| Introduction to the Language |
| | 167 | |
| | 168 | |
| GameMonkey Scripts Defined |
| | 168 | |
| | 168 | |
| | 169 | |
| Expression and Conditional Syntax |
| | 169 | |
| | 170 | |
| | 172 | |
| | 172 | |
| | 172 | |
| Tables as Associative Arrays |
| | 173 | |
| | 173 | |
| Iterating Table Data: foreach |
| | 174 | |
| Simulation of Structs and Simple Classes with Tables |
| | 174 | |
| | 175 | |
| Embedding GameMonkey Script |
| | 178 | |
| Setting Up Your Compiler Environment |
| | 179 | |
| Creating the GM Virtual Machine |
| | 179 | |
| Executing a String as a Script |
| | 180 | |
| Executing a Script from a File |
| | 182 | |
| | 183 | |
| | 185 | |
| | 187 | |
| | 187 | |
| Calling a Scripted Function |
| | 190 | |
| | 191 | |
| Creating a Host-Bound Function |
| | 192 | |
| | 194 | |
| | 195 | |
| Binding a Simple Vector Type |
| | 196 | |
| Constructor with Parameters |
| | 198 | |
| | 200 | |
| | 201 | |
| | 202 | |
| | 205 | |
| | 207 | |
| | 207 | |
| | 209 | |
| The Internet, TCP/IP, and Socket Programming |
| | 211 | |
|
| | 211 | |
| | 212 | |
| | 213 | |
| | 213 | |
| | 214 | |
| IP Routing (Data Delivery Through Wishful Thinking) |
| | 215 | |
| | 216 | |
| UDP (User Datagram Protocol) |
| | 216 | |
| TCP (Transmission Control Protocol) |
| | 216 | |
| | 218 | |
| | 218 | |
| | 218 | |
| Network Programming: Sockets |
| | 218 | |
| | 219 | |
| Example: A Simple TCP Client Program |
| | 219 | |
| | 221 | |
| | 221 | |
| !Order Byte about Warning A |
| | 222 | |
| Looking Up an Address Using DNS |
| | 222 | |
| Utility Functions for Dealing with Addresses |
| | 223 | |
| Connecting to a Remote Socket |
| | 223 | |
| | 224 | |
| Receiving Data on a Socket |
| | 224 | |
| Closing Socket and Cleaning Up |
| | 224 | |
| Example: TCP Client/Server Tic-Tac-Toe Game |
| | 224 | |
| Setting Up the Library, Creating the Socket |
| | 227 | |
| | 227 | |
| Binding a Socket to an Address |
| | 227 | |
| Listening for Connections |
| | 228 | |
| Accepting Client Connections |
| | 228 | |
| | 228 | |
| Using MSG_PEEK with recv() |
| | 228 | |
| Other Noteworthy Stuff about Tic-Tac-Toe |
| | 229 | |
| Example: TCP Client/Server Chat Program |
| | 229 | |
| Making a Socket Non-Blocking |
| | 234 | |
| Using select to Poll for I/O Availability |
| | 235 | |
| Other Notes about the Chat Server |
| | 236 | |
| | 236 | |
| Example: UDP Client/Server Nibbler Game |
| | 237 | |
| Setting Up the Server Socket |
| | 242 | |
| Sending and Receiving Messages: sendto() and recvfrom() |
| | 242 | |
| | 242 | |
| Partitioning Game State Between Client and Server/Message Design |
| | 243 | |
| What Happens If the Server Is Unreachable? |
| | 246 | |
| | 247 | |
| Congestion, Synchronization, and Metering |
| | 247 | |
| | 247 | |
| Programming with Asynchronous Sockets |
| | 249 | |
|
| Asynchronous != Non-Blocking |
| | 250 | |
| | 250 | |
| Setting Up the Asynchronous Sockets |
| | 251 | |
| Handling Notification Messages |
| | 252 | |
| Shaking Hands: Connecting and Accepting |
| | 255 | |
| | 256 | |
| Sending and Receiving Data |
| | 257 | |
| | 259 | |
| | 261 | |
| Vectors and Matrices: A Primer |
| | 263 | |
|
| | 263 | |
| | 264 | |
| | 273 | |
| | 275 | |
| | 277 | |
| | 283 | |
| | 283 | |
| | 284 | |
| | 284 | |
| | 285 | |
| | 287 | |
| | 289 | |
| | 289 | |
| Collision Detection and Response |
| | 291 | |
| | 291 | |
| Collision Response via Projection |
| | 292 | |
| | 292 | |
| Separating Axis Theorem (SAT) |
| | 293 | |
| | 293 | |
| Calculating the Projection Vector |
| | 295 | |
| Separating Axis Theorem for AABBs |
| | 295 | |
| | 296 | |
| | 298 | |
| Separating Axis Theorem for Circles |
| | 299 | |
| | 301 | |
| | 302 | |
| Separating Axis Theorem for Points |
| | 303 | |
| | 303 | |
| | 304 | |
| | 304 | |
| | 304 | |
| | 304 | |
| | 305 | |
| | 305 | |
| Appendix A: Basic Geometry |
| | 305 | |
| | 306 | |
| | 306 | |
| | 306 | |
| | 308 | |
| A* Pathfinding for Beginners |
| | 309 | |
|
| Introduction: The Search Area |
| | 309 | |
| | 310 | |
| | 311 | |
| | 313 | |
| | 317 | |
| Something to Note about Pathfinding Discussions |
| | 318 | |
| | 318 | |
| Other Units (Collision Avoidance) |
| | 318 | |
| | 320 | |
| Handling Unexplored Areas |
| | 321 | |
| | 321 | |
| | 321 | |
| | 322 | |
| Maintaining the Open List |
| | 323 | |
| | 324 | |
| Additional Notes on Heuristics: Manhattan Method |
| | 325 | |
| Additional Notes on Heuristics: Diagonal Shortcut |
| | 325 | |
| | 326 | |
| | 329 | |
| Organizing Code Files in C and C++ |
| | 331 | |
|
| | 331 | |
| Why Split Code into Several Files? |
| | 331 | |
| | 333 | |
| | 335 | |
| | 336 | |
| | 337 | |
| | 340 | |
| | 343 | |
| | 347 | |
| | 347 | |
| | 349 | |
|
| Why Bother with Exceptions? |
| | 349 | |
| | 350 | |
| | 350 | |
| | 351 | |
| | 353 | |
| Exception Safety and Error-Handling |
| | 353 | |
| Scenario 1: Exception Safety in Functions |
| | 353 | |
| Scenario 2: Exception Safety in Classes and Resource Wrapping |
| | 358 | |
| | 360 | |
| | 360 | |
| | 361 | |
| | 362 | |
| | 362 | |
| | 363 | |
| | 363 | |
| | 363 | |
| | 364 | |
| The One: A Singleton Discussion |
| | 367 | |
|
| | 367 | |
| | 368 | |
| | 370 | |
| | 371 | |
| | 371 | |
| | 371 | |
| | 372 | |
| | 372 | |
| | 373 | |
| PART 7 MISCELLANEOUS TOPICS |
| | 375 | |
| Introduction to Pointers, Structures, and Linked Lists |
| | 377 | |
|
| | 377 | |
| Introduction to Structures (and Typedefs) |
| | 379 | |
| | 379 | |
| | 381 | |
| | 382 | |
| Introduction to Simple Linked Lists |
| | 383 | |
| Introduction to Dynamic Memory Allocation |
| | 385 | |
| Dynamic Memory Allocation |
| | 386 | |
| | 389 | |
| | 389 | |
| | 390 | |
| Introduction to Recursion |
| | 396 | |
| Introduction to Member Functions |
| | 403 | |
| | 407 | |
| | 408 | |
| Brief Introduction to Inheritance |
| | 413 | |
| A Quick Peek at Multiple Inheritance |
| | 415 | |
| Brief Introduction to Polymorphism |
| | 416 | |
| Brief Introduction to Operator Overloading |
| | 422 | |
| Sound Formats and Their Uses in Games |
| | 425 | |
|
| | 426 | |
| | 426 | |
| | 427 | |
| | 427 | |
| | 428 | |
| | 429 | |
| | 429 | |
| | 430 | |
| | 432 | |
| | 433 | |
| | 435 | |
| | 437 | |
| Using XML Technologies for Enhancing Log Files |
| | 441 | |
|
|
| | 442 | |
| | 443 | |
| Basic Requirements and Background |
| | 443 | |
| Writing the Data to an XML File |
| | 445 | |
| Prettifying XML Using XSLT |
| | 451 | |
| Enhancing XSLT Using JavaScript |
| | 460 | |
| | 469 | |
| | 473 | |
|
| | 473 | |
| Creating Tables and Getting Started |
| | 474 | |
| | 475 | |
| | 476 | |
| | 477 | |
| Insert Something into the Database |
| | 477 | |
| | 479 | |
| | 479 | |
| | 481 | |
| | 481 | |
| | 483 | |
|
| | 483 | |
| Representing Item Properties |
| | 484 | |
| Items and the Item Database |
| | 484 | |
| | 485 | |
| | 487 | |
| | 489 | |
| | 490 | |
| A Comparison of Browser and Widget Platforms |
| | 493 | |
|
| What Do I Mean By Platform? |
| | 493 | |
| What Language Should You Use? |
| | 494 | |
| | 494 | |
| | 494 | |
| | 495 | |
| | 495 | |
| | 495 | |
| | 496 | |
| Third-Party Engine/Library |
| | 496 | |
| | 497 | |
| | 497 | |
| Index | | 499 | |