コード例 #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        override public void Draw(GameTime gameTime)
        {
            device.Clear(Color.CornflowerBlue);
            device.BlendState        = BlendState.Opaque;
            device.DepthStencilState = DepthStencilState.Default;
            device.SamplerStates[0]  = SamplerState.LinearWrap;

            sky.Draw(camera.View, camera.Projection);
            DrawModelWithEffect(terrainModel, Matrix.Identity, rockTexture);
            DrawModelWithEffect(ballModel, ball.World, currentBallProperties.Texture);
            DrawModel(arrowModel, Matrix.CreateScale(.5f) * ArrowRotation * Matrix.CreateTranslation(ball.position) * Matrix.CreateTranslation(0, 50f, 0), null);
            DrawModel(exitModel, Matrix.CreateScale(0.1f) * Matrix.CreateTranslation(ExitPosition), null);
            DrawModel(pitModel, Matrix.CreateTranslation(new Vector3(0, pitHeight, 0)), terrainTexture.Equals("Textures\\2") ? pitTextureIce : pitTextureLava);

            foreach (Coin x in coinList)
            {
                DrawModel(x.getModel(), Matrix.CreateScale(.2f) * x.getWorld(), coinTexture);
            }

            foreach (teleporter x in teleporterList)
            {
                DrawModel(x.getModel(), Matrix.CreateScale(2f) * x.getWorld(), teleporterTexture);
            }

            particleEngine.Draw(spriteBatch);

            spriteBatch.Begin();
            spriteBatch.DrawString(spriteFont, "Time Left: " + (LevelTime / 1000).ToString("#0.0"), new Vector2(device.Viewport.Bounds.Width - 175, device.Viewport.Bounds.Height - 50), Color.White);
            if (debugging)
            {
                spriteBatch.DrawString(spriteFont, "Arrow keys or WASD to move; I/K to move camera; E/Q to change ball; Space to jump", new Vector2(16, 32), Color.White);
                spriteBatch.DrawString(spriteFont, "Time: " + ((double)(timeInMillis / 100) / 10).ToString("#0.0"), new Vector2(32, 64), Color.White);
                spriteBatch.DrawString(spriteFont, "Gravity dot with normal: Angle(" + (a).ToString("0.00") + ") X(" + Math.Cos(a).ToString("0.00")
                                       + ") Y(" + Math.Sin(a).ToString("0.00") + ") Z(" + Math.Cos(Math.PI / 2 - a).ToString("0.00") + ")", new Vector2(32, 96), Color.White);
                spriteBatch.DrawString(spriteFont, "Heights: ground(" + ball.getHeight(ball.position) + ") ball+rad(" + (ball.position.Y + ball.ballRadius) + ")", new Vector2(32, 128), Color.White);
                spriteBatch.DrawString(spriteFont, "Normal: X(" + norm.X.ToString("0.000") + ") Y(" + norm.Y.ToString("0.000")
                                       + ") Z(" + norm.Z.ToString("0.000") + ")", new Vector2(32, 160), Color.White);
                spriteBatch.DrawString(spriteFont, "Acceleration: X(" + ball.acceleration.X.ToString("000.000") + ") Y(" + ball.acceleration.Y.ToString("000.000")
                                       + ") Z(" + ball.acceleration.Z.ToString("000.000") + ")", new Vector2(32, 192), Color.White);
                spriteBatch.DrawString(spriteFont, "Velocity: X(" + Math.Abs(ball.velocity.X).ToString("000.000") + ") Y(" + Math.Abs(ball.velocity.Y).ToString("000.000")
                                       + ") Z(" + Math.Abs(ball.velocity.Z).ToString("000.000") + ")", new Vector2(32, 224), Color.White);
                spriteBatch.DrawString(spriteFont, "Position: X(" + Math.Abs(ball.position.X).ToString("000.000") + ") Y(" + Math.Abs(ball.position.Y).ToString("000.000")
                                       + ") Z(" + Math.Abs(ball.position.Z).ToString("000.000") + ")", new Vector2(32, 256), Color.White);
            }
            spriteBatch.End();

            base.Draw(gameTime);
        }