Esempio n. 1
0
        public void Draw(SpriteBatch spriteBatch)
        {
            // tile position on screen
            var rect = new Rectangle((int)Position.X - 4, (int)Position.Y - 4, 8, 8);

            // draw the tile outline
            PrimiviteDrawing.DrawRectangle(spriteBatch, rect, 1, Color.White);
        }
Esempio n. 2
0
        protected override void Initialize()
        {
            player      = new Player(this);
            groundTiles = new TileMannager(this);

            base.Initialize();

            PrimiviteDrawing.Init(GraphicsDevice);

            PrepareRenderTarget();
        }
Esempio n. 3
0
        protected override void Draw(GameTime gameTime)
        {
            // PRE RENDER
            GraphicsDevice.SetRenderTarget(renderTarget);
            GraphicsDevice.Clear(Color.Black);

            //spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, Global.Camera.TranslationMatrix);
            spriteBatch.Begin(SpriteSortMode.Deferred,
                              BlendState.AlphaBlend,
                              SamplerState.PointClamp,
                              DepthStencilState.None,
                              RasterizerState.CullNone,
                              null,
                              Global.Camera.TranslationMatrix);

            groundTiles.Draw(gameTime, spriteBatch);
            player.Draw(gameTime, spriteBatch);

            Global.Camera.Draw(spriteBatch);

            spriteBatch.End();

            GraphicsDevice.SetRenderTarget(null); // Back buffer


            // SCREEN RENDER
            GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null);

            var renderHeightComplement = (Window.ClientBounds.Height % renderHeightDesired) / (Window.ClientBounds.Height / renderHeightDesired);
            var renderWidthComplement  = (Window.ClientBounds.Width % renderWidthDesired) / (Window.ClientBounds.Width / renderWidthDesired);

            spriteBatch.Draw(renderTarget, new Vector2(renderWidthComplement / 2, renderHeightComplement / 2), Color.White);

            //spriteBatch.Draw(renderTarget, Vector2.Zero, Color.White);

            if (Global.Debug)
            {
                // draw rect in safe draw area
                var rect = new Rectangle(renderWidthComplement / 2, renderHeightComplement / 2, renderWidthDesired, renderHeightDesired);
                PrimiviteDrawing.DrawRectangle(spriteBatch, rect, 1, Color.Red);
            }

            spriteBatch.End();

            base.Draw(gameTime);
        }
Esempio n. 4
0
        internal void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            for (int i = 0; i < TileLines; i++)
            {
                for (int j = 0; j < TileRows; j++)
                {
                    // get tile of the matrix
                    var tileId = tileMatrix[i, j];

                    // if has id on tileMatrix
                    if (tileId >= 0)
                    {
                        var tileX = tileId % TilePerRowOnTimeSet;
                        var tileY = tileId - (tileId % TilePerRowOnTimeSet);

                        // tile position on texture
                        var tileOriginRect = new Rectangle(tileX * Global.TileSize, tileY * Global.TileSize, Global.TileSize, Global.TileSize);
                        // draw the tile on screen
                        spriteBatch.Draw(tilesTexture, new Vector2(tileX * Global.TileSize, tileY * Global.TileSize), tileOriginRect, Color.White);
                    }
                }
            }

            if (Global.Debug)
            {
                for (int i = 0; i < TileLines; i++)
                {
                    for (int j = 0; j < TileRows; j++)
                    {
                        // tile position on screen
                        var rect = new Rectangle(Global.TileSize * i, Global.TileSize * j, Global.TileSize, Global.TileSize);
                        // draw the tile outline
                        PrimiviteDrawing.DrawRectangle(spriteBatch, rect, 1, Color.Green);
                    }
                }
            }
        }