Example #1
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (XNAGame game = new XNAGame())
     {
         game.Run();
     }
 }
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (XNAGame game = new XNAGame())
     {
         game.Run();
     }
 }
 static public void DrawLine(Vector3 start, Vector3 end, Color color)
 {
     basicEffect.World        = Matrix.Identity;
     basicEffect.View         = XNAGame.Instance().Camera.getView();
     basicEffect.Projection   = XNAGame.Instance().Camera.getProjection();
     pointList[currentLine++] = new VertexPositionColor(start, color);
     pointList[currentLine++] = new VertexPositionColor(end, color);
 }
Example #4
0
        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
            XNAGame.Instance().SpriteBatch.DrawString(spriteFont, "Yaw: " + getYaw(), new Vector2(10, 100), Color.White);
            XNAGame.Instance().SpriteBatch.DrawString(spriteFont, "Look: " + look.X + " " + look.Y + " " + look.Z, new Vector2(10, 120), Color.White);

            //XNAGame.Instance().SpriteBatch.DrawString(spriteFont, "Yaw: " + getYaw(), new Vector2(10, 100), Color.White);
        }
Example #5
0
        public override void Draw(GameTime gameTime)
        {
            XNAGame.Instance().SpriteBatch.DrawString(spriteFont, "Pos: " + pos.X + " " + pos.Y + " " + pos.Z, new Vector2(10, 10), Color.White);
            XNAGame.Instance().SpriteBatch.DrawString(spriteFont, "Look: " + look.X + " " + look.Y + " " + look.Z, new Vector2(10, 30), Color.White);
            XNAGame.Instance().SpriteBatch.DrawString(spriteFont, "Right: " + right.X + " " + right.Y + " " + right.Z, new Vector2(10, 50), Color.White);
            XNAGame.Instance().SpriteBatch.DrawString(spriteFont, "Up: " + up.X + " " + up.Y + " " + up.Z, new Vector2(10, 70), Color.White);

            // Draw the mesh
            if (model != null)
            {
                foreach (ModelMesh mesh in model.Meshes)
                {
                    foreach (BasicEffect effect in mesh.Effects)
                    {
                        effect.EnableDefaultLighting();
                        effect.PreferPerPixelLighting = true;
                        effect.World      = worldTransform;
                        effect.Projection = XNAGame.Instance().Camera.getProjection();
                        effect.View       = XNAGame.Instance().Camera.getView();
                    }
                    mesh.Draw();
                }
            }

            basicEffect.World      = Matrix.Identity;
            basicEffect.View       = XNAGame.Instance().Camera.getView();
            basicEffect.Projection = XNAGame.Instance().Camera.getProjection();

            if (drawAxis)
            {
                pointList[0] = new VertexPositionColor(pos, Color.Red);
                pointList[1] = new VertexPositionColor(pos + (look * 10), Color.Red);

                foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    XNAGame.Instance().GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineList, pointList, 0, 1);
                }

                pointList[0] = new VertexPositionColor(pos, Color.Blue);
                pointList[1] = new VertexPositionColor(pos + (right * 10), Color.Blue);

                foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    XNAGame.Instance().GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineList, pointList, 0, 1);
                }

                pointList[0] = new VertexPositionColor(pos, Color.White);
                pointList[1] = new VertexPositionColor(pos + (up * 10), Color.White);

                foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
                {
                    pass.Apply();
                    XNAGame.Instance().GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineList, pointList, 0, 1);
                }
            }
        }
 static public void Draw()
 {
     if (currentLine != 0)
     {
         foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
         {
             pass.Apply();
             XNAGame.Instance().GraphicsDevice.DrawUserPrimitives <VertexPositionColor>(PrimitiveType.LineList, pointList, 0, currentLine / 2);
         }
         currentLine = 0;
     }
 }
Example #7
0
        public override void Update(GameTime gameTime)
        {
            basicEffect.World      = Matrix.Identity;
            basicEffect.Projection = XNAGame.Instance().Camera.projection;
            basicEffect.View       = XNAGame.Instance().Camera.view;

            /*View = Matrix.CreateLookAt
             *              (new Vector3(0, 0, 5), Vector3.Zero, Vector3.Up),
             * Projection = Matrix.CreatePerspectiveFieldOfView
             *              (MathHelper.PiOver4, aspectRatio, 0.1f, 10)
             */
        }
        public override void Update(GameTime gameTime)
        {
            float width     = XNAGame.Instance().Ground.Width;
            float height    = XNAGame.Instance().Ground.Height;
            float speed     = 50.0f;
            float timeDelta = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if ((pos.X < -(width / 2)) || (pos.X > width / 2) || (pos.Z < -(height / 2)) || (pos.Z > height / 2) || (pos.Y < 0) || (pos.Y > 100))
            {
                Alive = false;
            }
            pos += look * speed * timeDelta;
        }
Example #9
0
        public XNAGame()
        {
            instance = this;
            graphics = new GraphicsDeviceManager(this);

            graphics.PreferredBackBufferWidth       = 1024;
            graphics.PreferredBackBufferHeight      = 768;
            graphics.PreferMultiSampling            = true;
            graphics.SynchronizeWithVerticalRetrace = true;
            graphics.ApplyChanges();
            graphics.IsFullScreen = false;
            Content.RootDirectory = "Content";
        }
        public XNAGame()
        {
            instance = this;
            graphics = new GraphicsDeviceManager(this);

            graphics.PreferredBackBufferWidth = 1024;
            graphics.PreferredBackBufferHeight = 768;
            graphics.PreferMultiSampling = true;
            graphics.SynchronizeWithVerticalRetrace = true;
            graphics.ApplyChanges();

            Content.RootDirectory = "Content";
        }
Example #11
0
        public Dalek()
        {
            worldTransform = Matrix.Identity;
            pos            = new Vector3(0, 5, 0);
            look           = new Vector3(0, 0, -1);
            right          = new Vector3(1, 0, 0);
            up             = new Vector3(0, 1, 0);
            globalUp       = new Vector3(0, 1, 0);
            drawAxis       = false;
            spriteFont     = XNAGame.Instance().Content.Load <SpriteFont>("Verdana");

            pointList = new VertexPositionColor[points];

            basicEffect = new BasicEffect(XNAGame.Instance().GraphicsDevice);
            basicEffect.VertexColorEnabled = true;
        }
 public override void Draw(GameTime gameTime)
 {
     worldTransform = Matrix.CreateScale(.2f) * Matrix.CreateTranslation(pos);
     // Draw the mesh
     if (model != null)
     {
         foreach (ModelMesh mesh in model.Meshes)
         {
             foreach (BasicEffect effect in mesh.Effects)
             {
                 effect.EnableDefaultLighting();
                 effect.PreferPerPixelLighting = true;
                 effect.World      = worldTransform;
                 effect.Projection = XNAGame.Instance().Camera.getProjection();
                 effect.View       = XNAGame.Instance().Camera.getView();
             }
             mesh.Draw();
         }
     }
 }
        public XNAGame()
        {
            instance = this;
            graphics = new GraphicsDeviceManager(this);

            #if WINDOWS
            graphics.PreferredBackBufferWidth = 1024;
            graphics.PreferredBackBufferHeight = 768;
            graphics.PreferMultiSampling = true;
            graphics.IsFullScreen = false;
            graphics.SynchronizeWithVerticalRetrace = true;

            #elif WINDOWS_PHONE
            Graphics.PreferredBackBufferWidth = 240;
            Graphics.PreferredBackBufferHeight = 400;
            #endif
            graphics.ApplyChanges();

            Content.RootDirectory = "Content";
        }
Example #14
0
        public override void Update(GameTime gameTime)
        {
            Dalek player    = XNAGame.Instance().Dalek;
            float timeDelta = (float)gameTime.ElapsedGameTime.TotalSeconds;

            // Calculate the look vector to make the AI Dalek point at the player dalek



            //

            if (look != basis)
            {
                float yawAngle   = getYaw();
                float pitchAngle = getPitch();
                worldTransform = Matrix.CreateRotationX(pitchAngle) * Matrix.CreateRotationY(yawAngle) * Matrix.CreateTranslation(pos);
            }
            else
            {
                worldTransform = Matrix.CreateTranslation(pos);
            }
        }
Example #15
0
        public override void LoadContent()
        {
            float twidth  = 10;
            float theight = 10;

            vertices = new VertexPositionTexture[]
            {
                new VertexPositionTexture(new Vector3(-Width, 0, Height), new Vector2(0, theight)),
                new VertexPositionTexture(new Vector3(-Width, 0, -Height), new Vector2(0, 0)),
                new VertexPositionTexture(new Vector3(Width, 0, Height), new Vector2(twidth, theight)),

                new VertexPositionTexture(new Vector3(Width, 0, Height), new Vector2(twidth, theight)),
                new VertexPositionTexture(new Vector3(-Width, 0, -Height), new Vector2(0, 0)),

                new VertexPositionTexture(new Vector3(Width, 0, -Height), new Vector2(twidth, 0))
            };

            Texture2D portrait    = XNAGame.Instance().Content.Load <Texture2D>("Ground");
            float     aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;

            basicEffect = new BasicEffect(graphics.GraphicsDevice);
            basicEffect.TextureEnabled = true;
            basicEffect.Texture        = portrait;
        }
Example #16
0
        public override void Update(GameTime gameTime)
        {
            float timeDelta = (float)(gameTime.ElapsedGameTime.Milliseconds / 1000.0f);

            keyboardState = Keyboard.GetState();
            mouseState    = Mouse.GetState();

            int mouseX = mouseState.X;
            int mouseY = mouseState.Y;

            int midX = GraphicsDeviceManager.DefaultBackBufferHeight / 2;
            int midY = GraphicsDeviceManager.DefaultBackBufferWidth / 2;

            int deltaX = mouseX - midX;
            int deltaY = mouseY - midY;

            yaw(-(float)deltaX / 100.0f);
            pitch(-(float)deltaY / 100.0f);
            Mouse.SetPosition(midX, midY);

            if (mouseState.LeftButton == ButtonState.Pressed)
            {
                Vector3 newTargetPos = pos + (look * 50.0f);
                //newTargetPos.Y = 10;
                XNAGame.Instance().Dalek.targetPos = newTargetPos;
            }

            if (mouseState.RightButton == ButtonState.Pressed)
            {
                Vector3 newTargetPos = pos;
                XNAGame.Instance().Dalek.targetPos = newTargetPos;
            }


            if (keyboardState.IsKeyDown(Keys.LeftShift))
            {
                timeDelta *= 20.0f;
            }

            if (keyboardState.IsKeyDown(Keys.W))
            {
                walk(timeDelta);
            }

            if (keyboardState.IsKeyDown(Keys.S))
            {
                walk(-timeDelta);
            }

            if (keyboardState.IsKeyDown(Keys.A))
            {
                strafe(timeDelta);
            }

            if (keyboardState.IsKeyDown(Keys.D))
            {
                strafe(-timeDelta);
            }

            view       = Matrix.CreateLookAt(pos, pos + look, up);
            projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), XNAGame.Instance().GraphicsDeviceManager.GraphicsDevice.Viewport.AspectRatio, 1.0f, 10000.0f);
        }
Example #17
0
 public Ground()
 {
     graphics = XNAGame.Instance().GraphicsDeviceManager;
     //Content.RootDirectory = "Content";
     //TargetElapsedTime = TimeSpan.FromSeconds(1 / 30.0);
 }
Example #18
0
 public override void LoadContent()
 {
     model = XNAGame.Instance().Content.Load <Model>("dalek");
 }
Example #19
0
 static void Main()
 {
     using (var game = new XNAGame())
         game.Run();
 }
 static void Main()
 {
     using (var game = new XNAGame())
         game.Run();
 }