Ejemplo n.º 1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointWrap, null, null, null, transformMatrix: camera.Transfrom);

            for (int z = 0; z < SquaresDepth; z++)
            {
                int layer = z;
                for (int y = 0; y < 50; y++)
                {
                    int row = y;
                    for (int x = 0; x < 100; x++)
                    {
                        int column = x;

                        spriteBatch.Draw(
                            TileSet.TileSetTexture,
                            new Rectangle((x * Scale), (y * Scale), Scale, Scale),
                            TileSet.GetSourceRectangle(MapLoad.Maps(map, layer, row, column)), //need to make variable fro map
                            Color.White,
                            0f,
                            Vector2.Zero,
                            SpriteEffects.None,
                            0f);
                    }
                }
            }

            hero.Draw(spriteBatch);
            base.Draw(gameTime);
            spriteBatch.End();
        }
Ejemplo n.º 2
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            switch (CurrentGameState)
            {
            case GameState.Game1:
                spriteBatch.Begin();
                spriteBatch.Draw(Content.Load <Texture2D>("MainMenu"), new Rectangle(0, 0, WindowWidth, WindowHeight), Color.White);
                btnPlay.Draw(spriteBatch);
                break;

            case GameState.Playing:
                spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointWrap, null, null, null, transformMatrix: Camera.Transfrom);

                for (int z = 0; z < MapDepth; z++)
                {
                    int layer = z;
                    for (int y = 0; y < MapHeight; y++)
                    {
                        int row = y;
                        for (int x = 0; x < MapWidth; x++)
                        {
                            int column = x;

                            spriteBatch.Draw(
                                TileSet.TileSetTexture,
                                new Rectangle((x * Scale), (y * Scale), Scale, Scale),
                                TileSet.GetSourceRectangle(MapLoad.Maps(map, layer, row, column)),     //need to make variable fro map
                                Color.White,
                                0f,
                                Vector2.Zero,
                                SpriteEffects.None,
                                0f);
                        }
                    }
                }

                hero.Draw(spriteBatch);
                archer.Draw(spriteBatch);
                foreach (Sprite projectile in numProjectiles)     //drawing on all projectiles
                {
                    projectile.Draw(spriteBatch);
                }

                int tileNumNW = MapLoad.Maps(map, 1, (int)(hero.position.Y / Scale), (int)(hero.position.X / Scale));
                int tileNumSW = MapLoad.Maps(map, 1, (int)((hero.position.Y + hero.texture.Height * 3) / Scale), (int)(hero.position.X / Scale));
                int tileNumNE = MapLoad.Maps(map, 1, (int)(hero.position.Y / Scale), (int)((hero.position.X + hero.texture.Width * 3) / Scale));
                int tileNumSE = MapLoad.Maps(map, 1, (int)((hero.position.Y + hero.texture.Height * 3) / Scale), (int)((hero.position.X + hero.texture.Width * 3) / Scale));

                //((int)(hero.position.X/Scale)).ToString() + "," + ((int)(hero.position.Y / Scale)).ToString()

                spriteBatch.DrawString(font, tileNumNW.ToString(), hero.position, Color.Black);
                spriteBatch.DrawString(font, tileNumSW.ToString(), new Vector2(hero.position.X, hero.position.Y + hero.texture.Height * 3), Color.Black);
                spriteBatch.DrawString(font, tileNumNE.ToString(), new Vector2(hero.position.X + hero.texture.Width * 3, hero.position.Y), Color.Black);
                spriteBatch.DrawString(font, tileNumSE.ToString(), new Vector2(hero.position.X + hero.texture.Width * 3, hero.position.Y + hero.texture.Height * 3), Color.Black);


                break;

            case GameState.Inventory:
                spriteBatch.Begin();
                break;
            }
            spriteBatch.End();
            base.Draw(gameTime);
        }