public override void Initialize() { base.Initialize(); new AssetCollector(this); GetService<AssetCollector>().LoadXML(@"Content/AsteroidsGame/assets.xml"); //Change bgcolor to black EntityGame.BackgroundColor = Color.Black; EntityGame.DebugInfo.Color = Color.White; _player = new PlayerShip(this, "PlayerShip"); //SpawnAsteroids(5); //TEST ASTEROIDS var a = new Asteroid(this, "Asteroid1"); a.Body.Position = new Vector2(300, 100); a.Physics.AddForce(-a.Physics.Force); var b = new Asteroid(this, "Asteroid2"); b.Body.Position = new Vector2(100, 100); b.Physics.AddForce(-b.Physics.Force); b.Physics.AddForce(30, 0); Page p = new Page(this, "Page"); p.Show(); _statusLabel = new Label(p, "StatusLabel", new Point(0, 0)); _statusLabel.Color = Color.White; _statusLabel.Visible = false; }
public void SpawnAsteroids(int num) { for (int i = 0; i < num; i++) { var a = new Asteroid(this, "Asteroid"); while (GetService<CollisionHandler>().ReturnManifolds(a.Collision).Count > 0) { a.Body.X = RandomHelper.GetFloat() * EntityGame.Viewport.Right; a.Body.Y = RandomHelper.GetFloat() * EntityGame.Viewport.Bottom; } } }