Example #1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            explosion.Draw(GraphicsDevice);

            base.Draw(gameTime);
        }
Example #2
0
 public override void Draw(GameTime gameTime)
 {
     GraphicsDevice.Clear(Color);
     spriteBatch.Begin(transformMatrix: ViewMatrix);               // Map the world space around the position to the full screen
     Draw(spriteBatch);                                            // Draw background below entitys first
     particleManager.Draw(spriteBatch);
     spriteBatch.End();
     base.Draw(gameTime);
 }
Example #3
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            // fix up for enabling correct 3d object rendering
            GraphicsDevice.BlendState        = BlendState.Opaque;
            GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            GraphicsDevice.SamplerStates[0]  = SamplerState.AnisotropicWrap;


            box.Draw(cam);

            particles.Draw(cam.Projection, cam.View, cam.SideVector, cam.UpVector);


            // Print debug information and custom params
            string text =
                "CONTROLS\n" +
                "ARROWS = Control camera rotation\n" +
                "Z/X = Zoom in and out\n\n" +
                "PARAMS" +
                "\nPARTICLE COUNT   = " + particles.ParticleCount +
                "\nPARTICLE RADIUS  = " + particles.ParticleRadius +
                "\ng/G - GRAVITY    = " + particles.Gravity +
                "\nd/D - DAMPING    = " + particles.Damping +
                "\np/P - SPRING     = " + particles.Spring +
                "\ns/S - SHEAR      = " + particles.Shear +
                "\na/A - ATTRACTION = " + particles.Attraction;

            spriteBatch.Begin();
            spriteBatch.DrawString(font, text, Vector2.One * 15, Color.White);
            spriteBatch.DrawString(font, "FPS: " + fpsCounter.FPS, new Vector2(GraphicsDevice.Viewport.Width * 0.90f, 15), Color.White);
            spriteBatch.End();

            base.Draw(gameTime);
        }
Example #4
0
        public void Draw(Level level)
        {
            if (RenderTargetsAreOutdated())
            {
                UpdateRenderTargets();
            }

            _camera.Position = Vector2.Round(GraphicsConstants.PhysicsToView(level.CameraCenter) - _graphicsDevice.Viewport.Bounds.Size.ToVector2() / 2f);

            _renderTargetStack.Push(_worldTarget);
            {
                _graphicsDevice.Clear(Color.Transparent);
                Background.Draw(_camera);
                TileMap.Draw(level, _camera);

                if (HideProgress)
                {
                    _spriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: _camera.GetTransformMatrix());

                    _spriteBatch.DrawString(_regularFont, "Press SPACE BAR to jump/kick.", new Vector2(256f, 2048f), Color.White);
                    _spriteBatch.DrawString(_regularFont, "Use the ARROW KEYS to move.", new Vector2(60f, 1700f), Color.White);
                    _spriteBatch.DrawString(_regularFont, "Tap DOWN to fall through platforms.", new Vector2(140f, 1520f), Color.White);
                    _spriteBatch.DrawString(_regularFont, "Strike R to restart.", new Vector2(670f, 1800f), Color.White);
                    _spriteBatch.DrawString(_regularFont, "Slap SHIFT while running to dash.", new Vector2(200f, 1190f), Color.White);
                    _spriteBatch.DrawString(_regularFont, "You can chain kicks and dashes...", new Vector2(80f, 900f), Color.White);
                    _spriteBatch.DrawString(_regularFont, "... if you hit your torch.", new Vector2(300f, 800f), Color.White);
                    _spriteBatch.DrawString(_regularFont, "Psst... you can press P\nto skip this tutorial.", new Vector2(-350f, 2170f), Color.White);

                    _spriteBatch.End();
                }

                if (TheWinnerIsYou)
                {
                    _spriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: _camera.GetTransformMatrix());

                    _spriteBatch.DrawString(_regularFont, "You win! Sleep tight.", new Vector2(80f, 270f), Color.White);

                    _spriteBatch.End();
                }

                _spriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: _camera.GetTransformMatrix());

                int startX = (int)Math.Floor(_camera.Position.X / _finishTexture.Width);
                int endX   = (int)Math.Floor((_camera.Position.X + _spriteBatch.GraphicsDevice.Viewport.Width) / _finishTexture.Width);

                float y = GraphicsConstants.PhysicsToView(level.FinishHeight);

                for (int x = startX; x <= endX; x++)
                {
                    _spriteBatch.Draw(_finishTexture, new Vector2(x * _finishTexture.Width, y - _finishTexture.Height / 2f), Color.White);
                }

                _spriteBatch.End();

                Particles.Draw(_camera);
                Entities.Draw(level, _camera);

                TileMap.DrawGrates(level, _camera);
            }
            _renderTargetStack.Pop();

            _renderTargetStack.Push(_waterTarget);
            {
                _graphicsDevice.Clear(Color.Transparent);
                _waterView.DrawMask(level, _camera);
            }
            _renderTargetStack.Pop();

            _waterEffect.Parameters["Time"].SetValue(_shaderTimer);

            Vector2 camera = _camera.Position / _graphicsDevice.Viewport.Bounds.Size.ToVector2();

            _waterEffect.Parameters["Camera"].SetValue(camera);

            _waterEffect.Parameters["Position"].SetValue(_camera.Position);
            _waterEffect.Parameters["Dimensions"].SetValue(_graphicsDevice.Viewport.Bounds.Size.ToVector2() + new Vector2(128f));

            if (level.EntityWorld.TryGetEntity(TorchEntityID, out Entity? te))
            {
                if (!te.IsPutOut && level.PhysicsWorld.TryGetBody(te.BodyID, out Body? torchBody))
                {
                    _waterEffect.Parameters["Light1"].SetValue(GraphicsConstants.PhysicsToView(torchBody.Position + torchBody.Bounds.Center));
                }
                else
                {
                    _waterEffect.Parameters["Light1"].SetValue(new Vector2(-1000f));
                }
            }

            _waterEffect.Parameters["Radius"].SetValue(_lightRadius);
            _waterEffect.Parameters["Ambience"].SetValue(_ambience);

            _spriteBatch.Begin(effect: _waterEffect);
            _spriteBatch.Draw(_worldTarget, Vector2.Zero, Color.White);
            _spriteBatch.End();

            _waterView.Draw(level, _camera);

            if (HideProgress)
            {
                _spriteBatch.Begin(samplerState: SamplerState.PointClamp, transformMatrix: _camera.GetTransformMatrix());

                //_spriteBatch.DrawString(_regularFont, "Press SPACE BAR to jump/kick.", new Vector2(256f, 2048f), Color.White);
                //_spriteBatch.DrawString(_regularFont, "Use the ARROW KEYS to move.", new Vector2(60f, 1700f), Color.White);

                _spriteBatch.End();
            }

            _spriteBatch.Begin(samplerState: SamplerState.PointClamp);

            Vector2 progPos = new Vector2(32f, _graphicsDevice.Viewport.Height / 2f);

            if (!HideProgress)
            {
                _spriteBatch.Draw(_progressTexture, progPos + new Vector2(-_progressTexture.Width / 2f, -_progressTexture.Height / 2f), Color.White);
            }

            Vector2 startView  = GraphicsConstants.PhysicsToView(Start);
            float   finishView = GraphicsConstants.PhysicsToView(level.FinishHeight);

            if (level.EntityWorld.TryGetEntity(TorchEntityID, out Entity? torchEntity))
            {
                if (level.PhysicsWorld.TryGetBody(torchEntity.BodyID, out Body? torchBody))
                {
                    Vector2 torchPosition = GraphicsConstants.PhysicsToView(torchBody.Position + torchBody.Bounds.Center);

                    if (!torchEntity.IsPutOut)
                    {
                        Vector2 arrowPosition = torchPosition;

                        arrowPosition.X = MathHelper.Clamp(arrowPosition.X, _camera.Position.X + 32f, _camera.Position.X + _graphicsDevice.Viewport.Width - 32f);
                        arrowPosition.Y = MathHelper.Clamp(arrowPosition.Y, _camera.Position.Y + 32f, _camera.Position.Y + _graphicsDevice.Viewport.Height - 32f);

                        _arrowSprite.Rotation = (torchPosition - arrowPosition).GetAngle();

                        _arrowSprite.Draw(_spriteBatch, arrowPosition - _camera.Position);
                    }

                    float tiy = Math.Clamp((torchPosition.Y - finishView) / (startView.Y - finishView), 0f, 1f);

                    if (!HideProgress)
                    {
                        _spriteBatch.Draw(_torchIconTexture,
                                          progPos + new Vector2(-_torchIconTexture.Width / 2f, (tiy - 0.5f) * (_progressTexture.Height - 32f) - _torchIconTexture.Height / 2f),
                                          Color.White);
                    }
                }
            }

            if (level.EntityWorld.TryGetEntity(PlayerEntityID, out Entity? playerEntity))
            {
                if (level.PhysicsWorld.TryGetBody(playerEntity.BodyID, out Body? playerBody))
                {
                    Vector2 playerPosition = GraphicsConstants.PhysicsToView(playerBody.Position + playerBody.Bounds.Center);

                    float piy = Math.Clamp((playerPosition.Y - finishView) / (startView.Y - finishView), 0f, 1f);

                    if (!HideProgress)
                    {
                        _spriteBatch.Draw(_playerIconTexture,
                                          progPos + new Vector2(-_playerIconTexture.Width / 2f, (piy - 0.5f) * (_progressTexture.Height - 32f) - _playerIconTexture.Height / 2f),
                                          Color.White);
                    }
                }
            }

            _spriteBatch.Draw(_pixelTexture, _graphicsDevice.Viewport.Bounds, Color.Black * 0.5f * _loseScreenOpacity);

            _spriteBatch.DrawString(_regularFont, "Press R to restart.",
                                    _graphicsDevice.Viewport.Bounds.Center.ToVector2() - _regularFont.MeasureString("Press R to restart.") / 2f, Color.White * _loseScreenOpacity);

            _spriteBatch.Draw(_pixelTexture, _graphicsDevice.Viewport.Bounds, Color.Black * _fadeOutOpacity);

            if (Header != null)
            {
                float headerOpacity = MathHelper.Clamp(1f - _headerTimer / _headerTime, 0f, 1f);

                _spriteBatch.Draw(_gradientTexture, Vector2.Zero, Color.White * headerOpacity);
                _spriteBatch.DrawString(_regularFont, Header, new Vector2(_graphicsDevice.Viewport.Bounds.Center.X - _regularFont.MeasureString(Header).X / 2f, 24f), Color.White * headerOpacity);
            }

            _spriteBatch.End();
        }
Example #5
0
 public void Draw(SpriteBatch spriteBatch, Texture2D texture)
 {
     Particles.Draw(spriteBatch, texture);
 }