/// <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); GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp; GraphicsDevice.BlendState = BlendState.AlphaBlend; gameStarfield.Draw(); foreach (EffectPass pass in drawEffect.CurrentTechnique.Passes) { pass.Apply(); for (int y = 0; y < gameWorld.Y_CHUNKS; y++) { for (int x = 0; x < gameWorld.X_CHUNKS; x++) { Chunk c = gameWorld.Chunks[x, y, 0]; if (c == null) continue; if (!c.Visible) continue; if (c == null || c.VertexArray==null || c.VertexArray.Length == 0) continue; if (!gameCamera.boundingFrustum.Intersects(c.boundingSphere)) continue; GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionNormalColor>(PrimitiveType.TriangleList, c.VertexArray, 0, c.VertexArray.Length, c.IndexArray, 0, c.VertexArray.Length / 2); } } } gameHero.Draw(GraphicsDevice); enemyController.Draw(gameCamera); projectileController.Draw(gameCamera); particleController.Draw(); powerupController.Draw(); Vector2 offset = new Vector2(0, GraphicsDevice.Viewport.Height - 720) / 2; spriteBatch.Begin(); spriteBatch.Draw(hudTex, new Vector2(16, 16) + offset, new Rectangle(0, 0, 16, 688), Color.White * 0.2f); spriteBatch.Draw(hudTex, new Vector2(40, 16) + offset, new Rectangle(32, 0, 16, 688), Color.White * 0.2f); spriteBatch.Draw(hudTex, new Vector2(16, 16 + (int)((688f / 100f) * (100f - gameHero.Health))) + offset, new Rectangle(0, 0, 16, (int)((688f / 100f) * (gameHero.Health))), Color.White); spriteBatch.Draw(hudTex, new Vector2(40, 16 + (int)((688f / 100f) * (100f - gameHero.XP))) + offset, new Rectangle(32, 0, 16, (int)((688f / 100f) * (gameHero.XP))), Color.White); for (int i = 0; i < 5; i++) { spriteBatch.Draw(hudTex, new Vector2(40, 16 + (int)((688f / 100f) * (100f - gameHero.xpLevels[i]))) + offset, new Rectangle(64, 0, 16, 1), Color.White); } //spriteBatch.DrawString(font, gameHero.XP.ToString("0.00"), Vector2.One * 5, Color.White); spriteBatch.End(); base.Draw(gameTime); }