public void Reset() { next_spawn = 0; for (int index = 0; index < 360; index++) { planets[index] = null; } player.Initialize(blackhole, SpriteFactory.GetSprite("Earth"), 0, 250f, 10, player_mas * SCALE, player_vel * SCALE); }
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); }
public GameManager(GameController controller, int width, int height) { this.controller = controller; this.width = width; this.height = height; threshhold = (float)Math.Atan((float)height / width); blackhole = new Blackhole(controller, width, height); blackhole.Initialize(SpriteFactory.GetSprite("Blackhole"), new Vector2(width / 2, height / 2), 10); Sprite cover = SpriteFactory.GetSprite("BlackHoleCover"); cover.Opacity = 0.8f; blackhole.Extra.Add(cover); player = new Computer(controller, 100); player.Maximum = 200; player.Initialize(blackhole, SpriteFactory.GetSprite("Earth"), 0, 250f, 10, player_mas * SCALE, player_vel * SCALE); next_spawn = 0; }