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

//  BoinkSpaceView
//
//  a subclass of BoinkView that adds a space view subview for special effect
//
//  You may freely copy, distribute, and reuse the code in this example.
//  NeXT disclaims any warranty of any kind, expressed or  implied, as to its
//  fitness for any particular use.

#import "BoinkSpaceView.h"
#import "Thinker.h"
#import <appkit/Application.h>
#import <dpsclient/wraps.h>

@implementation BoinkSpaceView

- oneStep
{
	// this is weird but efficient - focus is locked on this View, and
	// spaceview goes ahead and draws on it.  It's like subviews, only
	// faster because all coordinate systems are kept the same...

	[super oneStep];

	avoid.origin = redrawTo;
	[mySpaceView setVoidRect:&avoid];
	[mySpaceView oneStep];

	return self;
}

- initFrame:(const NXRect *)frameRect
{
	[super initFrame:frameRect];
	
	mySpaceView = [[SpaceView alloc] initFrame:frameRect];
	[self setAccel:-1.4];
	
	[self newViewSize];
	avoid.size.width = avoid.size.height = 100;
	return self;
}

- sizeTo:(NXCoord)width :(NXCoord)height
{
	[super sizeTo:width :height];
	[mySpaceView sizeTo:width :height];
	[self newViewSize];
	return self;
}

- drawSelf:(const NXRect *)rects :(int)rectCount
{
	if (!rects || !rectCount) return self;
	
	PSsetgray(0);
	//NXRectFill(rects);

	return self;
}

- (float) getXspeed
{
	return randBetween(4, 6.5);
}

- (const char *)windowTitle
{
	return "BoinkSpace";
}

- newViewSize
{
	[super newViewSize];
	nvert =	nhoriz = 0;
	return self;
}

- didLockFocus
{
	[mySpaceView didLockFocus];
	return self;
}

@end

unix.superglobalmegacorp.com

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