Exemple #1
0
 public void Update(GameTime game_time)
 {
     player.Update(game_time);
     blackhole.Update(game_time);
     next_spawn -= (float)game_time.ElapsedGameTime.TotalSeconds;
     if (next_spawn <= 0)
     {
         next_spawn += spawn_time / SCALE;
         Asteroid planet    = new Asteroid(controller);
         float    radius    = 10;
         float    mass      = 100;// + (float)(random.NextDouble() * 200);
         int      int_angle = random.Next(0, 360);
         if (planets[int_angle] == null)
         {
             float angle = (float)(int_angle * Math.PI / 180 - Math.PI);
             float distance;
             float abs_angle = Math.Abs(angle);
             if (abs_angle > threshhold && abs_angle < Math.PI - threshhold)
             {
                 distance = Math.Abs(height / (float)(2 * Math.Sin(angle)));
             }
             else
             {
                 distance = Math.Abs(width / (float)(2 * Math.Cos(angle)));
             }
             distance -= planet.Radius + blackhole.Radius;
             planet.Initialize(blackhole, SpriteFactory.GetSprite("Circle"), angle, distance, radius, 1.5f * mass * SCALE);
             planets[int_angle] = planet;
         }
     }
     if (player.Check(blackhole))
     {
         Reset(); return;
     }
     for (int index = 0; index < 360; index++)
     {
         Asteroid planet = planets[index];
         if (planet != null)
         {
             if (CircularObject.Collide(blackhole, planet))
             {
                 blackhole.Affect(planet);
                 planets[index] = null;
             }
             else
             {
                 planet.Update(game_time);
                 if (player.Check(planet))
                 {
                     Reset(); return;
                 }
             }
         }
     }
     player.Test(game_time);
 }