ftp.nice.ch/pub/next/developer/resources/libraries/gamekit_proj.NI.sa.tar.gz#/gamekit_proj/gamekit-1/GameActor.m

This is GameActor.m in view mode; [Download] [Up]

/* Generated by Interface Builder */

// Handles moving and rendering various moving objects.

#import <gamekit/gamekit.h>
#import <stdio.h>


@implementation GameActor

- init				// initialize the new instance vars
{
	[super init];
	myX = 0; myY = 0;
	lastx = 0; lasty = 0;
	px = 0; py = 0; scale = 1;
	return self;
}

- move:sender				// Move the Actor one animation frame
{	// you must override this and put something here
	return self;
}

- at:(float *)xx :(float *)yy		// where is the actor now?
{
	*xx = myX;
	*yy = myY;
	return self;
}

- lastAt:(float *)xx :(float *)yy	// called to find out where actor is
{
	*xx = lastx;
	*yy = lasty;
	return self;
}

- (int)xpos { return myX; }	// return our x-coord

- (int)ypos { return myY; }	// return our y-coord

- moveOneFrame	// moves the actor along; access directly or via renderAt::move:
{
	myX += px;
	myY += py;
	return self;
}

- renderAt:(int)posx :(int)posy move:(BOOL)moveOk	// draw actor
		// you should lock focus on view that gets the actor first.
{		// this should be overridden by the actor subclass
	if (moveOk) [self moveOneFrame];
	lastx = myX;
	lasty = myY;
	return self;
}

- (int)scale
{
	return scale;
}

- setScale:(int)newScale
{
	if ((newScale < 1) || (newScale > 2)) return self;
	scale = newScale;
	return self;
}


@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.