Exemplo n.º 1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Gray);

            // Update Transform matrix
            Matrix transform = Matrix.CreateScale(new Vector3(zoom, zoom, 1));
            transform.Translation = new Vector3(camPos, 1);

            if (level != null)
            {
                // Apply Transform matrix
                // Everything in here can be moved and zoomed by the mouse
                spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, transform);
                {
                    // Draw background
                    spriteBatch.Draw(solid, new Rectangle(level.tiles[0, 0].Position.ToPoint(), new Point(level.width * 50, level.height * 50)), Color.Black * 0.5f);

                    // Draw Level
                    level.Draw(spriteBatch);
                }
                spriteBatch.End();
            }

            // UI
            spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, null);
            {
                sidebar.DrawSelf(spriteBatch);

                if (MouseText != null)
                {
                    spriteBatch.DrawString(font, MouseText, mouse.Position.ToVector2() + new Vector2(10), Color.White);
                    MouseText = null;
                }
            }
            spriteBatch.End();
            base.Draw(gameTime);
        }