This is XWBullet.m in view mode; [Download] [Up]
#import "XWBullet.h"
#import "XoxWars.h"
extern int xw_nastyShots;
extern int xw_bulletMass;
@implementation XWBullet
- activate:sender :(int)tag
{
NXSize tsize = {8,8};
NXSize t2 = {4, 4};
Actor *dude = (Actor *)sender;
float xfactor = -sin(dude->theta), yfactor = cos(dude->theta);
float bulletDistance = xw_nastyShots ? 9 : 4;
[super activate:sender :tag];
speed = xw_bulletSpeed;
[self reinitWithImage:(dude->alliance == GOOD ?
"spbullet0" : "spbullet1")
frameSize:&tsize
numFrames:8
shape: RECTCIRC
alliance: xw_nastyShots ? DESTROYALL : dude->alliance
radius: 2
buffered: NO
x: dude->x + (dude->radius + bulletDistance) * xfactor
y: dude->y + (dude->radius + bulletDistance) * yfactor
theta: dude->alliance == GOOD ? 0 : PI
vel: dude->vel + speed
interval: 80
distToCorner: &t2];
xv = dude->xv + xfactor * speed;
yv = dude->yv + yfactor * speed;
expireTime = timeInMS + 1900;
min_frame = 0;
max_frame = 7;
return self;
}
- positionChanged
{
if (xw_bounce)
[self bounceAtDistance: (xOffset) :(yOffset)];
else
[self wrapAtDistance: (xOffset+10) :(yOffset+10)];
[super positionChanged];
return self;
}
#define MAXV 105
- calcDxDy:(NXPoint *)dp
{
if (xw_gravity && xw_bulletMass) [self swApplyGravity];
if (xv > MAXV) xv = MAXV;
else if (xv < -MAXV) xv = -MAXV;
if (yv > MAXV) yv = MAXV;
else if (yv < -MAXV) yv = -MAXV;
return [super calcDxDy:(NXPoint *)dp];
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.