/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); // TODO: Add your drawing code here //Calculate translation to centre screen Globals.translation = Globals.Centre - thePlayer.mPosition; spriteBatch.Begin(); if (thePlayer.health > 0) { for (int i = 0; i < thePlanets.Length; i++) { thePlanets[i].Draw(spriteBatch); } thePlayer.Draw(spriteBatch); spriteBatch.DrawString(font, thePlayer.health.ToString(), thePlayer.mTranslation, Color.White); spriteBatch.DrawString(font, "Score : " + score.ToString(), Globals.topRight, Color.White); for (int i = 0; i < theShips.Count; i++) { theShips[i].Draw(spriteBatch); } for (int i = 0; i < theShipsType2.Count; i++) { theShipsType2[i].Draw(spriteBatch); } for (int i = 0; i < myBullets.Count; i++) { if (myBullets[i].alive == true) { myBullets[i].Draw(spriteBatch); } } for (int i = 0; i < enemyBullets.Count; i++) { if (enemyBullets[i].alive == true) { enemyBullets[i].Draw(spriteBatch); } } //spriteBatch.DrawString(font, thePlayer.mPosition.ToString(), new Vector2(20, 45), Color.White); //Draw Radar!! //one pixel per ship/planet //radar is in top left corner Globals.radarTranslation = Globals.Universe / 2 - thePlayer.mPosition; spriteBatch.Draw(Globals.radarBackground, Vector2.Zero, Color.White); for (int i = 0; i < theShips.Count; i++) { Vector2 pos = theShips[i].mPosition; pos += Globals.radarTranslation; pos = Globals.wrapAround(pos); pos = pos / Globals.grainSize; spriteBatch.Draw(Globals.redPixel, pos, Color.White); } for (int i = 0; i < theShipsType2.Count; i++) { Vector2 pos = theShipsType2[i].mPosition; pos += Globals.radarTranslation; pos = Globals.wrapAround(pos); pos = pos / Globals.grainSize; spriteBatch.Draw(Globals.redPixel, pos, Color.White); } for (int i = 0; i < thePlanets.Length; i++) { Vector2 pos = thePlanets[i].mPosition; pos += Globals.radarTranslation; pos = Globals.wrapAround(pos); pos = pos / Globals.grainSize; spriteBatch.Draw(Globals.yellowPixel, pos, Color.White); } } else { Vector2 nwGgPosition = new Vector2(thePlayer.mTranslation.X, thePlayer.mTranslation.Y); nwGgPosition.X = nwGgPosition.X - 120; spriteBatch.DrawString(font, thePlayer.gameOver, nwGgPosition, Color.Red, 0, new Vector2(0, 0), 3.0f, SpriteEffects.None, 1); nwGgPosition.Y = nwGgPosition.Y - 120; spriteBatch.DrawString(font, "Score : " + score.ToString(), nwGgPosition, Color.Red, 0, new Vector2(0, 0), 3.0f, SpriteEffects.None, 1); } //loading.Draw(spriteBatch); spriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { // TODO: Add your drawing code here //Calculate translation to centre screen Globals.translation = Globals.Centre - thePlayer.mPosition; spriteBatch.Begin(); //Globals.radarTranslation = Globals.Universe / 2 - thePlayer.mPosition; spriteBatch.Draw(Globals.Background, Vector2.Zero, Color.White); if (thePlayer.mHealth < 0) { spriteBatch.DrawString(font, "GameOver", new Vector2(500, 500), Color.Red); //this.Exit(); } thePlayer.Draw(spriteBatch); EnemyManager.Draw(gameTime, spriteBatch, updateWaveOne, updateWaveTwo); for (int i = 0; i < thePlayer.mRockets.Length; i++) { if (thePlayer.mRockets[i].alive == true) { thePlayer.mRockets[i].Draw(spriteBatch); } } for (int i = 0; i < thePlanets.Length; i++) { thePlanets[i].Draw(spriteBatch); } //spriteBatch.DrawString(font, thePlayer.mPosition.ToString(), new Vector2(20, 45), Color.White); //Draw Radar!! //one pixel per ship/planet //radar is in top left corner Globals.radarTranslation = Globals.Universe / 2 - thePlayer.mPosition; spriteBatch.Draw(Globals.radarBackground, Vector2.Zero, Color.White); for (int i = 0; i < EnemyManager.startingShips; i++) { if (EnemyManager.theShips[i].alive == true) { Vector2 pos = EnemyManager.theShips[i].mPosition; pos += Globals.radarTranslation; pos = Globals.wrapAround(pos); pos = pos / Globals.grainSize; spriteBatch.Draw(Globals.redPixel, pos, Color.White); } } if (updateWaveOne) { for (int i = 0; i < EnemyManager.waveOneCount; i++) { if (EnemyManager.waveOne[i].alive == true) { Vector2 pos = EnemyManager.waveOne[i].mPosition; pos += Globals.radarTranslation; pos = Globals.wrapAround(pos); pos = pos / Globals.grainSize; spriteBatch.Draw(Globals.redPixel, pos, Color.White); } } } if (updateWaveTwo) { for (int i = 0; i < EnemyManager.waveTwoCount; i++) { if (EnemyManager.waveTwo[i].alive == true) { Vector2 pos = EnemyManager.waveTwo[i].mPosition; pos += Globals.radarTranslation; pos = Globals.wrapAround(pos); pos = pos / Globals.grainSize; spriteBatch.Draw(Globals.redPixel, pos, Color.White); } } } for (int i = 0; i < thePlanets.Length; i++) { Vector2 pos = thePlanets[i].mPosition; pos += Globals.radarTranslation; pos = Globals.wrapAround(pos); pos = pos / Globals.grainSize; spriteBatch.Draw(Globals.yellowPixel, pos, Color.White); } //GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Draw(healthBar, healthRec, Color.White); spriteBatch.End(); base.Draw(gameTime); }