Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
MoofWars/MoofWars.h
/* |
File: MoofWars.h |
Contains: All of the standard application conditionals are defined in this header, |
along with all of the global variables declared by the game. |
Written by: Timothy Carroll |
Copyright: Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved. |
You may incorporate this Apple sample source code into your program(s) without |
restriction. This Apple sample source code has been provided "AS IS" and the |
responsibility for its operation is yours. You are not permitted to redistribute |
this Apple sample source code as "Apple sample source code" after having made |
changes. If you're going to re-distribute the source, we require that you make |
it clear in the source that the code was descended from Apple sample source |
code, but that you've made changes. |
Change History (most recent first): |
7/2/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1 |
2/24/97 Timothy Carroll Moved conditional builds to an external file so |
that error macros can be loaded separate from MoofWars.h |
1/23/97 Timothy Carroll Conditionalized inclusion of MacHeadersPPC |
so that MrC will compile |
1/23/97 Timothy Carroll Moved the Error Macros to an external file. |
8/15/96 Timothy Carroll Initial Release |
*/ |
#ifndef _MOOFWARS_ |
#define _MOOFWARS_ |
#pragma once |
#include <Quickdraw.h> |
#include <Palettes.h> |
#include <DrawSprocket.h> |
// 2/24/97 |
// We now include the app conditionals from a separate file to prevent library files |
// from needing to specifically include our MoofWars header by name. |
#include "AppConditionals.h" |
// Moved the error macros out to the generic libraries, since I use them in other |
// projects. |
#include "Error Macros.h" |
/********************************************************************************* |
OTHER NECESSARY HEADERS |
*********************************************************************************/ |
#include "TCommandTimer.h" |
#include "Scaling.h" |
#include "TGraphicCollection.h" |
#if qUsingSound |
#include "Hollywood.h" |
#endif |
/********************************************************************************* |
CONSTANTS |
*********************************************************************************/ |
// A few standard colors -- probably should use palette calls instead! |
const RGBColor kWhite = {0xFFFF, 0xFFFF, 0xFFFF}; |
const RGBColor kBlack = {0x0000, 0x0000, 0x0000}; |
const RGBColor kDarkBlue = {0x0000,0x0000,0x7000}; |
const RGBColor kLtGrey = {0xC000,0xC000,0xC000}; |
const RGBColor kMediumGrey = {0x7FFF,0x7FFF,0x7FFF}; |
// The ResID of the application's color table. All of my custom graphics routines use |
// an 8-bit color table and the sprite is encoded to use these colors. The actual variable |
// to hold the color table is declared below. |
enum { |
kAppColorTableResID = 128 |
}; |
// Various constants used to load the background tile and sprite graphics. |
enum { |
kGridResourceID = 500, |
kShipResourceID = 1000, |
kShotResourceID = 1001, |
kEnemyResourceID = 1003 |
}; |
// A few keys on the keyboard -- these are the ones I use right now, at least until I add |
// a real configuration dialog. |
enum |
{ |
kEscapeKey = 0x35, |
kPauseKey = 0x71, |
kUpKey = 0x7E, |
kDownKey = 0x7D, |
kLeftKey = 0x7B, |
kRightKey = 0x7C, |
kPeriod = 0x2F, |
kComma = 0x2B, |
kZKey = 0x06, |
kXKey = 0x07, |
kCKey = 0x08, |
kVKey = 0x09, |
kAKey = 0x00, |
kOne = 0x12, |
kTwo = 0x13, |
kThree = 0x14, |
kFour = 0x15, |
kZero = 0x1D |
}; |
// Here's the actual mapping of the keys above to functions on the keyboard. Change these |
// to change the key settings. |
enum |
{ |
kExitGame = kEscapeKey, |
kDebugger = kPauseKey, |
kShipRotateLeft = kComma, |
kShipRotateRight = kPeriod, |
kShipApplyThrust = kUpKey, |
kShipFireShot = kLeftKey, |
kShipFireCluster = kRightKey, |
kEnemyRotateLeft = kZKey, |
kEnemyRotateRight = kXKey, |
kEnemyThrustForward = kCKey, |
kEnemyThrustBackward = kVKey, |
kEnemyFireShots = kAKey, |
kPlaySoundOne = kOne, |
kPlaySoundTwo = kTwo, |
kPlaySoundThree = kThree, |
kPlaySoundFour = kFour, |
kSoundToggle = kZero |
}; |
/********************************************************************************* |
VARIABLES |
*********************************************************************************/ |
// Holds the bounds of the playing field. |
extern WorldRect32 gWorldBounds; |
// The main color table described above |
extern CTabHandle gAppColorTable; |
// Our draw sprocket context. |
extern DSpContextReference gDrawContext; |
// And a running total of the number of shots on the board. We only keep this if |
// we are going to display this number on the screen. |
#if qShowTiming |
extern long gShotsOnBoard; |
#endif |
// Holds the current state of the keyboard and other input devices when processing |
// the list of sprites. |
extern TInputState gCommandKeys; |
// A standard set of lookup tables in 16.16 fixed notation, so that we can quickly |
// do sin and cos. We currently use 48 frames because thats easy to do from |
// Specular Infini-D. 360/48 = 7.5¡ per angle. |
extern long gSinLookup[48]; |
extern long gCosLookup[48]; |
// Currently we are using the hollywood API, we'll either change to our own API or |
// remove sound code before shipping. |
#if qUsingSound |
extern SndReference gSounds[10]; |
extern Boolean gPlayingSound; |
#endif |
// These hold all of the games graphics. We export these because we can create |
// sprites faster if it is already known that the sprites are loaded. |
extern TGraphicCollection *gShipGraphics; |
extern TGraphicCollection *gEnemyGraphics; |
extern TGraphicCollection *gShotGraphics; |
/********************************************************************************* |
FUNCTIONS |
*********************************************************************************/ |
// This checks a particular key value against the 128-bit number returned by GetKeys. |
extern Boolean CheckKey (unsigned char *PtrToKeyMap, short theKey); |
#endif /* _MOOFWARS_ */ |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-10-14