Exemple #1
0
        public Game(Rectangle boundaries, Random random)
        {
            this.boundaries = boundaries;
            this.random     = random;

            playerShip = new PlayerShip(boundaries);
            livesLeft  = 3;
            NextWave();
        }
Exemple #2
0
 public Game(Random random, Rectangle playArea)
 {
     boundaries  = playArea;
     this.random = random;
     stars       = new Stars(boundaries, random);
     NextWave();
     playerShip   = new PlayerShip(boundaries);
     playerShots  = new List <Shot>();
     invaderShots = new List <Shot>();
 }
Exemple #3
0
        public Game(Random random, Rectangle formArea)
        {
            this.formArea = formArea;
            this.random = random;
            stars = new Stars(random, formArea);
            scoreLocation = new PointF((formArea.Left + 5.0F), (formArea.Top + 5.0F));
            livesLocation = new PointF((formArea.Right - 120.0F), (formArea.Top + 5.0F));
            waveLocation = new PointF((formArea.Left + 5.0F), (formArea.Top + 25.0F));
            playerShip = new PlayerShip(formArea,
                new Point((formArea.Width / 2), (formArea.Height - 50)));
            playerShots = new List<Shot>();
            invaderShots = new List<Shot>();
            invaders = new List<Invader>();

            nextWave();
        }
Exemple #4
0
        public Game(Random random, Rectangle formArea)
        {
            this.formArea = formArea;
            this.random   = random;
            stars         = new Stars(random, formArea);
            scoreLocation = new PointF((formArea.Left + 5.0F), (formArea.Top + 5.0F));
            livesLocation = new PointF((formArea.Right - 120.0F), (formArea.Top + 5.0F));
            waveLocation  = new PointF((formArea.Left + 5.0F), (formArea.Top + 25.0F));
            playerShip    = new PlayerShip(formArea,
                                           new Point((formArea.Width / 2), (formArea.Height - 50)));
            playerShots  = new List <Shot>();
            invaderShots = new List <Shot>();
            invaders     = new List <Invader>();


            nextWave();
        }
        public Game(Graphics g, Rectangle boundaries)
        {
            //Initialize the stars to plot a black background and to be able to add the stars to the
            //Canvas;
            this.g                 = g;
            this.boundaries.X      = 0;
            this.boundaries.Y      = 0;
            this.boundaries.Height = boundaries.Y;
            this.boundaries.Width  = boundaries.X;



            this.random = new Random();



            //Initializes two collections that keeps track of the shots fired respectively
            this.playerShots = new Shots();
            this.enemyShots  = new Shots();


            this.stars = new Stars(boundaries);
            Point initialPosition = new Point(boundaries.X / 2, boundaries.Y);

            this.playerShip = new PlayerShip(initialPosition, boundaries, playerShots, enemyShots, livesLeft);


            this.invaders = new Invaders(boundaries, playerShots, enemyShots, random, display);
            invaders.MoveInvaders();

            this.display = new Display(boundaries);



            //Plays the music for the life force
            System.Media.SoundPlayer player = new System.Media.SoundPlayer();
            player.SoundLocation = @"C:\GameMusic\LifeForce.wav";
            player.Load();
            player.Play();



            this.initialScreen = DateTime.Now;
            this.initialImage  = (Bitmap)Properties.Resources.ResourceManager.GetObject("LifeForce1");
        }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the Game class.
 /// </summary>
 /// <param name="boundaries">The rectangle representing the gaming area.</param>
 /// <param name="random">A Random for use with all inner functions requiring a random.</param>
 public Game(Rectangle boundaries, Random random)
 {
     /* initialize the two accepted parameters before
      * ANYTHING else.*/
     this.boundaries = boundaries;
     this.random     = random;
     this.playerShipStartingLocation = new Point(boundaries.Right - 100, boundaries.Bottom - 50);
     this.playerShip       = new PlayerShip(playerShipStartingLocation);
     this.playerShots      = new List <Shot>();
     this.invaderShots     = new List <Shot>();
     this.invaders         = new List <Invader>();
     this.livesLeftDisplay = new List <Bitmap>();
     this.stars            = new Stars(boundaries, random);
     for (int i = 0; i < livesLeft; i++)
     {
         livesLeftDisplay.Add(playerShip.GetLivesLeftImage());
     }
     NextWave();
 } // end constructor method Game
        public Game(Rectangle boundaries, Random random)
        {
            this.random = random;
            invaders = new List<Invader>();
            playerShip = new PlayerShip();

            playerShots = new List<Shot>();
            invaderShots = new List<Shot>();
            stars = new Stars(boundaries, random);

            this.boundaries = boundaries;

            for (int i = 1; i <= 1; i++)
            {
                for (int s = 0; s < 1; s++)
                {
                    invaders.Add(
                        new Invader((ShipType)s, new Point((s + 200), 100), 10));
                }
            }
        }
Exemple #8
0
 private void createPlayerShip()
 {
     playerShip = new PlayerShip(windowBoundaries, playableBoundaries) { Location = new Point(playableBoundaries.Width / 2, playableBoundaries.Height) };
 }