File:  [NeXTSTEP 3.3 examples] / Examples / AppKit / BreakApp / BreakView.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:48:39 2018 UTC (8 years, 1 month ago) by root
Branches: NeXT, MAIN
CVS tags: NeXTSTEP33, HEAD
Sample Programs from NeXSTEP 3.3

#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.0  // 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
- setSoundMode: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 called
// 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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.