Exemplo n.º 1
0
        protected override void Draw()
        {
            Camera.Update(null);

            // Clear to the default control background color.
            Color backColor = new Color(BackColor.R, BackColor.G, BackColor.B);

            GraphicsDevice.Clear(backColor);
            g.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);

            PolygonEffect.View = Camera.View;
            g.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            g.GraphicsDevice.SamplerStates[0]  = SamplerState.PointClamp;
            g.GraphicsDevice.RasterizerState   = RasterizerState.CullCounterClockwise;

            foreach (Tile3D ActiveTile in ListTile3D)
            {
                PolygonEffect.Texture = ListTileSet[ActiveTile.TilesetIndex];
                PolygonEffect.CurrentTechnique.Passes[0].Apply();

                ActiveTile.Draw(g.GraphicsDevice);
            }

            g.End();
        }
Exemplo n.º 2
0
        protected override void Update(GameTime gameTime)
        {
            float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;

            KeyboardState keyState = Keyboard.GetState();

            // Allows the game to exit
            if (keyState.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            if (keyState.IsKeyDown(Keys.Left))
            {
                cam.Yaw -= 1 * dt;
            }
            else if (keyState.IsKeyDown(Keys.Right))
            {
                cam.Yaw += 1 * dt;
            }
            if (keyState.IsKeyDown(Keys.Up))
            {
                cam.Pitch -= 1 * dt;
            }
            else if (keyState.IsKeyDown(Keys.Down))
            {
                cam.Pitch += 1 * dt;
            }
            if (keyState.IsKeyDown(Keys.Z))
            {
                cam.Offset += Vector3.Forward * 5 * dt;
            }
            else if (keyState.IsKeyDown(Keys.X))
            {
                cam.Offset += Vector3.Backward * 5 * dt;
            }

            if (keyState.IsKeyDown(Keys.G))
            {
                if (keyState.IsKeyDown(Keys.LeftShift) || keyState.IsKeyDown(Keys.RightShift))
                {
                    particles.Gravity += Vector3.Down * 0.1f;
                }
                else
                {
                    particles.Gravity -= Vector3.Down * 0.1f;
                }
            }

            if (keyState.IsKeyDown(Keys.A))
            {
                if (keyState.IsKeyDown(Keys.LeftShift) || keyState.IsKeyDown(Keys.RightShift))
                {
                    particles.Attraction += 0.1f * dt;
                }
                else
                {
                    particles.Attraction -= 0.1f * dt;
                }
            }

            if (keyState.IsKeyDown(Keys.P))
            {
                if (keyState.IsKeyDown(Keys.LeftShift) || keyState.IsKeyDown(Keys.RightShift))
                {
                    particles.Spring += 0.1f * dt;
                }
                else
                {
                    particles.Spring -= 0.1f * dt;
                }
            }

            if (keyState.IsKeyDown(Keys.S))
            {
                if (keyState.IsKeyDown(Keys.LeftShift) || keyState.IsKeyDown(Keys.RightShift))
                {
                    particles.Shear += 0.1f * dt;
                }
                else
                {
                    particles.Shear -= 0.1f * dt;
                }
            }

            if (keyState.IsKeyDown(Keys.D))
            {
                if (keyState.IsKeyDown(Keys.LeftShift) || keyState.IsKeyDown(Keys.RightShift))
                {
                    particles.Damping += 0.1f * dt;
                }
                else
                {
                    particles.Damping -= 0.1f * dt;
                }
            }

            if (keyState.IsKeyDown(Keys.R))
            {
                particles.Reset();
            }


            cam.Update(dt);


            // Update particles
            particles.Update(dt);


            base.Update(gameTime);
        }