This is ArrayBonusTracker.m in view mode; [Download] [Up]
#import <gamekit/gamekit.h> static int _defaultBonusArray = 0; @implementation ArrayBonusTracker - init { return [self initForBonuses:&_defaultBonusArray count:1]; } - initForBonuses:(int *)bonusArray count:(int)num { // we copy the array in... int i; // set up array before super init because it will call resetBonus, // which expects this data to be present already. if (valuesArray) free(valuesArray); valuesArray = (int *)NXZoneMalloc([self zone], sizeof(int) * num); for (i=0; i<num; i++) valuesArray[i] = bonusArray[i]; count = num; [super init]; return self; } - advanceBonus { bonusIndex++; if (bonusIndex >= count) bonusIndex = count - 1; value = valuesArray[bonusIndex]; return self; } - retreatBonus { bonusIndex--; if (bonusIndex < 0) bonusIndex = 0; value = valuesArray[bonusIndex]; return self; } - setMin:(int)newMin max:(int)newMax { return self; } // No-op - resetBonus { bonusIndex = 0; value = valuesArray[bonusIndex]; return self; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.