Game scripting mastery

1.3K 118 0
Game scripting mastery

Đ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

TE AM FL Y Game Scripting Mastery Alex Varanese © 2003 by Premier Press, a division of Course Technology All rights reserved No part of this book may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system without written permission from Premier Press, except for the inclusion of brief quotations in a review The Premier Press logo and related trade dress are trademarks of Premier Press, Inc and may not be used without written permission Publisher: Stacy L Hiquet Marketing Manager: Heather Hurley Acquisitions Editor: Mitzi Koontz Series Editor: André LaMothe Project Editor: Estelle Manticas Copy Editor: Kezia Endsley Interior Layout: Bill Hartman Cover Designer: Mike Tanamachi Indexer: Kelly Talbot Proofreader: Sara Gullion ActivePython, ActiveTcl, and ActiveState are registered trademarks of the ActiveState Corporation All other trademarks are the property of their respective owners Important: Premier Press cannot provide software support Please contact the appropriate software manufacturer’s technical support line or Web site for assistance Premier Press and the author have attempted throughout this book to distinguish proprietary trademarks from descriptive terms by following the capitalization style used by the manufacturer Information contained in this book has been obtained by Premier Press from sources believed to be reliable However, because of the possibility of human or mechanical error by our sources, Premier Press, or others, the Publisher does not guarantee the accuracy, adequacy, or completeness of any information and is not responsible for any errors or omissions or the results obtained from use of such information Readers should be particularly aware of the fact that the Internet is an ever-changing entity Some facts may have changed since this book went to press ISBN: 1-931841-57-8 Library of Congress Catalog Card Number: 2001099849 Printed in the United States of America 03 04 05 06 07 BH 10 Premier Press, a division of Course Technology 2645 Erie Avenue, Suite 41 Cincinnati, Ohio 45208 This book is dedicated to my parents, Ray and Sue, and to my sister Katherine, if for no other reason than the simple fact that they'd put me in a body bag if I forgot to so iv Foreword Programming games is so fun! The simple reason is that you get to code so many different types of subsystems in a game, regardless of whether it's a simple Pac Man clone or a complex triple-A tactical shooter Coding experience is very enriching, whether you’re writing a renderer, sound system, AI system, or the game code itself; all of these types of programming contain challenges that you get to solve The best way to code in any of these areas is with the most knowledge you can absorb beforehand This is why you should have a ton of programming books close at hand One area of game coding that hasn't gotten much exposure is scripting Some games don't need scripting—whether or not a game does is often dependant on your development environment and team—but in a lot of cases, using scripting is an ideal way of isolating game code from the main engine, or even handling in-game cinematics Most programmers, when faced with solving a particular coding problem (let's say handling NPC interaction, for instance), will usually decide to write their own elaborate custom language that integrates with their game code With the scripting tools available today this isn't strictly necessary, but boy is it fun! Many coders aren’t aware of the range of scripting solutions available today; that’s where this fine book comes in Game Scripting Mastery is the best way to dive into the mysterious world of game scripting languages You’ll learn what a scripting language is and how one is written; you’ll get to learn about Lua, Python, and Tcl and how to make them work with your game (I’m a hardcore proponent for Lua, by the way); and, of course, you’ll learn about compiler theory You’ll even get to examine how a full scripting language is developed! There's lots of knowledge contain herein, and if you love coding games, I'm confident that you'll enjoy finding out more about this aspect of game programming Have "The Fun!” John Romero v Acknowledgments It all started as I was standing around with some friends of mine on the second day of the 2001 Xtreme Game Developer's Conference in Santa Clara, California, discussing the Premier Press game development series At the time, I'd been doing a lot of research on the subject of compiler theory—specifically, how it could be applied to game scripting—and at the exact moment I mentioned that a scripting book would be a good idea, André Lamothe just happened to walk by "Let's see what he thinks," I said, and pulled him aside "Hey André, have you ever thought about a book on game scripting for your series?" I expected something along the lines of "that's not a bad idea", or "sure it's already in production." What I got was surprising, to say the least "Why don't you write it?" That was literally what he said Unless you're on some sort of weird version of Jeopardy! where the rules of the game require you to phrase your answer in the form of a book deal, this is a pretty startling response I blinked, thought about it for about a nanosecond, and immediately said okay This is how I handle most important decisions, but the sheer magnitude of the events that would be set into motion by this particular one could hardly have been predicted at the time Never question the existence of fate With the obligatory anecdote out of the way, there are a number of very important people I'd like to thank for providing invaluable support during the production of this book It'd be nothing short of criminal if this list didn't start with Mitzi Foster, my acquisitions editor who demonstrated what can only be described as superhuman patience during the turbulent submission and evolution of the book's manuscript Having to handle the eleventh-hour rewrites of entire chapters (and large ones at that) after they've been submitted and processed is an editor's nightmare— and only one of the many she put up with—but she managed to handle it in stride, with a consistently friendly and supportive attitude Next up is my copy editor, Kezia Endsley; if you notice the thorough grammatical correctness of even the comments in this book's code listings, you'll have her to thank Granted, it'll only be a matter of time before the latest version of Microsoft's compilers have a comment grammar checking paperclip, dancing monkey, robot dog, or ethnically ambiguous baby, but her eye for detail is safely appreciated for now Lastly, rounding out the Game Scripting Mastery pit crew is Estelle Manticas, my project editor who really stepped up to the plate during the later parts of the project, somehow maintaining a sense of humor while planet Earth crumbled around us Few people have what it takes to manage the workload of an entire book when the pressure's on, and she managed to make it look easy vi Of course, due to my relatively young age and penchant for burning through cash like NASA, I've relied on others to provide a roof over my head The honor here, not surprisingly, goes to my parents I'd like to thank my mom for spreading news of my book deal to every friend, relative, teacher, and mailman our family has ever known, and my dad for deciding that the best time to work so loudly on rebuilding the deck directly outside my room is somewhere around zero o'clock in the morning I also can't forget my sister, Katherine—her constant need for me to drive her to work is the only thing that keeps me waking up at a decent hour Thanks a lot, guys! And last, and most certainly least, I suppose I should thank that Lamothe guy Seriously though—I may have toiled endlessly on the code and manuscript, but André is the real reason this book happened (and was also its technical editor) I've gotta say thanks for letting my raid your fridge on a regular basis, teaching me everything I know about electrical engineering, dumping so many free books on me, answering my incessant and apparently endless questions, restraining yourself from ending our more heated arguments with a golf club, and of course, extending such an obscenely generous offer to begin with It should be known that there's literally no one else in the industry that goes out of their way to help people out this much, and I'm only one of many who've benefited from it I'd also like to give a big thanks to John Romero, who took time out of his understandably packed schedule to save the day and write the book's Foreword If not for him, I probably would've had to get my mom to it Oh and by the way, just because I think they'll get a kick out of it, I'd like to close with some horrendously geeky shout-outs: thanks to Ironblayde, xms and Protoman—three talented coders, and the few people I actually talk to regularly online—for listening to my constant ranting, and encouraging me to finish what I start (if for no other reason than the fact that I'll stop blabbering about it) You guys suck Seriously Now if you'll excuse me, I'm gonna wrap this up I feel like I'm signing a yearbook vii About the Author Alex Varanese has been obsessed with game development since the mid-1980's when, at age five, he first laid eyes—with both fascination and a strange and unexplainable sense of familiarity—on the 8-bit Nintendo Entertainment System He's been an avid artist since birth as well, but didn't really get going as a serious coder until later in life, at around age 15, with QBASIC He got his start as a professional programmer at age 18 as a Java programmer in the Silicon Valley area, working on a number of upstart B2B projects on the J2EE platform before working for about a year as both a semi-freelance and in-house graphic designer Feeling that life in the office was too restrictive, however, he's since shifted his focus back to game development and the pursuit of future technology He currently holds the position of head designer and systems architect for eGameZone (http://www.egamezone.net), the successor venture to André LaMothe's Xtreme Games LLC He spends his free time programming, rendering, writing about himself in the third person, yelling at popup ads, starring in an off-Broadway production of Dude, Where's My Car? The Musical, and demonstrating a blatant disregard for the posted speed limit Alex Varanese can be reached at alex@amvbooks.com, and is always ready and willing to answer any questions you may have about the book Please, don't hesitate to ask! viii Letter from the Series Editor A long, long, time ago on an 8-bit computer far, far, away, you could get away with hard coding all your game logic, artificial intelligence, and so forth These days, as they say on the Sopranos "forget about it.…" Games are simply too complex to even think about coding anymore—in fact, 99 percent of all commercial games work like this: a 3D game engine is developed, then an interface to the engine is created via a scripting language system (usually a very high-level language) based on a virtual machine The scripting language is used by the game programmers, and even more so the game designers, to create the actual game logic and behaviors for the entire game Additionally, many of the rules of standard programming, such as strict typing and single threaded execution, are broken with scripting languages In essence, the load of game development falls to the game designers for logic and game play, and to game programmers for the 3D engine, physics, and core technologies of the engine So where does one start when learning to use scripting in games? Well, there's a lot of stuff on the Internet of course, and you can try to interface languages like Python, Lau, and others to your game, but I say you should know how to it yourself from the ground up And that’s what Game Scripting Mastery is all about This book is a monster—Alex covers every detail you can possibly imagine about game scripting This is hard stuff, relatively speaking—we are talking about compiler theory, virtual machines, and multithreading here However, Alex starts off assuming you know nothing about scripting or compilers, so even if you’re a beginner you will be able to easily follow along, provided you take your time and work through the material By the end of the book you’ll be able to write a compiler and a virtual machine, as well as interface your language to ix your existing C/C++ game engine—in essence, you will have mastered game scripting! Also, you will never want to write another parser as long as you live In conclusion, if game scripting is something you’ve been interested in, and you want to learn it in some serious detail, then this book is the book for you Moreover, this is the only book on the market (as we go to publication) about this subject As this is the flagship treatise on game scripting, we’ve tried to give you everything we needed when figuring it out on our own— and I think we have done much, much more You be the judge! Sincerely, André LaMothe Series Editor ... that’s where this fine book comes in Game Scripting Mastery is the best way to dive into the mysterious world of game scripting languages You’ll learn what a scripting language is and how one is... programming books close at hand One area of game coding that hasn't gotten much exposure is scripting Some games don't need scripting whether or not a game does is often dependant on your development... virtual machine The scripting language is used by the game programmers, and even more so the game designers, to create the actual game logic and behaviors for the entire game Additionally, many

Ngày đăng: 03/02/2018, 11:35

Từ khóa liên quan

Mục lục

  • sample.pdf

    • sterling.com

      • Welcome to Sterling Software

Tài liệu cùng người dùng

Tài liệu liên quan