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); }
/// <summary> /// Creates a new Ship instance. /// </summary> /// <param name="player"> /// The player who owns the ship. /// </param> /// <param name="spriteSheet"> /// The Ship's rotational sprite sheet. /// </param> /// <param name="startingScreenPosition"> /// The Ship's starting screen position. /// </param> /// <param name="bulletSurface"> /// The surface for bullets fired by this ship. /// </param> /// <param name="infoBarShipSurface"> /// The surface that is displayed as the identifying icon in the /// InfoBar. /// </param> public Ship(Player player, SpriteSheet spriteSheet, Point startingScreenPosition, Surface bulletSurface, Surface infoBarShipSurface) : base(spriteSheet.AnimatedSprite) { this.player = player; this.spriteSheet = spriteSheet; // This is for the ship picture in the InfoBar. this.shipPhotoSurface = infoBarShipSurface; this.topSpeed = Configuration.Ships.TopSpeed; this.shields = Configuration.Ships.Shields.Power; this.X = startingScreenPosition.X; this.Y = startingScreenPosition.Y; this.Velocity = new Vector(); this.Life = -1; // Infinite life span. // Our next scheduled respawn time (i.e. never). this.respawnTime = DateTime.MinValue; this.speedLimiter = new SpeedLimit(this.topSpeed); this.forwardThruster = new Thruster(this, false, Configuration.Ships.Thrusters.Forward.SoundFilename, Configuration.Ships.Thrusters.Forward.Power, spriteSheet.ForwardThrusterEngineLength, Configuration.Ships.Thrusters.Forward.ExhaustConeDeg, Configuration.Ships.Thrusters.Forward.ParticleMinColor, Configuration.Ships.Thrusters.Forward.ParticleMaxColor); this.reverseThruster = new Thruster(this, true, Configuration.Ships.Thrusters.Reverse.SoundFilename, Configuration.Ships.Thrusters.Reverse.Power, spriteSheet.ReverseThrusterEngineLength, Configuration.Ships.Thrusters.Reverse.ExhaustConeDeg, Configuration.Ships.Thrusters.Reverse.ParticleMinColor, Configuration.Ships.Thrusters.Reverse.ParticleMaxColor); this.cannon = new Cannon(this, spriteSheet.CannonBarrelLength, bulletSurface, Configuration.Ships.Cannon.Power, Configuration.Ships.Cannon.Cooldown, Configuration.Ships.Cannon.MuzzleSpeed, Configuration.Bullets.Life); this.spawnTime = DateTime.Now; }