/// <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.CornflowerBlue); SpriteBatch.Begin(0, null, null, null, null, null, Camera.ActiveCamera?.World ?? Matrix.Identity); ComponentManager.Draw(); SpriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// Draws the gameplay screen. /// </summary> public override void Draw(GameTime gameTime) { ScreenManager.GraphicsDevice.Clear(ClearOptions.Target, Color.Black, 0, 0); // Our player and enemy are both actually just text strings. SpriteBatch spriteBatch = ScreenManager.SpriteBatch; spriteBatch.Begin(); if (!componentManager.portalActive) { int i, n; for (i = 0; i < 3; i++) { for (n = 0; n < 3; n++) { spriteBatch.Draw(bgTexture, new Vector2(i * 512, n * 512), Color.White); } } } player.Draw(spriteBatch); componentManager.Draw(spriteBatch, player); spriteBatch.DrawString(gameFont, string.Format("Level {0}", componentManager.level), new Vector2(20, 20), Color.White); spriteBatch.DrawString(gameFont, string.Format("Efficiency: {0}%", Math.Round(componentManager.kills / componentManager.shotsTaken * 100)), new Vector2(20, 60), Color.White); //spriteBatch.DrawString(gameFont, "// TODO", playerPosition, Color.Green); //spriteBatch.DrawString(gameFont, "Insert Gameplay Here", //enemyPosition, Color.DarkRed); spriteBatch.DrawString(gameFont, string.Format("Health: {0}", player.health), new Vector2(ScreenManager.windowSize.X - 200, 20), Color.White); spriteBatch.DrawString(gameFont, string.Format("Core Health: {0}", componentManager.core.health), new Vector2(ScreenManager.windowSize.X - 260, 60), Color.White); if (componentManager.gameOver) { spriteBatch.DrawString(gameFont, "Game Over", new Vector2(ScreenManager.windowSize.X / 2 - 80, ScreenManager.windowSize.Y / 2 - 40), Color.White); } spriteBatch.End(); // If the game is transitioning on or off, fade it out to black. if (TransitionPosition > 0 || pauseAlpha > 0) { float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, pauseAlpha / 2); ScreenManager.FadeBackBufferToBlack(alpha); } }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); cm.Update(gameTime); spriteBatch.Begin(); cm.Draw(gameTime, spriteBatch); spriteBatch.End(); // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { this.Exit(); } base.Update(gameTime); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); m_ComponentManager.Draw(e.Graphics); }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); ComponentManager.Draw(); base.Draw(gameTime); }