|
|
1.1 ! root 1: // BoinkSpaceView ! 2: // ! 3: // a subclass of BoinkView that adds a space view subview for special effect ! 4: // ! 5: // You may freely copy, distribute, and reuse the code in this example. ! 6: // NeXT disclaims any warranty of any kind, expressed or implied, as to its ! 7: // fitness for any particular use. ! 8: ! 9: #import "BoinkSpaceView.h" ! 10: #import "Thinker.h" ! 11: #import <appkit/Application.h> ! 12: #import <dpsclient/wraps.h> ! 13: ! 14: @implementation BoinkSpaceView ! 15: ! 16: - oneStep ! 17: { ! 18: // this is weird but efficient - focus is locked on this View, and ! 19: // spaceview goes ahead and draws on it. It's like subviews, only ! 20: // faster because all coordinate systems are kept the same... ! 21: ! 22: [super oneStep]; ! 23: ! 24: avoid.origin = redrawTo; ! 25: [mySpaceView setVoidRect:&avoid]; ! 26: [mySpaceView oneStep]; ! 27: ! 28: return self; ! 29: } ! 30: ! 31: - initFrame:(const NXRect *)frameRect ! 32: { ! 33: [super initFrame:frameRect]; ! 34: ! 35: mySpaceView = [[SpaceView alloc] initFrame:frameRect]; ! 36: [self setAccel:-1.4]; ! 37: ! 38: [self newViewSize]; ! 39: avoid.size.width = avoid.size.height = 100; ! 40: return self; ! 41: } ! 42: ! 43: - sizeTo:(NXCoord)width :(NXCoord)height ! 44: { ! 45: [super sizeTo:width :height]; ! 46: [mySpaceView sizeTo:width :height]; ! 47: [self newViewSize]; ! 48: return self; ! 49: } ! 50: ! 51: - drawSelf:(const NXRect *)rects :(int)rectCount ! 52: { ! 53: if (!rects || !rectCount) return self; ! 54: ! 55: PSsetgray(0); ! 56: //NXRectFill(rects); ! 57: ! 58: return self; ! 59: } ! 60: ! 61: - (float) getXspeed ! 62: { ! 63: return randBetween(4, 6.5); ! 64: } ! 65: ! 66: - (const char *)windowTitle ! 67: { ! 68: return "BoinkSpace"; ! 69: } ! 70: ! 71: - newViewSize ! 72: { ! 73: [super newViewSize]; ! 74: nvert = nhoriz = 0; ! 75: return self; ! 76: } ! 77: ! 78: - didLockFocus ! 79: { ! 80: [mySpaceView didLockFocus]; ! 81: return self; ! 82: } ! 83: ! 84: @end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.