TweetFollow Us on Twitter

Games People Write
Volume Number:11
Issue Number:12
Column Tag:Book Review

Games People Write

Jump into games programming with advice from the experts.

By Mike Scanlin

Tricks of the Mac Game
Programming Gurus

By McCornack, Ragnemalm, Celestin,
et al.
Hayden Books, 1995
ISBN 1-56830-183-9
861 pages (softback) with CD-ROM. $50.00

The desire to write a computer game has probably recruited more people to study computer programming than any other kind of software. Certainly, this is true for me. It was 15 years ago when I asked for my allowance in quarters so I could go down to the local arcade and play games. I remember wondering how they made those games and thinking that it must be the coolest job in the world. Then came the day my grandfather gave me a 16K Apple ][ computer. As with many people, it changed my life. I became obsessed with learning everything there was to know about programming games. It was a slow process of trial-and-error, with lots of hacking and disassembling in between. I can only imagine how much quicker I could have learned everything if I’d had a book like Tricks of the Mac Game Programming Gurus back then. I would have saved so much time that I might have gone outside once in a while, had a few friends and maybe even gone to the movies occasionally.

While there is much to be said for figuring out how to do something on your own, there is also something to be said for not reinventing the wheel all the time. This book explains and solves many of the problems you will encounter while writing a Macintosh game. It will give you enough of the basics so that you can concentrate on game playability, good graphics, and sounds, rather than figuring out things like how to hide the menu bar, how to create preferences and saved game files, and how to correctly let people configure their keyboard controls independent of their country or keyboard model.

This book was written by many people, each explaining everything he knows about his area of expertise (graphics, sound, QuickDraw 3D, networking, PowerPC, etc.). There is not much source code printed in the book (for space reasons - it’s a big book as it is), but the accompanying CD-ROM has lots of documented source code on it.

The beginning of the book reviews GWorlds, GDevices, CopyBits, PixMaps and palettes. For the uninitiated these concepts can be overwhelming, but the author does a good job of telling you just what you need to know to get started. There is a simple demo application called Clem the Clam that shows a little animated clam walking across a background (with appropriate masking). It’s a great app to learn and experiment with.

There is a chapter on how to make good sound (overlapping sounds, background music, etc.), as well as a discussion of an included code library called Hollywood. This library allows you to play AIFF files, 'snd' resources, mono, stereo, MACE-compressed, streaming sound, 8-bit sound or 16-bit sound, and it can do them all at once. This is a great way to get up and running using sounds with minimal effort. The only effort is coming up with good sounds for your game. The mechanics of playing them from within your game are taken care of for you.

A similarly useful chapter covers networking. Taking advantage of the Macintosh’s built-in networking capability has never been easier. It covers AppleTalk in detail (ATP and DDP), and goes into Apple’s new networking protocol, OpenTransport, as well. Once you’ve read this material you will no longer be intimidated by the concept of writing a network game. As in the sound chapter, the grunt work of networking has been taken care of for you. Now you just have to come up with a good network game idea.

Once you’ve got sounds and networking under control, the remaining areas to concentrate on are graphics and game design. Throughout the book there are references to little tricks with graphics: fast blitters, masks, working with offscreen PixMaps, optimizing for CopyBits. I especially like the one discussing how to encode (and compress) 8-bit indexed images so that your blitters are faster. You’ll find there are many examples using 8-bit indexed images. That seems to be the appropriate lowest common denominator you should shoot for if you want to reach the broadest possible Macintosh audience. It also makes porting to non-Macintosh systems easiest (there is a complete chapter on porting and what to consider).

Game design is, of course, the hardest part of any good game. This book has taken care of many of the mechanical aspects involved in writing a good Macintosh game, but it can’t solve the creativity problem for you. It’s up to you to work with good artists, good musicians and good creative people to make your game really fun to play. There are a couple of chapters on how to make the entities in your game appear realistic. The equations for realistic collisions, distance covered by diagonal movement, acceleration due to gravity, etc., are given along with clear diagrams.

Several optimization tips are given, including: using fixed-point math when you can (velocity calculations), using the floating-point registers on a PowerPC as the fastest way to write your blitting loops (for maximum data transfer throughput), using aligned data on the 603 and 604 (which sped up one game’s blit loop by a factor of two when compared to the unaligned case), and using no more than 8 parameters per function so the PowerPC can pass them in registers. There are other details, too, but I’ll let you ferret them out on your own by reading the book.

I strongly recommend this book to anyone considering writing his or her first game. I also recommend it to people who are unfamiliar with sound or networking. Those skills can be useful even in non-game applications.

Having said all that, there are some things about this book I didn’t like. For starters, it really does feel like it was written by many different people. There are places where it’s redundant. I’m not sure I need to be told how to hide the menu bar in three different ways in three different chapters. That tends to confuse, more than help. Which is the best way to hide it? I still don’t know. It would have been great, too, if they could have gotten everyone to agree to a common set of coding guidelines and naming conventions. Consistency enhances comprehension when you’re looking at someone else’s code.

Several of the authors suggest boosting speed by using tables to look up various things (entity behavior, dungeon maps, etc.). While I applaud that technique, I would have made more things resource-driven instead of using static data in the source code. Perhaps, though, the authors used static data for demonstration purposes (to avoid adding the complication of custom resource templates), or for portability reasons.

While some of the authors are very good at explaining their optimizations and why they did things a certain way, others are not. For example, one of the code snippets calls MoreMasters() four times during initialization with a comment that says, “so we won’t run out of handles”. But the phrase “run out of handles” is misleading, because the issue is memory fragmentation, not running out of handles. Nowhere is it explained how to determine the appropriate number of preallocated master pointers (i.e. by exercising your program thoroughly and then looking in the heap to see how many were created).

There are a couple of typographical problems, such as the occasional double-hyphen in the source code (a post-decrement) being converted into an em-dash by some overly aggressive file translator. I’m not sure if novice programmers will know that x-; means x--; (I guess they’ll have to figure it out when they try to compile). Throughout the book there are “Note” paragraphs set on top of solid 10% gray rectangles. Maybe it’s just the copy that I received but about half of those paragraphs were missing the background rectangle or it was so light that you couldn’t see it. The result is that as you’re reading the text you sometimes come across what seems to be a completely disjointed paragraph. Not a big deal once you’ve encountered it a couple of times, though, because you know to skip it and keep reading the text in the following paragraph.

There are also some things that are downright strange. Apparently, one of the authors is Swedish because some of the screen shots contain Swedish text and buttons in the Open/Save dialogs. That adds confusion in an English book because the text around those dialogs was discussing how to save and load games, not how to internationalize. Also, there is a chapter called “Aesthetics” which emphasizes that a consistent look-and-feel can help your game, but then goes on to label the OK button as “Okay” in a standard Macintosh dialog (right next to a Cancel button). To anyone with Macintosh experience, it looks distinctly odd and unnecessarily different.

Despite the above problems, the code is readable and the game logic and diagrams are clean. Also, in a series of interviews, published Macintosh game authors answer some of the non-technical questions most curious readers will have, such as, “How many people worked on that game?”, “How long did it take?” and “What tools did you use?” If you would like to see the sun, have friends, have time to go to the movies or maybe just learn a bit on how to write a Macintosh game, then you should read this book.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Typinator 9.1 - Speedy and reliable text...
Typinator turbo-charges your typing productivity. Type a little. Typinator does the rest. We've all faced projects that require repetitive typing tasks. With Typinator, you can store commonly used... Read more
ESET Cyber Security 6.11.414.0 - Basic i...
ESET Cyber Security provides powerful protection against phishing, viruses, worms, and spyware. Offering similar functionality to ESET NOD32 Antivirus for Windows, ESET Cyber Security for Mac allows... Read more
Opera 105.0.4970.29 - High-performance W...
Opera is a fast and secure browser trusted by millions of users. With the intuitive interface, Speed Dial and visual bookmarks for organizing favorite sites, news feature with fresh, relevant content... Read more
Slack 4.35.131 - Collaborative communica...
Slack brings team communication and collaboration into one place so you can get more work done, whether you belong to a large enterprise or a small business. Check off your to-do list and move your... Read more
Viber 21.5.0 - Send messages and make fr...
Viber lets you send free messages and make free calls to other Viber users, on any device and network, in any country! Viber syncs your contacts, messages and call history with your mobile device, so... Read more
Hazel 5.3 - Create rules for organizing...
Hazel is your personal housekeeper, organizing and cleaning folders based on rules you define. Hazel can also manage your trash and uninstall your applications. Organize your files using a familiar... Read more
Duet 3.15.0.0 - Use your iPad as an exte...
Duet is the first app that allows you to use your iDevice as an extra display for your Mac using the Lightning or 30-pin cable. Note: This app requires a iOS companion app. Release notes were... Read more
DiskCatalogMaker 9.0.3 - Catalog your di...
DiskCatalogMaker is a simple disk management tool which catalogs disks. Simple, light-weight, and fast Finder-like intuitive look and feel Super-fast search algorithm Can compress catalog data for... Read more
Maintenance 3.1.2 - System maintenance u...
Maintenance is a system maintenance and cleaning utility. It allows you to run miscellaneous tasks of system maintenance: Check the the structure of the disk Repair permissions Run periodic scripts... Read more
Final Cut Pro 10.7 - Professional video...
Redesigned from the ground up, Final Cut Pro combines revolutionary video editing with a powerful media organization and incredible performance to let you create at the speed of thought.... Read more

Latest Forum Discussions

See All

‘Sonic Dream Team’ Apple Arcade Review –...
What an unusual day we have arrived upon today. Now, Sonic the Hedgehog games aren’t a new thing for iOS gaming. The original Sonic the Hedgehog appeared on the classic iPod, so the Blue Blur got in the doors as fast as you would expect him to. The... | Read more »
PvP Basketball Game ‘NBA Infinite’ Annou...
Level Infinite and Lightspeed Studios just announced a new real-time PvP basketball game for mobile in the form of NBA Infinite (). NBA Infinite includes solo modes as well, collecting and upgrading current NBA players, managing teams, and more. It... | Read more »
New ‘Dysmantle’ iOS Update Adds Co-Op Mo...
We recently had a major update hit mobile for the open world survival and crafting adventure game Dysmantle ($4.99) from 10tons Ltd. Dysmantle was one of our favorite games of 2022, and with all of its paid DLC and updates, it is even better. | Read more »
PUBG Mobile pulls a marketing blinder wi...
Over the years, there have been a lot of different marketing gimmicks tried by companies and ambassadors, some of them land like Snoop Dog and his recent smoking misdirection, and some are just rather frustrating, let’s no lie. Tencent, however,... | Read more »
‘Goat Simulator 3’ Mobile Now Available...
Coffee Stain Publishing and Coffee Stain Malmo, the new mobile publishing studio have just released Goat Simulator 3 on iOS and Android as a premium release. Goat Simulator 3 debuted on PS5, Xbox Series X|S, and PC platforms. This is the second... | Read more »
‘Mini Motorways’ Huge Aurora Borealis Up...
Mini Motorways on Apple Arcade, Nintendo Switch, and Steam has gotten a huge update today with the Aurora Borealis patch bringing in Reykjavik, new achievements, challenges, iCloud improvements on Apple Arcade, and more. Mini Motorways remains one... | Read more »
Fan-Favorite Action RPG ‘Death’s Door’ i...
Last month Netflix revealed during their big Geeked Week event a number of new titles that would be heading to their Netflix Games service. Among them was Acid Nerve and Devolver Digital’s critically acclaimed action RPG Death’s Door, and without... | Read more »
SwitchArcade Round-Up: Reviews Featuring...
Hello gentle reader, and welcome to the SwitchArcade Round-Up for December 4th, 2023. I’ve been catching up on my work as much as possible lately, and that translates to a whopping six reviews for you to read today. The list includes Astlibra... | Read more »
‘Hi-Fi Rush’ Anniversary Interview: Dire...
Back in January, Tango Gameworks and Bethesda released one of my favorite games of all time with Hi-Fi Rush. As someone who adores character action and rhythm games, blending both together seemed like a perfect fit for my taste, but Hi-Fi Rush did... | Read more »
Best iPhone Game Updates: ‘Pizza Hero’,...
Hello everyone, and welcome to the week! It’s time once again for our look back at the noteworthy updates of the last seven days. Things are starting to chill out for the year, but we still have plenty of holiday updates ahead of us I’m sure. Some... | Read more »

Price Scanner via MacPrices.net

Apple is clearing out last year’s M1-powered...
Apple has Certified Refurbished 11″ M1 iPad Pros available starting at $639 and ranging up to $310 off Apple’s original MSRP. Each iPad Pro comes with Apple’s standard one-year warranty, features a... Read more
Save $50 on these HomePods available today at...
Apple has Certified Refurbished White and Midnight HomePods available for $249, Certified Refurbished. That’s $50 off MSRP and the lowest price currently available for a full-size Apple HomePod this... Read more
New 16-inch M3 Pro MacBook Pros are on sale f...
Holiday MacBook deals are live at B&H Photo. Apple 16″ MacBook Pros with M3 Pro CPUs are in stock and on sale for $200-$250 off MSRP. Their prices are among the lowest currently available for... Read more
Christmas Deal Alert! Apple AirPods Pro with...
Walmart has Apple’s 2023 AirPods Pro with USB-C in stock and on sale for $189.99 on their online store as part of their Holiday sale. Their price is $60 off MSRP, and it’s currently the lowest price... Read more
Apple has Certified Refurbished iPhone 12 Pro...
Apple has unlocked Certified Refurbished iPhone 12 Pro models in stock starting at $589 and ranging up to $350 off original MSRP. Apple includes a standard one-year warranty and new outer shell with... Read more
Holiday Sale: Take $50 off every 10th-generat...
Amazon has Apple’s 10th-generation iPads on sale for $50 off MSRP, starting at $399, as part of their Holiday Sale. Their discount applies to all models and all colors. With the discount, Amazon’s... Read more
The latest Mac mini Holiday sales, get one to...
Apple retailers are offering Apple’s M2 Mac minis for $100 off MSRP as part of their Holiday sales. Prices start at only $499. Here are the lowest prices available: (1): Amazon has Apple’s M2-powered... Read more
Save $300 on a 24-inch iMac with these Certif...
With the recent introduction of new M3-powered 24″ iMacs, Apple dropped prices on clearance M1 iMacs in their Certified Refurbished store. Models are available starting at $1049 and range up to $300... Read more
Apple M1-powered iPad Airs are back on Holida...
Amazon has 10.9″ M1 WiFi iPad Airs back on Holiday sale for $100 off Apple’s MSRP, with prices starting at $499. Each includes free shipping. Their prices are the lowest available among the Apple... Read more
Sunday Sale: Apple 14-inch M3 MacBook Pro on...
B&H Photo has new 14″ M3 MacBook Pros, in Space Gray, on Holiday sale for $150 off MSRP, only $1449. B&H offers free 1-2 day delivery to most US addresses: – 14″ 8-Core M3 MacBook Pro (8GB... Read more

Jobs Board

Mobile Platform Engineer ( *Apple* /AirWatch)...
…systems, installing and maintaining certificates, navigating multiple network segments and Apple /IOS devices, Mobile Device Management systems such as AirWatch, and Read more
Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Senior Product Manager - *Apple* - DISH Net...
…Responsibilities** We are seeking an ambitious, data-driven thinker to assist the Apple Product Development team as our Wireless Product division continues to grow Read more
Senior Product Manager - *Apple* - DISH Net...
…Responsibilities** We are seeking an ambitious, data-driven thinker to assist the Apple Product Development team as our Wireless Product division continues to grow Read more
Senior Software Engineer - *Apple* Fundamen...
…center of Microsoft's efforts to empower our users to do more. The Apple Fundamentals team focused on defining and improving the end-to-end developer experience in Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.