/// <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.mothershipStartingLocation = new Point(boundaries.Left + 40, 90); this.motherShipDirection = Direction.Right; this.motherShip = null; this.motherShipTravelArea = new Rectangle(new Point(boundaries.Left, 90), new Size(boundaries.Width, 40)); this.playerShip = new PlayerShip(playerShipStartingLocation); this.playerShots = new List<Shot>(); this.playerBombs = new List<Bomb>(); this.invaderShots = new List<Shot>(); this.invaders = new List<Invader>(); this.livesLeftDisplay = new List<Bitmap>(); this.deadInvaderExplosions = new List<Explosion>(); this.otherExplosions = new List<Explosion>(); this.deadInvaderScores = new List<ScoreFlash>(); this.mothershipHasAppeared = false; this.stars = new Stars(boundaries, random); for (int i = 0; i < livesLeft; i++) livesLeftDisplay.Add(playerShip.GetImage()); NextWave(); } // end constructor method Game
public Form1() { InitializeComponent(); random = new Random(); stars = new Stars(ClientRectangle); game = Game.GetInstance(); game.setClientRectangle(ClientRectangle); game.NextWave(); }
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>(); }
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(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"); }
/// <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)); } } }
public Game(Rectangle clientRectangle) { m_boundaries = clientRectangle; m_random = new Random(); m_stars = new Stars(m_random, m_boundaries); }