// Draw public static void Draw(PlayerShip player1, PlayerShip player2, SkyBox skyBox, SpriteBatch spriteBatch) { // Draw skybox skyBox.Draw(camera.View, camera.Projection, ((ArcBallCamera)camera).Position); // Draw menu items spriteBatch.Begin(); // Draw transparent background spriteBatch.Draw(bg, new Rectangle(0, 0, 1920, 1080), Color.White); // Draw logo spriteBatch.Draw(logo, new Rectangle(483, 20, logo.Width, logo.Height), Color.White); // Draw the actual credits spriteBatch.DrawString(menuFont, "Made by:", new Vector2(580, 320), new Color(224, 96, 26)); // "}" Replaced with "É" in font texture spriteBatch.DrawString(menuFont, "Olle Astr}", new Vector2(560, 350), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "Sound effects by:", new Vector2(515, 420), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "https://www.zapsplat.com", new Vector2(460, 450), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "Skybox Generate with:", new Vector2(485, 520), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "Space Engine", new Vector2(545, 550), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "http://spaceengine.org", new Vector2(470, 580), new Color(224, 96, 26)); // Draw buttons buttonManager.Draw(spriteBatch); spriteBatch.End(); }
// Draw public static void Draw(PlayerShip player1, PlayerShip player2, SkyBox skyBox, SpriteBatch spriteBatch) { // Draw skybox skyBox.Draw(camera.View, camera.Projection, ((ArcBallCamera)camera).Position); // Start spritebatch to draw menu components spriteBatch.Begin(); // Draw transparent background spriteBatch.Draw(bg, new Rectangle(0, 0, 1920, 1080), Color.White); // Draw logo spriteBatch.Draw(logo, new Rectangle(483, 20, logo.Width, logo.Height), Color.White); // Draw a win text depending on who won if (player1.Kills >= Game1.WinLimit && player2.Kills >= Game1.WinLimit) { spriteBatch.DrawString(menuFont, "It's a tie!", new Vector2(540, 360), new Color(224, 96, 26)); } else if (player1.Kills >= Game1.WinLimit) { spriteBatch.DrawString(menuFont, "Player 1 Wins", new Vector2(535, 360), new Color(224, 96, 26)); } else if (player2.Kills >= Game1.WinLimit) { spriteBatch.DrawString(menuFont, "Player 2 Wins", new Vector2(535, 360), new Color(224, 96, 26)); } // Draw game stats and scoreboard // Draw "titles" for each columb/row spriteBatch.DrawString(menuFont, "Stats:", new Vector2(420, 420), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "Kills", new Vector2(580, 420), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "Deaths", new Vector2(740, 420), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "Player 1", new Vector2(420, 480), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "Player 2", new Vector2(420, 540), new Color(224, 96, 26)); // Draw actual stats (number of kills/deaths/etc) spriteBatch.DrawString(menuFont, player1.Kills.ToString(), new Vector2(610, 480), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, player1.Deaths.ToString(), new Vector2(770, 480), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, player2.Kills.ToString(), new Vector2(610, 540), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, player2.Deaths.ToString(), new Vector2(770, 540), new Color(224, 96, 26)); // Draw scoreboard texture spriteBatch.Draw(scoreboard, new Vector2(419, 420), Color.White); // Draw return to menu text spriteBatch.DrawString(menuFont, "Press A to return to main menu", new Vector2(400, 660), new Color(224, 96, 26)); spriteBatch.End(); }
// Draw public static void Draw(PlayerShip player1, PlayerShip player2, SkyBox skyBox, SpriteBatch spriteBatch) { // Draw skybox skyBox.Draw(camera.View, camera.Projection, ((ArcBallCamera)camera).Position); // Draw menu items spriteBatch.Begin(); // Draw transparent background spriteBatch.Draw(bg, new Rectangle(0, 0, 1920, 1080), Color.White); // Draw controller texture spriteBatch.Draw(controller, new Rectangle(344, 50, controller.Width, controller.Height), Color.White); // Draw text explaining the game play spriteBatch.DrawString(menuFont, "Watch your shields and don't let your hull reach 0%", new Vector2(260, 450), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "Avoid collisions", new Vector2(510, 490), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "First player to gain " + Game1.WinLimit.ToString() + " kills wins", new Vector2(397, 530), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "Press F To toggle fullscreen", new Vector2(420, 570), new Color(224, 96, 26)); // Draw what each button on the controller texture does spriteBatch.DrawString(menuFont, "Thrust/Strafe", new Vector2(120, 167), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "Ascend", new Vector2(235, 95), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "Descend", new Vector2(950, 95), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "Fire", new Vector2(950, 67), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "Brake", new Vector2(950, 167), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "Menu select", new Vector2(950, 197), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "Pitch/Yaw", new Vector2(950, 232), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "Return to main menu", new Vector2(950, 40), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "Menu up", new Vector2(217, 220), new Color(224, 96, 26)); spriteBatch.DrawString(menuFont, "Menu down", new Vector2(190, 257), new Color(224, 96, 26)); // Draw buttons buttonManager.Draw(spriteBatch); spriteBatch.End(); }
// Draw public static void Draw(SkyBox skyBox, SpriteBatch spriteBatch, GraphicsDevice graphics) { // Draw skybox skyBox.Draw(camera.View, camera.Projection, ((ArcBallCamera)camera).Position); // Start SpriteBatch to draw 2D components spriteBatch.Begin(); // Draw transparent background spriteBatch.Draw(bg, new Rectangle(0, 0, 1920, 1080), Color.White); // Draw logo spriteBatch.Draw(logo, new Rectangle(483, 20, logo.Width, logo.Height), Color.White); // Check if player1's controller is connected and draw text accordingly if (GamePad.GetState(PlayerIndex.One).IsConnected) { spriteBatch.DrawString(menuFont, " Controller 1 Conmnected", new Vector2(450, 640), new Color(224, 96, 26)); } else { spriteBatch.DrawString(menuFont, "Controller 1 Disconnected", new Vector2(440, 640), new Color(224, 30, 00)); } // Check if player2's controller is connected and draw text accordingly if (GamePad.GetState(PlayerIndex.Two).IsConnected) { spriteBatch.DrawString(menuFont, " Controller 2 Conmnected ", new Vector2(450, 680), new Color(224, 96, 26)); } else { spriteBatch.DrawString(menuFont, "Controller 2 Disconnected", new Vector2(440, 680), new Color(224, 30, 00)); } // Draw buttons buttonManager.Draw(spriteBatch); spriteBatch.End(); // Reset states changed by spritebatch to draw 3D correctly again graphics.BlendState = BlendState.Opaque; graphics.DepthStencilState = DepthStencilState.Default; // Draw ship ship.Draw(camera.View, camera.Projection, ((ArcBallCamera)camera).Position); }
// Draw everything for when playing void DrawPlaying(GameTime gameTime) { // !!!!! Reset render target !!!!! GraphicsDevice.SetRenderTarget(null); //// !!!!! Set render target to top !!!!! GraphicsDevice.SetRenderTarget(RenderTargetTop); // Clear render target GraphicsDevice.Clear(Color.Black); // Draw skybox skyBox.Draw(cameraPlayer1.View, cameraPlayer1.Projection, ((CockpitCamera)cameraPlayer1).Position); // Draw BulletManagers player1Ship.BulletManager.Draw(cameraPlayer1); player2Ship.BulletManager.Draw(cameraPlayer1); // Draw asteroids asteroidField.Draw(cameraPlayer1); // Draw each player player2Ship.DrawThirdPerson(cameraPlayer1); player1Ship.DrawFirstPerson(cameraPlayer1, spriteBatch, GraphicsDevice, player2Ship.Model); // !!!!! Set render target to bottom !!!!! GraphicsDevice.SetRenderTarget(RenderTargetBottom); // Clear render target GraphicsDevice.Clear(Color.Black); // Draw skybox skyBox.Draw(cameraPlayer2.View, cameraPlayer2.Projection, ((CockpitCamera)cameraPlayer2).Position); // Draw BulletManagers player1Ship.BulletManager.Draw(cameraPlayer2); player2Ship.BulletManager.Draw(cameraPlayer2); // Draw asteroids asteroidField.Draw(cameraPlayer2); // Draw each player player1Ship.DrawThirdPerson(cameraPlayer2); player2Ship.DrawFirstPerson(cameraPlayer2, spriteBatch, GraphicsDevice, player1Ship.Model); // !!!!! Set render target to bottom !!!!! GraphicsDevice.SetRenderTarget(RenderTargetFullscreen); // Draw both screens (render targets) spriteBatch.Begin(); spriteBatch.Draw(RenderTargetTop, new Rectangle(0, 0, 960, 1080), Color.White); spriteBatch.Draw(RenderTargetBottom, new Rectangle(960, 0, 960, 1080), Color.White); spriteBatch.End(); // !!!!! Reset render target !!!!! GraphicsDevice.SetRenderTarget(null); // Clear render target GraphicsDevice.Clear(Color.Black); // Draw the final rendertarget spriteBatch.Begin(); spriteBatch.Draw(RenderTargetFullscreen, new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height), Color.White); spriteBatch.End(); }