Happy Face CTB Game
Volume Number: 13
Issue Number: 2
Column Tag: Communications Toolbox
HappyFace
By Mark Chally, Covina, California
Using the Communications Toolbox to build an interactive,
two-player game
The purpose of this article is to implement a simple, two-player, interactive game as
a means to explore Apple's Macintosh Communications Toolbox. It includes methods for
using the Connection Manager to send and receive information. This article builds on
the fundamentals learned in the DebugTerm article, found in MacTech 12.10 (October,
1996).
Introduction to HappyFace. Where did it come from?
After DebugTerm went to press, I suggested a follow-up article to further exploit the
CTB. I thought a simple game would be entertaining and instructive. Time was short,
but the challenge was exciting. Of several possible game ideas, HappyFace was the clear
choice, having the advantages of simplicity and entertainment value.
Long before Barney the dinosaur would be loathed by adults everywhere, there were
happy faces. Surely you remember the little yellow pill-shaped guys with Kool-Aid
grins, found on T-shirts, pins, and bumper stickers accompanied by "Have a Nice
Day." Soon, T-shirts displayed happy faces with bullet holes in their foreheads from
which blood oozed. Later, arcade games appeared in which players would use mallets to
strike gophers' heads as they poked up through holes. Finally, Mike Darweesh wrote
the Macintosh game "Bonk," based on the gopher games. In Bonk, players click on silly
heads as they appear in a grid, before they disappear - at progressively shorter
intervals. HappyFace was inspired by that weird combination of sarcasm and gaming.
How do you play it?
HappyFace is a two-player game that gives you the opportunity to smack those little
yellow critters. You use the CTB to connect with your opponent. HappyFace does not
care what tool is used to establish the connection, but it does expect the tool to support
a means to simultaneously send and receive data using the standard CTB functions.
Most, if not all connection tools do this. You earn points by striking the faces as they
appear on a grid. The first player having 25 points wins.
When launched, if HappyFace cannot find the preferences file in the program's folder
it poses the Connection Settings dialog (Figure 1).
Figure 1. Connection Settings Dialog with Apple Modem Tool's default options.
If the user cancels the dialog, the program beeps and aborts. Otherwise, it creates a
game window with 64 squares, eight rows and eight columns. HappyFace then waits for
the user to establish a connection, which is initiated using the Connect, Listen, and
Settings items on the Connection menu.
Once a connection has been established, either player may select New Game from the
File menu. When the game begins, each player's copy creates five happy faces which
inhabit randomly selected squares in both players' windows (Figure 2).
Figure 2. The HappyFace window with no faces struck.
Each player may then strike happy faces by clicking on them using the cursor - which
becomes a mallet whenever it is positioned over the window. As the faces are struck,
their features (eyes and mouths) change color and shape. Faces which have not been
struck have blue features. Those struck by the player using the local copy receive
green features, and those struck by the opponent receive red ones (Figure 3).