Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 17th, 2012  |  syntax: None  |  size: 1.01 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. -(Person*) initWithHome:(City*)h {
  2.         self = [self init];
  3.         home = h;
  4.         myZ = 0.0f;
  5.         myZvel = 0.01f;
  6.         pos = [home.pos get];
  7. //      pos = [Vector3d addVector:home.pos ToVector:[[Vector3d alloc] initWithX:[artist randomBetween:-0.1f And:0.1f] Y:[artist randomBetween:-0.1f And:0.1f]]];       
  8.         float xo = (float)random() / RAND_MAX;
  9.         float yo = (float)random() / RAND_MAX;
  10.        
  11.         #define PEOPLE_SPREAD 0.05f
  12.  
  13.         xo *= PEOPLE_SPREAD;
  14.         yo *= PEOPLE_SPREAD;
  15.         xo -= PEOPLE_SPREAD / 2.0f;
  16.         yo -= PEOPLE_SPREAD / 2.0f;
  17.         [pos addVector:[[Vector3d alloc] initWithX:xo Y:yo]];
  18.  
  19.         //NSLog(@"yo ");
  20.         float speed = [self newSpeed];
  21.         if((float)random() / RAND_MAX > 0.5f) {
  22.                 if((float)random() / RAND_MAX > 0.5f) {        
  23.                         vel = [[Vector3d alloc] initWithX:speed Y:0.0f];
  24.                 } else {
  25.                         vel = [[Vector3d alloc] initWithX:-speed Y:0.0f];                      
  26.                 }
  27.         } else {
  28.                 if((float)random() / RAND_MAX > 0.5f) {        
  29.                         vel = [[Vector3d alloc] initWithX:0.0f Y:speed];
  30.                 } else {
  31.                         vel = [[Vector3d alloc] initWithX:0.0f Y:-speed];
  32.                 }              
  33.         }
  34.        
  35.         return self;
  36. }