public OrbitClash() { Video.WindowIcon(); Video.SetVideoMode(Configuration.DisplaySize.Width, Configuration.DisplaySize.Height, false); Video.WindowCaption = Configuration.Title; Mixer.ChannelsAllocated = Configuration.MaxSoundChannels; this.theGameHasBegun = false; this.particleSystem = new ParticleSystem(); this.mainTitle = new MainTitle(); Surface infoBarSurface = new Surface(Configuration.InfoBar.ImageFilename); this.infoBar = infoBarSurface.Convert(Video.Screen, true, false); // Player 1. this.player1 = new Player(1); this.player1.LeftKey = Configuration.Controls.Player1.Left; this.player1.RightKey = Configuration.Controls.Player1.Right; this.player1.UpKey = Configuration.Controls.Player1.Up; this.player1.DownKey = Configuration.Controls.Player1.Down; this.player1.FireKey = Configuration.Controls.Player1.Fire; // Player 2. this.player2 = new Player(2); this.player2.LeftKey = Configuration.Controls.Player2.Left; this.player2.RightKey = Configuration.Controls.Player2.Right; this.player2.UpKey = Configuration.Controls.Player2.Up; this.player2.DownKey = Configuration.Controls.Player2.Down; this.player2.FireKey = Configuration.Controls.Player2.Fire; this.bulletShipImpactSound = new Sound(Configuration.Bullets.BulletShipImpactSoundFilename); this.bulletShipImpactSound.Volume = Configuration.SoundVolume; this.bulletShipImpactBounceSound = new Sound(Configuration.Bullets.BulletShipImpactBounceSoundFilename); this.bulletShipImpactBounceSound.Volume = Configuration.SoundVolume; this.bulletPlanetImpactSound = new Sound(Configuration.Bullets.BulletPlanetImpactSoundFilename); this.bulletPlanetImpactSound.Volume = Configuration.SoundVolume; this.shipShipImpactSound = new Sound(Configuration.Ships.ShipShipImpactSoundFilename); this.shipShipImpactSound.Volume = Configuration.SoundVolume; // Setup screen bounce-boundary manipulator. this.boundaryManipulator = new ParticleBoundary(new Rectangle(Configuration.PlayArea.Location, Configuration.PlayArea.Size)); this.particleSystem.Manipulators.Add(this.boundaryManipulator); // Set up star-background. Surface backgroundSurface = new Surface(Configuration.PlayAreaBackgroundImageFilename); this.background = backgroundSurface.Convert(Video.Screen, true, false); // Setup the planet. Point planetLocation = new Point(Configuration.PlayArea.Width / 2, Configuration.PlayArea.Height / 2); this.planet = new Planet(Configuration.Planet.ImageFilename, Configuration.Planet.ImageTransparentColor, planetLocation, Configuration.Planet.ImageScale); this.particleSystem.Add(this.planet); // Draw the planetary halo onto the background. if (Configuration.Planet.ShowPlanetaryHalo) { Point haloPosition = new Point(this.planet.Center.X - Configuration.Planet.GravityWellRadius, this.planet.Center.Y - Configuration.Planet.GravityWellRadius); this.background.Blit(this.planet.HaloSurface, haloPosition); } // Setup the gravity manipulator. this.gravityManipulator = new GravityWell(this.planet.Center, Configuration.Planet.GravityWellRadius, Configuration.Planet.GravityPower); this.particleSystem.Manipulators.Add(this.gravityManipulator); // Setup speed limit manipulator. this.speedLimitManipulator = new SpeedLimit(Configuration.UniversalSpeedLimit); //this.particleSystem.Manipulators.Add(this.speedLimitManipulator); Events.KeyboardDown += new EventHandler<KeyboardEventArgs>(this.KeyboardDown); Events.KeyboardUp += new EventHandler<KeyboardEventArgs>(this.KeyboardUp); Events.Fps = Configuration.Fps; Events.Tick += new EventHandler<TickEventArgs>(this.Tick); Events.Quit += new EventHandler<QuitEventArgs>(this.Quit); }
private void Impact(Ship ship, Planet planet) { Player player = (ship.Player.Number == 1) ? this.player1 : this.player2; this.particleSystem.Particles.Add(player.ExplosionEffect.Explode(ship.Center)); ship.Die(); player.ScoreCard.Suicides++; }
private void Impact(Planet planet, Bullet bullet) { bullet.Life = 0; try { this.bulletPlanetImpactSound.Play(); } catch { // Must be out of sound channels. } }
protected virtual void Dispose(bool disposing) { if (!this.disposed) { // We haven't been disposed yet. if (disposing) { /* The method has been called directly or indirectly by a * user's code. Dispose of managed resources here. */ if (this.mainTitle != null) { this.mainTitle.Dispose(); this.mainTitle = null; } if (this.background != null) { this.background.Dispose(); this.background = null; } if (this.planet != null) { this.planet.Dispose(); this.planet = null; } if (this.player1.Ship != null) { this.player1.Ship.Dispose(); this.player1.Ship = null; } if (this.player2.Ship != null) { this.player2.Ship.Dispose(); this.player2.Ship = null; } if (this.player1 != null) { this.player1.Dispose(); this.player1 = null; } if (this.player2 != null) { this.player2.Dispose(); this.player2 = null; } if (this.bulletShipImpactBounceSound != null) { this.bulletShipImpactBounceSound.Dispose(); this.bulletShipImpactBounceSound = null; } if (this.bulletPlanetImpactSound != null) { this.bulletPlanetImpactSound.Dispose(); this.bulletPlanetImpactSound = null; } if (this.bulletShipImpactSound != null) { this.bulletShipImpactSound.Dispose(); this.bulletShipImpactSound = null; } if (this.shipShipImpactSound != null) { this.shipShipImpactSound.Dispose(); this.shipShipImpactSound = null; } } // Dispose of unmanaged resources _only_ out here. this.disposed = true; } }