
Untitled
By: a guest on
Apr 17th, 2012 | syntax:
None | size: 1.01 KB | hits: 6 | expires: Never
-(Person*) initWithHome:(City*)h {
self = [self init];
home = h;
myZ = 0.0f;
myZvel = 0.01f;
pos = [home.pos get];
// pos = [Vector3d addVector:home.pos ToVector:[[Vector3d alloc] initWithX:[artist randomBetween:-0.1f And:0.1f] Y:[artist randomBetween:-0.1f And:0.1f]]];
float xo = (float)random() / RAND_MAX;
float yo = (float)random() / RAND_MAX;
#define PEOPLE_SPREAD 0.05f
xo *= PEOPLE_SPREAD;
yo *= PEOPLE_SPREAD;
xo -= PEOPLE_SPREAD / 2.0f;
yo -= PEOPLE_SPREAD / 2.0f;
[pos addVector:[[Vector3d alloc] initWithX:xo Y:yo]];
//NSLog(@"yo ");
float speed = [self newSpeed];
if((float)random() / RAND_MAX > 0.5f) {
if((float)random() / RAND_MAX > 0.5f) {
vel = [[Vector3d alloc] initWithX:speed Y:0.0f];
} else {
vel = [[Vector3d alloc] initWithX:-speed Y:0.0f];
}
} else {
if((float)random() / RAND_MAX > 0.5f) {
vel = [[Vector3d alloc] initWithX:0.0f Y:speed];
} else {
vel = [[Vector3d alloc] initWithX:0.0f Y:-speed];
}
}
return self;
}