Exemple #1
0
        public static void Draw(SpriteBatch spriteBatch)
        {
            switch (GameManager.gameState)
            {
            case GameState.NewGame:
                break;

            case GameState.LoadGame:
                break;

            case GameState.Pause:
                break;

            case GameState.Quit:
                break;

            case GameState.Combat:
                break;

            default:
                spriteBatch.Begin(transformMatrix: Camera.camera.GetViewMatrix(), samplerState: SamplerState.PointClamp);
                mapRenderer.Draw(currentLevel.Map, Camera.camera.GetViewMatrix());
                spriteBatch.End();
                break;
            }
        }
Exemple #2
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();

            //draw the tiles and plants layer of the tiled map on the screen
            tiledMapRenderer.Draw(tiledMap.GetLayer("tiles"));
            tiledMapRenderer.Draw(tiledMap.GetLayer("plants"));

            //draw the player image in position of the player object of the tiled map
            spriteBatch.Draw(playerImage, playerPosition, Color.White);

            //draw the trees layer of the tiled map after the player so the player can move behind the trees for example
            tiledMapRenderer.Draw(tiledMap.GetLayer("trees"));

            //draw message
            string text = "a map made in Tiled with object layer to set position of player image";

            spriteBatch.DrawString(font, text, new Vector2(10, 10), Color.White);

            spriteBatch.End();

            base.Draw(gameTime);
        }
Exemple #3
0
        public void Draw(SpriteBatch spriteBatch)
        {
            Matrix transform = _camera.GetViewMatrix();

            _tiledMapRenderer.Draw(_tiledMap.GetLayer("Space"), transform);
            _tiledMapRenderer.Draw(_tiledMap.GetLayer("ShipFloor"), transform);
            _tiledMapRenderer.Draw(_tiledMap.GetLayer("Collidable"), transform);

            spriteBatch.Begin(transformMatrix: transform, samplerState: SamplerState.PointClamp);
            // Draws all game objects to screen
            foreach (IEntity entity in _entities)
            {
                entity.Draw(spriteBatch);
            }
            _player.Draw(spriteBatch);

            spriteBatch.End();

            _tiledMapRenderer.Draw(_tiledMap.GetLayer("UpperLayer"), transform);

            // HUD Section
            spriteBatch.Begin(samplerState: SamplerState.PointClamp);
            _playerInventoryHud.Draw(spriteBatch);
            _toolboxInventoryHud.Draw(spriteBatch);
            _healthBar.Draw(spriteBatch);
            spriteBatch.DrawString(_font, _brokenList, new Vector2(50f, 100f), Color.White);
            spriteBatch.End();
        }
        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            GraphicsDevice.Clear(Color.Black);

            var viewMatrix       = _camera.GetViewMatrix();
            var projectionMatrix = Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width,
                                                                      GraphicsDevice.Viewport.Height, 0, 0f, -1f);

            // painter's algorithm; just draw things in the expected order

            var backgroundLayer = _map.GetLayer("background");

            _mapRenderer.Draw(backgroundLayer, ref viewMatrix, ref projectionMatrix);

            var solidsLayer = _map.GetLayer("solids");

            _mapRenderer.Draw(solidsLayer);

            var decorationsLayer = _map.GetLayer("decorations");

            _mapRenderer.Draw(decorationsLayer, ref viewMatrix, ref projectionMatrix);

            _entityComponentSystem.Draw(gameTime);

            var decorations2Layer = _map.GetLayer("decorations2");

            _mapRenderer.Draw(decorations2Layer, ref viewMatrix, ref projectionMatrix);

            var deadliesLayer = _map.GetLayer("deadlies");

            _mapRenderer.Draw(deadliesLayer, ref viewMatrix, ref projectionMatrix);
        }
Exemple #5
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // draw all layers
            mapRenderer.Draw(bottomLayer);
            mapRenderer.Draw(middleLayer);
            player.drawPlayer(spriteBatch);
            mapRenderer.Draw(topLayer);
            mapRenderer.Draw(overLapLayer);

            base.Draw(gameTime);
        }
        public override void Draw(GameTime gameTime)
        {
            if (IsVisible)
            {
                // resize to phone screen size
                //_graphicsDeviceManager.PreferredBackBufferWidth = 270;
                //_graphicsDeviceManager.PreferredBackBufferHeight = 540;
                _graphicsDeviceManager.PreferredBackBufferWidth  = 1200;
                _graphicsDeviceManager.PreferredBackBufferHeight = 800;
                _graphicsDeviceManager.ApplyChanges();


                // Clear the screen
                _contentManager.GetGraphicsDevice().Clear(Color.Pink);

                // Transform matrix is only needed if you have a Camera2D
                // Setting the sampler state to `SamplerState.PointClamp` is reccomended to remove gaps between the tiles when rendering
                _spriteBatch.Begin(transformMatrix: _camera.GetViewMatrix(), samplerState: SamplerState.PointClamp);

                // map Should be the `TiledMap`
                // Once again, the transform matrix is only needed if you have a Camera2D
                mapRenderer.Draw(map, _camera.GetViewMatrix());

                // End the sprite batch
                _spriteBatch.End();

                base.Draw(gameTime);
            }

            base.Draw(gameTime);
        }
Exemple #7
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.DarkGray);

            //New code

            //Start drawing things
            spriteBatch.Begin();

            tmr.Draw(map, viewMatrix: camera.getTransformation, SamplerState.PointClamp);

            //Iterate and draw all active objects in GameObject.object_dict and all background objects DEBUG Add background objects later
            foreach (KeyValuePair <long, GameObject> entry in GameObject.ActiveObjects)
            {
                spriteBatch.Draw(entry.Value.sprite.texture, entry.Value.position, Color.White);
                if (Options.debug) //Draw hitboxes and debug info if debug mode is turned on
                {
                    spriteBatch.Draw(hitboxSprite.texture, entry.Value.Hitbox, entry.Value.hitboxColor * 0.35f);
                    spriteBatch.DrawString(font, "xspeed: " + player.xspeed.ToString(), new Vector2(60.0f, 0.0f), Color.Black);
                    spriteBatch.DrawString(font, "yspeed: " + player.yspeed.ToString(), new Vector2(60.0f, 20.0f), Color.Black);
                    spriteBatch.DrawString(font, "x: " + player.position.X.ToString(), new Vector2(0.0f, 0.0f), Color.White);
                    spriteBatch.DrawString(font, "y: " + player.position.Y.ToString(), new Vector2(0.0f, 20.0f), Color.White);
                }
            }

            spriteBatch.DrawString(font, "Collison below?: " + player.collision_below.ToString(), new Vector2(10.0f, 40.0f), Color.Black);
            spriteBatch.End();

            base.Draw(gameTime);
        }
Exemple #8
0
        public override void Draw(GameTime gameTime)
        {
            // TODO: Add your drawing code here
            GraphicsDevice.BlendState       = BlendState.AlphaBlend;
            GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
            GraphicsDevice.RasterizerState  = RasterizerState.CullNone;

            var viewMatrix       = _camera.GetViewMatrix();
            var projectionMatrix = Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 0f, -1f);

            _mapRenderer.Draw(_map, ref viewMatrix, ref projectionMatrix);

            DrawText();

            _fpsCounter.Draw(gameTime);

            _player.Draw(GameRef.SpriteBatch, _camera);

            foreach (var p in _players)
            {
                p.Draw(GameRef.SpriteBatch, _camera);
            }


            base.Draw(gameTime);
        }
Exemple #9
0
        public void Draw(SpriteBatch spriteBatch)
        {
            if (MapTransition != null && MapTransition.State == MapTransitionHandler.TransitionState.MapChange)
            {
                MapTransition.Draw(spriteBatch);
            }
            else
            {
                MapRenderer.Draw(MapCurrent, MapCamera.GetViewMatrix());

                if (MainPlayer.IsActive == true)
                {
                    MainPlayer.Draw(spriteBatch);
                }

                foreach (MapEntity entity in Entities)
                {
                    entity.Draw(spriteBatch);
                }

                if (IsTransitionActive == true)
                {
                    MapTransition.Draw(spriteBatch);
                }
            }
        }
Exemple #10
0
        public override void Draw(GameTime gameTime, Camera camera)
        {
            _mapRenderer ??= new TiledMapRenderer(camera.GraphicsDevice);
            _mapRenderer.Draw(_map.GetLayer(""), camera.GetViewMatrix(), Matrix.Identity);

            base.Draw(gameTime, camera);
        }
Exemple #11
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();

            //draw background last

            // draw arrow
            foreach (Arrow arr in Arrow.arrows)
            {
                // arrow.Draw(spriteBatch);

                spriteBatch.Draw(arrow, new Vector2(arr.Position.X - 50, arr.Position.Y - 50), null, Color.White);
            }

            // draw the player
            player.Draw(spriteBatch);

            DrawAllEnemies();

            // mapManager.Draw(Matrix.Identity, spriteBatch);

            _tiledMapRenderer.Draw();
            spriteBatch.End();


            base.Draw(gameTime);
        }
Exemple #12
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.ForestGreen);

            mapRenderer.Draw(myMap);

            if (player.Health > 0)
            {
                player.anim.Draw(spriteBatch, new Vector2(player.Position.X - 48, player.Position.Y - 48));
            }

            spriteBatch.Begin();

            foreach (Enemy en in Enemy.enemies)
            {
                Texture2D spriteToDraw;
                int       rad;

                if (en.GetType() == typeof(Snake))
                {
                    spriteToDraw = snakeEnemy_Sprite;
                    rad          = 50;
                }
                else
                {
                    spriteToDraw = eyeEnemy_Sprite;
                    rad          = 73;
                }

                spriteBatch.Draw(spriteToDraw, new Vector2(en.Position.X - rad, en.Position.Y - rad), Color.White);
            }

            foreach (Obstacle o in Obstacle.obstacles)
            {
                Texture2D spriteToDraw;
                if (o.GetType() == typeof(Tree))
                {
                    spriteToDraw = tree_Sprite;
                }
                else
                {
                    spriteToDraw = bush_Sprite;
                }
                spriteBatch.Draw(spriteToDraw, o.Position, Color.White);
            }

            foreach (Projectile proj in Projectile.projectiles)
            {
                spriteBatch.Draw(bullet_Sprite, new Vector2(proj.Position.X - proj.Radius, proj.Position.Y - proj.Radius), Color.White);
            }

            for (int i = 0; i < player.Health; i++)
            {
                spriteBatch.Draw(heart_Sprite, new Vector2(3 + i * 63, 0), Color.White);
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }
Exemple #13
0
        public void Draw()
        {
            //parallax = (int)Math.Round(Camera.position.X * 0.6f);

            //Matrix layerFg = Matrix.CreateTranslation(((Camera.position.X) * 0.1f) - 30, 0, 0) * Camera.GetTransformMatrix();
            //Matrix layerMg = Matrix.CreateTranslation(((Camera.position.X) * 0.2f)-60, 0, 0) * Camera.GetTransformMatrix();
            //Matrix layerBg = Matrix.CreateTranslation(parallax - 240, 0, 0) * Camera.GetTransformMatrix();

            //if (tiledMap.GetLayer("FarBackground") != null)
            //{
            //	renderer.Draw(tiledMap.GetLayer("FarBackground"), Resolution.GetTransformationMatrix());
            //}
            //if (tiledMap.GetLayer("Background") != null)
            //{
            //	renderer.Draw(tiledMap.GetLayer("Background"), layerBg);
            //}
            //if (tiledMap.GetLayer("MidBackground") != null)
            //{
            //	renderer.Draw(tiledMap.GetLayer("MidBackground"), layerMg);
            //}
            //if (tiledMap.GetLayer("Foreground 2") != null)
            //{
            //	renderer.Draw(tiledMap.GetLayer("Foreground 2"), layerFg);
            //}
            //if (tiledMap.GetLayer("Foreground 2") != null)
            //{
            //	renderer.Draw(tiledMap.GetLayer("CloseForeground"), Camera.GetTransformMatrix(), null, null, .1f);
            //}

            //renderer.Draw(tiledMap.GetLayer("Foreground"), Camera.GetTransformMatrix());

            renderer.Draw(tiledMap, Camera.GetTransformMatrix());
        }
        public void Draw(GameTime gameTime)
        {
            var viewMatrix       = _camera.GetViewMatrix();
            var projectionMatrix = Matrix.CreateOrthographicOffCenter(0, _graphicsDevice.Viewport.Width, _graphicsDevice.Viewport.Height, 0, 0f, -1f);

            _mapRenderer.Draw(_map, ref viewMatrix, ref projectionMatrix);
        }
Exemple #15
0
        public void Draw(SpriteBatch sb, Camera2D camera, GraphicsDevice graphicsDevice)
        {
            var viewMatrix       = camera.GetViewMatrix();
            var projectionMatrix = Matrix.CreateOrthographicOffCenter(0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height, 0, 0f, -1f);

            mapRenderer.Draw(map, viewMatrix, projectionMatrix);
        }
        public override void Draw(GameTime gameTime)
        {
            // This game has a blue background. Why? Because!
            ScreenManager.GraphicsDevice.Clear(ClearOptions.Target, Color.CornflowerBlue, 0, 0);

            // Our player and enemy are both actually just text strings.
            var spriteBatch = ScreenManager.SpriteBatch;

            spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp);

            _mapRenderer.Draw(
                _isShowingMap2 ? _testMap2.GetLayer("LevelGraphics") : _testMap1.GetLayer("LevelGraphics"));

            spriteBatch.DrawString(_font, "Tomas is Awesome", new Vector2(100f, 20f), Color.Green);

            if (_isShowingCollision && !_isShowingMap2)
            {
                foreach (var collisionObject in _testMap1.ObjectLayers[0].Objects.Where(o => o.Type == "Rectangle"))
                {
                    spriteBatch.DrawRectangle(collisionObject.Position, collisionObject.Size, Color.Pink);
                }
                //TODO: Figure out how to draw polygons from the ObjectLayer's Object collection.
                // the one we're trying to draw has a Name and Type == "Slope", and has a Position and collection of Point objects that are offsets from the Position
            }

            spriteBatch.End();

            // If the game is transitioning on or off, fade it out to black.
            if (TransitionPosition > 0 || _pauseAlpha > 0)
            {
                float alpha = MathHelper.Lerp(1f - TransitionAlpha, 1f, _pauseAlpha / 2);
                ScreenManager.FadeBackBufferToBlack(alpha);
            }
        }
Exemple #17
0
        public void Draw(OrthographicCamera camera, SpriteBatch spriteBatch)
        {
            var viewMatrix = camera.GetViewMatrix();

            mapRenderer.Draw(viewMatrix);
            entities.ForEach(entity => { entity.Draw(spriteBatch); });
        }
Exemple #18
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            var viewMatrix       = _camera.GetViewMatrix();
            var projectionMatrix = Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width,
                                                                      GraphicsDevice.Viewport.Height, 0, 0f, -1f);

            _mapRenderer.Draw(_map, ref viewMatrix, ref projectionMatrix);

            _spriteBatch.Begin(transformMatrix: _camera.GetViewMatrix());
            _zombie.Draw(_spriteBatch);
            _spriteBatch.Draw(_fireballSprite);
            _spriteBatch.End();

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

            _spriteBatch.Draw(_motwSprite);
            _spriteBatch.End();


            //_spriteBatch.Begin();
            //_spriteBatch.DrawString(_bitmapFont, string.Format("FPS: {0} Zoom: {1}", _fpsCounter.AverageFramesPerSecond, _camera.Zoom), new Vector2(5, 5), new Color(0.5f, 0.5f, 0.5f));
            //_spriteBatch.End();

            base.Draw(gameTime);
        }
Exemple #19
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.DarkGreen);

            spriteBatch.Begin(transformMatrix: cam.GetViewMatrix(), sortMode: SpriteSortMode.FrontToBack);
            mapRenderer.Draw(myMap, cam.GetViewMatrix());
            if (player.Swing != null)
            {
                //spriteBatch.Draw(testHitSPrite, new Vector2(player.Swing.Position.X-16, player.Swing.Position.Y-16), null, Color.White, 0f, new Vector2(0, 0), new Vector2(1, 1), new SpriteEffects(), (float)((player.Swing.Position.Y + 16) / myMap.HeightInPixels));
            }
            collisionObjects.Draw(spriteBatch, myMap.HeightInPixels);
            //foreach (Obstacle ob in obstacles.AdjacentObstacles(player.Position))
            //{
            //spriteBatch.Draw(ob.Texture, ob.Position, null, Color.White, 0f, new Vector2(0, 0), new Vector2(1, 1), new SpriteEffects(), (float)((ob.HitPos.Y - ob.DrawSort) / myMap.HeightInPixels));
            //}



            player.anim.Draw(spriteBatch, new Vector2(player.Position.X - 32, player.Position.Y - 32), myMap.WidthInPixels);
            //spriteBatch.Draw(_texture, player.HitBox, Color.White);

            spriteBatch.End();

            spriteBatch.Begin();
            spriteBatch.DrawString(font, "Sta: " + Math.Floor(player.Stamina), new Vector2(3, 3), Color.White);
            spriteBatch.DrawString(font, "Str : " + Math.Floor(player.Strength), new Vector2(3, 45), Color.White);
            spriteBatch.End();

            base.Draw(gameTime);
        }
Exemple #20
0
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // TODO: Add your drawing code here
            var viewMatrix       = camera.GetViewMatrix();
            var projectionMatrix = Matrix.CreateOrthographicOffCenter(0,
                                                                      GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 0f, -1f);

            spriteBatch.Begin(transformMatrix: viewMatrix);

            mapRenderer.Draw(map, ref viewMatrix, ref projectionMatrix);
            player.Draw(spriteBatch);

            foreach (Enemy e in enemies)
            {
                e.Draw(spriteBatch);
            }
            gem.Draw(spriteBatch);

            spriteBatch.End();

            spriteBatch.Begin();

            spriteBatch.DrawString(candaraFont, "Score " + score.ToString(), new Vector2(20, 20), Color.Brown);
            for (int i = 0; i < lives; i++)
            {
                spriteBatch.Draw(heart, new Vector2(ScreenWidth - 60 - i * 40, 40), Color.White);
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }
        protected override void Draw(GameTime gameTime)
        {
            //GraphicsDevice.Clear(Color.CornflowerBlue);//not needed if drawing a map, silly!

            spriteBatch.Begin(samplerState: SamplerState.LinearClamp);

            mapRenderer.Draw(map.GetLayer("Base"), camera.GetViewMatrix(fixedFactor));          //draws fixed layer
            mapRenderer.Draw(map.GetLayer("Background"), camera.GetViewMatrix(parallaxFactor)); //draws parallax layer
            mapRenderer.Draw(map.GetLayer("Foreground"), camera.GetViewMatrix());               //draws foreground layer
            //mapRenderer.Draw(map, camera.GetViewMatrix());//OLD, draws all map layers

            //DRAW SPRITES HERE

            spriteBatch.End();

            base.Draw(gameTime);
        }
 public void Draw(SpriteBatch spriteBatch)
 {
     //var viewMatrix = CameraLocator.Camera.GetViewMatrix();
     //var projectionMatrix = Matrix.CreateOrthographicOffCenter(0,
     //    ConfigLocator.Config.VirtualWidth,
     //    ConfigLocator.Config.VirtualHeight, 0, 0f, -1f);
     //mapRenderer.Draw(viewMatrix, projectionMatrix);
     mapRenderer.Draw(map);
 }
Exemple #23
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            _renderer.Draw(_camera.GetViewMatrix());
            //_world.Draw(gameTime);

            base.Draw(gameTime);
        }
Exemple #24
0
 /// <summary>
 /// This is called when the game should draw itself.
 /// </summary>
 /// <param name="gameTime">Provides a snapshot of timing values.</param>
 protected override void Draw(GameTime gameTime)
 {
     GraphicsDevice.Clear(Color.Pink);
     // TODO: Add your drawing code here
     spriteBatch.Begin(transformMatrix: camera.get_transformation(GraphicsDevice), samplerState: SamplerState.PointClamp);
     player.Draw(spriteBatch);
     mapRenderer.Draw(camera.get_transformation(GraphicsDevice));
     spriteBatch.End();
     base.Draw(gameTime);
 }
Exemple #25
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();
            _mapRenderer.Draw(_basicMap);
            spriteBatch.End();

            base.Draw(gameTime);
        }
Exemple #26
0
        public void Draw(SpriteBatch spriteBatch)
        {
            _tiledMapRenderer.Draw(_tiledMap, Camera.GetTransformMatrix());

#if DEBUG
            foreach (var tile in _tileCollisions)
            {
                spriteBatch.Draw(_tileTexture, tile.Rectangle, new Color(Color.Red, 80f));
            }
#endif
        }
Exemple #27
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(new Color(20, 16, 19));

            #region draw ground
            spriteBatch.Begin(transformMatrix: camera.TransformationMatrix, samplerState: SamplerState.PointClamp);
            spriteBatch.Draw(Textures.main, new Vector2(0, 0), color: Color.White, scale: SPRITE_SCALE * Vector2.One);
            spriteBatch.End();
            #endregion

            #region  draw map
            Matrix projection = Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width / SPRITE_SCALE, GraphicsDevice.Viewport.Height / SPRITE_SCALE, 0, 0, -1);

            mapRender.Draw(map, camera.TransformationMatrix, projection);
            #endregion

            //Start the drawing spritebatch for all game objects here
            spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp,
                              DepthStencilState.None, RasterizerState.CullCounterClockwise,
                              transformMatrix: camera.TransformationMatrix);

            Characters.Draw(spriteBatch, camera);
            GameObjects.Draw(spriteBatch, camera);
            player.Draw(spriteBatch, camera, Textures.pixel);
            UI.Draw(spriteBatch, graphics);

            spriteBatch.End();

            #region draw dialog
            foreach (Character c in Characters.Npcs)
            {
                if (c.Dialog.DrawDialog)
                {
                    spriteBatch.Begin();
                    spriteBatch.Draw(Textures.pixel, new Rectangle(0, 500, graphics.PreferredBackBufferWidth, 300), Color.Black);
                    spriteBatch.End();

                    c.Dialog.Draw(spriteBatch, UI.uiFont, new Vector2(100, 600), Color.White);
                }
            }
            #endregion

            #region draw debug
            if (DEBUG_MODE)
            {
                spriteBatch.Begin(transformMatrix: camera.TransformationMatrix, samplerState: SamplerState.PointClamp);
                spriteBatch.Draw(Textures.pixel, new Rectangle((int)player.Position.X, (int)player.Position.Y, 2, 2), Color.Red);
                spriteBatch.DrawString(UI.debugFont, "(" + Math.Round(player.Position.X) + ", " + Math.Round(player.Position.Y) + ")", new Vector2(player.Position.X, player.Position.Y), Color.Red);
                spriteBatch.End();
            }
            #endregion

            base.Draw(gameTime);
        }
Exemple #28
0
 public override void Draw()
 {
     if (Get <RendererComponent>().Sprite != null)
     {
         DrawSprite(Get <RendererComponent>().Sprite);
     }
     else if (Get <RendererComponent>().TiledMap != null)
     {
         _tiledMapRenderer.Draw(Get <RendererComponent>().TiledMap, MainGame.Instance.MainCamera.GetViewMatrix());
     }
 }
Exemple #29
0
 protected override void Draw(GameTime gameTime)
 {
     GraphicsDevice.Clear(Color.CornflowerBlue);
     _camera.LookAt(_playerPosition);
     // TODO: Add your drawing code here
     _spriteBatch.Begin(transformMatrix: _camera.GetViewMatrix(), samplerState: SamplerState.PointClamp);
     _tiledMapRenderer.Draw(_camera.GetViewMatrix());
     _spriteBatch.Draw(_playerTexture, _playerPosition, Color.White);
     _spriteBatch.End();
     base.Draw(gameTime);
 }
Exemple #30
0
        public override void Render(GameTime GameTime)
        {
            var CameraMatrix = Game.Camera.GetViewMatrix();

            // Batch -> Normal sprites without effects
            Game.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, transformMatrix: CameraMatrix);

            // Draw Map
            MapRenderer.Draw(Map, CameraMatrix);

            foreach (Unit U in Units)
            {
                if (!U.Selected)
                {
                    U.Draw(Game.SpriteBatch);
                }
            }

            Game.SpriteBatch.End();

            // Batch -> Sprites with Outline shader
            Vector4 OutlineColor = Color.Crimson.ToVector4();

            Game.Effects["Outline"].Parameters["OutlineColor"].SetValue(OutlineColor);

            Game.SpriteBatch.Begin(sortMode: SpriteSortMode.Deferred, blendState: BlendState.AlphaBlend, samplerState: SamplerState.PointClamp,
                                   transformMatrix: CameraMatrix, effect: Game.Effects["Outline"]);

            foreach (Unit U in Units)
            {
                if (U.Selected)
                {
                    Vector2 TextureRes = new Vector2(U.Sprite.SpriteTexture.Width, U.Sprite.SpriteTexture.Height);
                    Game.Effects["Outline"].Parameters["TextureRes"].SetValue(TextureRes);
                    U.Draw(Game.SpriteBatch);
                }
            }

            Game.SpriteBatch.End();

            // Draw selection rectangle
            if (Selecting)
            {
                Game.SpriteBatch.Begin(samplerState: SamplerState.PointClamp);
                Size2  RectSize = new Size2(Math.Abs(Game.MouseState.X - SelectionStart.X), Math.Abs(Game.MouseState.Y - SelectionStart.Y));
                Point2 Origin   = new Point2(Math.Min(SelectionStart.X, Game.MouseState.X), Math.Min(SelectionStart.Y, Game.MouseState.Y));
                Game.SpriteBatch.DrawRectangle(new RectangleF(Origin, RectSize), Color.Green);
                Game.SpriteBatch.End();
            }

            DisplayEditor();
        }