This is SwarmView.h in view mode; [Download] [Up]
/* SwarmView.h Define the SwarmView class and it's instance variables. The number of instance variables is minimizes - until there are controls to modify the constants, there is no reason to have them in, and can often prevent gratuitous subclassing. Original Version: Kurt Werle Mod Dec 16 1991, Scott Byer - took out many instance variables, added array pointers for the encoded user path coodinates and ops. Made a straight subclass of View, not of BackView. */ #import <appkit/View.h> #import "Thinker.h" // Constants #define TRUE 1 #define FALSE 0 #define BEES 75 /* Initial number of bees */ #define MAXBEES 500 /* maximum number of bees */ #define BEEACC 3 /* Max bee acceleration - odd integer. */ #define WASPACC 7 /* Max wasp acceleration - odd integer. */ #define BEEVEL 15 /* Max bee velocity - odd integer. */ #define WASPVEL 9 /* Max wasp velocity - odd integer. */ #define BORDER 50 /* Border within the screen boundaries for wasp. */ #define COORDS (MAXBEES+1) #define VIEW_WIDTH ((int)bounds.size.width) #define VIEW_HEIGHT ((int)bounds.size.height) /* Coordinate holding structure that can be passed directly into DPSDoUserPath, and the macros for accessing them when doing the calculations. */ typedef int DrawCds[COORDS][2][2]; typedef int BBox[4]; #define COORDS_SIZE (sizeof(DrawCds) / sizeof(int)) #define BBOX_SIZE (sizeof(BBox) / sizeof(int)) #define DRAW_BASE (drawCds) #define ERASE_BASE (eraseCds) #define WX(t) ((*drawCds)[0][(t)][0]) /* addressing into dynamic array */ #define WY(t) ((*drawCds)[0][(t)][1]) /* addressing into dynamic array */ #define OWX(t) ((*eraseCds)[0][(t)][0]) /* addressing into dynamic array */ #define OWY(t) ((*eraseCds)[0][(t)][1]) /* addressing into dynamic array */ #define WXV (xv[0]) #define WYV (yv[0]) #define X(t,b) ((*drawCds)[(b)][(t)][0]) /* addressing into dynamic array */ #define Y(t,b) ((*drawCds)[(b)][(t)][1]) /* addressing into dynamic array */ #define OX(t,b) ((*eraseCds)[(b)][(t)][0]) /* addressing into dynamic array */ #define OY(t,b) ((*eraseCds)[(b)][(t)][1]) /* addressing into dynamic array */ #define RAND(v) ((random() % v) - (v/2)) /* random number around 0 */ /* For bounding box calculations. */ #define MINMAX(val, min, max) if (val < (min)) (min) = val; \ if (val > (max)) (max) = val #define RESET_BBOX (*drawBBox)[0] = VIEW_WIDTH; \ (*drawBBox)[1] = VIEW_HEIGHT; \ (*drawBBox)[2] = 0; \ (*drawBBox)[3] = 0 #define BUMP_BBOX(xVal, yVal) MINMAX(xVal, (*drawBBox)[0], (*drawBBox)[2]); \ MINMAX(yVal, (*drawBBox)[1], (*drawBBox)[3]) /* Macros for copying the draw coordinaes into the erase coordinates. */ #define COPY_CDS { register DrawCds *temp = drawCds; \ drawCds = eraseCds ; eraseCds = temp; } #define COPY_BBOX { register BBox *temp = drawBBox; \ drawBBox = eraseBBox; eraseBBox = temp; } @interface SwarmView:View { int stage; /* Count up until init time. */ int bees; /* Current number of bees. */ int cursorwasp; /* Use the cursor as wasp position? */ // Bee tracking and display. DrawCds spaceOne; /* Space to hold coordinates. */ DrawCds spaceTwo; DrawCds *drawCds; /* Pointer that is actually used. */ DrawCds *eraseCds; int xv[COORDS]; /* Bee velocities, x direction. */ int yv[COORDS]; /* Bee velocities, y direction. */ BBox bboxOne; /* Space to hold bbox. */ BBox bboxTwo; BBox *drawBBox; /* Pointer that is actually used. */ BBox *eraseBBox; char ops[COORDS * 2]; /* Storage for operator array. */ // Outlets into preferences window. id inspectorPanel; // Preferences Window id beeText; // Number of Bees id slider; // Slider that reflects the number of bees. } - initFrame:(const NXRect *)frameRect; - initSwarmView; - initValues; - (BOOL)ignoreMouseMovement; - (const char *)windowTitle; - inspector: sender; - oneStep; - drawSelf:(const NXRect *)rects :(int)rectCount; - setNumberBees: sender; - setFollow: sender; @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.