This is CrapsView.m in view mode; [Download] [Up]
#import "CrapsView.h" #import "../NEXTVegas/NEXTVegas.h" #import "craps.h" #import "Craps.h" static id _puckOnImage; static id _puckOffImage; static id _puckSound; @implementation CrapsView + initialize { id myBundle = [NXBundle bundleForClass:self]; char path[MAXPATHLEN+1]; if(self == [CrapsView class]) { if ([myBundle getPath:path forResource:"puckOn" ofType:"eps"]) _puckOnImage = [[NXImage allocFromZone:[self zone]] initFromFile:path]; if ([myBundle getPath:path forResource:"puckOff" ofType:"eps"]) _puckOffImage = [[NXImage allocFromZone:[self zone]] initFromFile:path]; if ([myBundle getPath:path forResource:"puck" ofType:"snd"]) _puckSound = [[SoundEffect allocFromZone:[self zone]] initFromSection:path]; } return self; } - initFrame:(const NXRect *)frameRect { return [super initFrame:frameRect]; } - awakeFromNib { NXSize puckSize; [_puckOnImage getSize:&puckSize]; puckPoint.x = bounds.size.width/2 - puckSize.width/2; puckPoint.y = bounds.size.height - puckSize.height - 4.0; return self; } - puckOn:(BOOL)flag { puckOn = flag; [self display]; if(puckOn && doSound) { [_puckSound play:1.0 pan:0.0]; } return self; } - drawSelf:(const NXRect *)rects :(int)rectCount { [super drawSelf:rects :rectCount]; if(puckOn) if(tag == DONT_COME) [_puckOffImage composite:NX_SOVER toPoint:&puckPoint]; else [_puckOnImage composite:NX_SOVER toPoint:&puckPoint]; return self; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.