home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NeXTSTEP 3.0
/
NeXTSTEP3.0.iso
/
NextDeveloper
/
Examples
/
AppKit
/
BreakApp
/
BreakView.h
< prev
next >
Wrap
Text File
|
1992-03-15
|
3KB
|
116 lines
#import <appkit/View.h>
#import <dpsclient/dpsNeXT.h>
// Maximum number of tiles in the playing area...
#define NUMTILESX 8
#define NUMTILESY 20
#define NUMTILETYPES 2 // Number of different tile types.
#define TILEHEIGHT 18@// Tile size, in pixels
#define TILEWIDTH 28.0
#define INTERTILE 2.0
#define GAMEWIDTH ((TILEWIDTH+INTERTILE) * NUMTILESX) // Size of the field.
#define GAMEHEIGHT ((TILEHEIGHT+INTERTILE) * NUMTILESY)
@interface BreakView:View
{
int numTilesLeft, score, level, lives, highScore;
BOOL gameRunning, demoMode, soundEnabled;
DPSTimedEntry timer;
double lastFrameTime;
// The various pieces that know how to draw themselves on the field.
id tile[NUMTILETYPES];
// The actual array of tiles on the field. tiles[x][y] is the id of the
// tile that is at location x * TILEWIDTH, y * TILEHEIGHT.
short tiles[NUMTILESX][NUMTILESY];
id ball, paddle, backGround;
// The following six are outlets set when the nib file is being
// read in.
// Views that display various info (these can be nil, in which case the
// corresponding info will just go to the bit bucket).
id scoreView;
id livesView;
id levelView;
id hscoreView;
id statusView;
id wallSound;
id tileSound;
id paddleSound;
id missSound;
// Other ball & paddle params
float ballX, ballY, paddleX, paddleY, ballXVel, ballYVel, leftMargin;
NXSize ballSize, paddleSize, tileSize;
// These variables store the of the ball. Killer ball goes through tiles
// without bouncing; nice ball bounces from the top wall towards the paddle.
BOOL killerBall, niceBall;
// Number of revolutions left if the ball is rotating. If zero or
// less, than the ball is not rotating...
float revolutionsLeft;
float revolutionSpeed; // Radians per millisecond if rotating
}
// The following methods can be called by Interface Builder objects &
// during creation/destruction of instances of BreakView.
- initFrame:(const NXRect *)frm;
- free;
- gotoFirstLevel:sender; // Essentially a "new game"
- gotoNextLevel:sender; // Doesn't have to be explicitly called by user
- setDemoMode:sender; // Connect to switch with binary state
- setSoundOn:sender; // Connect to switch with binary state
- go:sender; // mouseDown: on the view does the same thing
- stop:sender;
- changeBackground:sender;
- revertBackground:sender;
// Methods to get back status of game.
- (int)score;
- (int)level;
- (int)lives;
// The following methods are internal and probably should not be@led
// by others.
- setBackgroundFile:(const char *)fileName andRemember:(BOOL)remember;
- setHighScore:(int)hScore;
- getHighScore;
- resizePieces;
- resetBallAndPaddle;
- directBallAt:(NXPoint *)dest;
- drawSelf:(NXRect *)rects :(int)rectCount;
- drawBackground:(NXRect *)rect;
- eraseBall;
- erasePaddle;
- showBall;
- showPaddle;
- incrementGameScore:(int)scoreIncrement;
-(BOOL) hitTileAt:(int)x :(int)y;
- step:(double)timeNow;
-(BOOL)acceptsFirstMouse;
- (void)playSound:sound atXLoc:(float)xLoc;
@end