ebook img

Tricks of the Mac Game Programming Gurus PDF

886 Pages·1995·169.216 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Tricks of the Mac Game Programming Gurus

Fellow Game Programmers\ P<ogr.unm;ng top-quality game' i' "'°more fun than playing lltem-Every time a - grune prog<.mm« gcl'' paycheck, <oy"1ty p,ymen<. o< re&i'uation fee, a g<in c<nne' ,1ong wilh iL "Can you believe it, l get to do thi' nW """· pU'h what'' po"ible on lhe M", exe<eit;<• my bnlln, and ).ugh while I'm doing it - and they give me money, too!" lf you ate on< of the'e people, OL you want to be, thi' book i' fo< you. ThIB IB a "h"'d' on" book - not too much theo<Y ,.d a whole lot of pmcti<>C-You< guide' h.ve ,peot lhe" time in me uenche,, and they know the diffe<ence between truking •bout prog<""' ming ond ,ol\ing up thei< ,ieeve' and doing it. Grune p<og"mnUng i' oomplex, and wilh G•" me Macin""h like the oiliet p"'tfotm') , garo<' "e where me cutting-edge of me prog"mming art i' honed. Grune''"' where the Mac ,hnW' its "uff-how quickly it "n mainpulate d.ta. how ,mooilily it oan P'"""t moving Un•g<'. how deatlY it can tep<oduce ,ouni\, and mufilc, how compaclly it can ,tore complex iofonnatioo. lf you oan m""' Macinto'h grune p<Og"-nuning, "mund"'e" pro"""'°"ing will be a piece of c"1<e-The technique' u'"'1 in gume' tod,Y will be u.,d in multimedia next ye><. and will be found in business presentations the year after that. Out ,uilio<' have encl> .,lected a ,peciol topic to oove< in depili You won't trreeze through thi• book - it'• too jam-packed full of ioloon•tion - but you will find me infmmation ea'Y to integ<ate into yom own p<ojocts. The CD-ROM i' full ofU'eful code-mud> of it wriuen e,pecially fo< thi' book, and .,me of it taken direct ftom popu l" gum<' ftom top pubU,he"-But don't wo<<Y. we got lhe prog<anun«'' penni"ion to use the code - we got the programmers to write the book! Ple"" ""d you< oonunents on iliIB boOk. ,.d you< ,uggeati-OR' lo< ou< next book on Mac grune developmen4 di,-ectly to me, o< to <he publi,het. We k•OW you'll find thi' book ""'fol and infonnative, and we hope you have Ion wiili it, too-We hope you hav as much fun using this book as we did writing it! Sincerely, :5~)/_c-t Jamie McCornack Project Editor MacGameDev on America Online [email protected] Read this book and no longer will you wonder wliat it11J Mac game. You'll know how to make graphics and so the Mac Game Programming Gurus tells you what to and why to do it, and a whole lot more, besides gi · the game gurus use. Plus, you get the tools (don't fotg the book!) you need to get the job done. But don't take my word for it Read the book and tell Mac Game Programming Gurus lives in the Don cf8 delivers the inside goods on game programming games. Let it be your companion for finding and* in your gray matter. See you on the ether, @il U~~©~~ U[fo~ rnvtJ~©® @ @. [fffiJ @ ~ ~@ ~ ~@ ~ ~ ITffiJ ITffiJ ITU @J ~ ~ 01J 01J by Mccornack, Ragnemalm, Celestin, et al. Tricks of the Mac® Game Programming Gurus ©1995 Hayden Books, a division of Macmillan Computer Publishing All rights reserved. Printed in the United States of America. No part of this book may be used or reproduced in any form or by any means, or stored in a database or retrieval system, without prior written permission of the publisher except in the case of brief quotations embodied in critical articles and reviews. Making copies of any part of this book for any purpose other than your own personal use is a violation of United States copyright laws. For information, address Hayden Books, 201W.103rd Street, Indianapolis, Indiana 46290. Library of Congress Catalog Number: 95-60416 ISBN: 1-56830-183-9 This book is sold as is, without warranty of any kind, either express or implied. While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information or instructions contained herein. It is further stated that the publisher and author are not respon sible for any damage or loss to your data or your equipment that results directly or indirectly from your use of this book. 97 96 95 4 3 2 Interpretation of the printing code: The rightmost double-digit number is the year of the book's printing; the rightmost single-digit number is the number of the book's printing. For example, a printing code of 95-1 shows that the first printing of the book occurred in 1995. Trademark Acknowledgments: All products mentioned in this book are either trademarks of the companies referenced in this book, registered trademarks of the companies referenced in this book, or neither. We strongly advise that you investi gate a particular product's name thoroughly before you use the name as your own. Apple, Mac, and Macintosh are registered trademarks of Apple Computer, Inc. The Hayden Books Team Publisher Publishing Coordinator David Rogelberg Rosemary Lewis Product Development Manager Interior Designer Patrick Gibbons Fred Bower Acquisitions Editor Cover Designer Stacy Kaplan Jay Corpus Development Editor Production Brad Miser Angela Calvert, Dan Caparo, Kim Cofer, Kevin Foltz, David Garratt, Shawn Copy /Production Editor MacDonald, Joe Millay, Erika Millen, Beth Rago, Regina Rexrode, Erich J. Steve Mulder · Richter, Christine Tyner, Karen Walsh, Robert Wolf Technical Reviewers · MarkAdams Indexer Stuart Cheshire Bront Davis Dennis Cohen Brian Greenstone Jake Hoelter Interviewer Tom Thompson To Our Readers Hayden Books 201West103rd Street Dear Friend, Indianapolis, IN 46290 Thank you on behalf of everyone at (800) 428-5331 voice Hayden Books for choosing Tricks of the (800) 448-3804 fax Mac Game Programming Gurus to enable you to explore game programming on the Macintosh. For many reasons, the Email addresses: Mac is the best platform for games, and America Online: Hayden Bks fortunately games on the Mac are Apple Link: hayden.books exploding in both quality and popular CompuServe: 76350,3014 ity. This book will help you make your Internet: [email protected] own contribution to this growth. We'd love to see any games that this book helps you with. Please write and let us know. What you think of this book is important to our ability to better serve you in the future. If you have any comments, no matter how great or small, we'd appreciate you taking the time to send us email or a note by snail mail. Of course, we'd love to hear your book ideas. Sincerely yours, - J/_:.t You can reach Hayden Books at the following: Contents at a Glance 0 A Game Programming Primer ........................................................... 1 1 Your First Game ............................................................................... 41 2 Basic Game Graphics ....................................................................... 87 3 Advanced Graphics ........................................................................ 121 4 File Management ........................................................................... 209 5 User Interaction .............................................................................. 265 6 Audio .............................................................................................. 327 7 Game Mechanics: Environments and Entities ............................... 389 8 Game Mechanics: Behavior ........................................................... 433 9 QuickDraw 3D ............................................................................... 491 10 Networking .................................................................................... 547 11 Porting ............................................................................................ 627 12 Game Aesthetics ............................................................................. 709 13 Optimizing Game Code for PowerPC ............................................ 731 14 Glypha III: A Case Study ............................................................... 749 A Top Speed-or Not? ...................................................................... 797 B Macintosh Environments ............................................................... 811 Index .............................................................................................. 843 Table of Contents 0 A Grune Programming Primer ........................................................... 1 Animation Basics ........................................................................ 2 What's Animation? ............................................................... 2 How Quick Is Quick Enough? ............................................. 2 How Smooth Is Smooth Enough? ........................................ 4 How Fast Is Too Fast? .......................................................... 5 The Hello World Code .............................................. ·. .................. 6 HelloWorldl: Bare Bones .................................................... 6 HelloWorld2: Color and Complexity ................................. 16 HelloWorld3: Clams in Formation ..................................... 23 HelloW orld4: Clruns in Collision ....................................... 25 HelloWorld5: Clruns in Multibit ........................................ 26 HelloWorld6: 8 Bits Preferred ........................................... 28 HelloWorld6. l: No Brakes ................................................. 30 Some Sound Advice .................................................................. 30 Sound Markers ................................................................... 31 Synchronous vs. Asynchronous Sound .............................. 32 MGWSound.c .................................................................... 32 What Do I Do Next? ................................................................. 39 1 Your First Game ............................................................................... 41 Dungeon I ................................................................................. 41 Graphics ............................................................................. 42 Sounds ................................................................................ 43 Moving Around and Fighting ............................................. 44 Random Numbers .............................................................. 45 Let's See Some Source Code! ................................................... 45 Building Dungeon .............................................................. 46 Understanding Dungeon .................................................... 46 Declarations, Constants, and Variables .............................. 46 Subroutines ........................................................................ 49 The Main Progrrun ............................................................. 58 But How about My Own First Game? ...................................... 59 Problem 1: A Good Idea .................................................... 60 Can You Do It? ................................................................... 61 Can the Computer Do It? ................................................... 61 Can Your Players Do It? ..................................................... 64 All Those Games ....................................................................... 65 2-D Space Games ............................................................... 65 Platform Games ................................................................. 66 Side-Scrollers ..................................................................... 67 Board Games and Puzzle Games ....................................... 69 Card Games ........................................................................ 70 First-Person 3-D Action Games ......................................... 71 Adventure Games ............................................................... 72 Dungeon-Digging Games .................................................. 74 Abstract Action Games ...................................................... 75 Simulation Games .............................................................. 77 Strategy Games .................................................................. 77 Programmer's Games ......................................................... 79 Dungeon 1 Plus ......................................................................... 80 Map Generation ................................................................. 80 Source Code Additions ...................................................... 80 Leaving the Game .............................................................. 85 2 Basic Game Graphics ....................................................................... 87 Color Theory ............................................................................. 87 How to Dress Better ........................................................... 88 Comparing RGB and RYB ................................................. 89 The Color Wheel ................................................................ 90 Using Color Wisely ............................................................ 91 HSV and the Color Picker .................................................. 92 Indexed and Direct Graphics Hardware .................................... 96 Direct Devices .................................................................... 96 Fixed Devices ..................................................................... 96 Indexed Devices and Color Tables ..................................... 96 Palettes and the Palette Manager ............................................... 99 Using Palettes ................................................................... 102 Drawing with Palettes ...................................................... 105 Palette Animation ............................................................. 106 Of GWorlds and GDevices ...................................................... 108 A Graphic Buffer, Pixmap, and CopyBi ts () Primer ....... 108 Why Use an Off-Screen? ................................................. 109 GWorlds ........................................................................... 110 GDevices .......................................................................... 113 Game Graphics Programming ................................................. 116 Multiple Monitor Tactics ................................................. 116 Fading Strategies .............................................................. 117 Hiding the Menu Bar Suavely .......................................... 118 Your Friend, CopyBits() ................................................. 118

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.