Exemple #1
0
        public void Draw(ExtendedSpriteBatch spriteBatch, Light nearestLight)
        {
            if (Map.TileSet.Tiles.ContainsKey(Name))
            {
                Color tileColor = Color.White;

                if (Config.LIGHTS_ENABLED)
                {
                    tileColor = Color.Black;
                    if (nearestLight != null)
                        tileColor = nearestLight.GetColor(Center);
                }

                spriteBatch.Draw(Map.TileSet.TileSheet, GetRectangle(), Map.TileSet.GetTileRectangle(Name), tileColor);
            }
            else
            {
                spriteBatch.DrawRectangle(new Rectangle(X * Width, Y * Height, Width, Height), Color.White);
            }
        }
Exemple #2
0
        public virtual void Draw(ExtendedSpriteBatch spriteBatch)
        {
            if (IsAnimated)
            {
                if (Animations.ContainsKey(CurrentAnimation))
                {
                    spriteBatch.Draw(Animations[CurrentAnimation].SpriteSheet, new Rectangle(X, Y, Animations[CurrentAnimation].FrameWidth, Animations[CurrentAnimation].FrameHeight), Animations[CurrentAnimation].FrameRectangle, Color.White, 0.0f, new Vector2(0, 0), GetSpriteEffect(), 0);
                }
            }
            else
            {
                spriteBatch.Draw(Sprite, new Rectangle(X, Y, Sprite.Width, Sprite.Height), Color.White);
            }

            if (DrawBoundingBox)
            {
                spriteBatch.DrawRectangle(GetBoundingBox(), Color.Red);
            }
        }
Exemple #3
0
 public void Draw(ExtendedSpriteBatch spriteBatch)
 {
     base.Draw(spriteBatch);
 }
Exemple #4
0
        protected override void LoadContent()
        {
            spriteBatch = new ExtendedSpriteBatch(GraphicsDevice);
            // TODO: Verwenden Sie this.Content, um Ihren Spiel-Content hier zu laden

            TileSet tileSet = new TileSet(64, 64, Content.Load<Texture2D>("tileset"));
            tileSet.AddTileMapping("ground_1", new Vector2(0, 0));
            tileSet.AddTileMapping("ground_2", new Vector2(64, 0));
            tileSet.AddTileMapping("ground_3", new Vector2(128, 0));
            tileSet.AddTileMapping("background", new Vector2(320, 0));

            tileSet.AddTileMapping("plattform_1", new Vector2(3 * 64, 2 * 64));
            tileSet.AddTileMapping("plattform_2", new Vector2(4 * 64, 2 * 64));
            tileSet.AddTileMapping("plattform_3", new Vector2(5 * 64, 2 * 64));

            tileMap = new TileMap(this,960, 512, 64, 64, tileSet);

            tileMap.ResetTiles("background");
            tileMap.tiles[0, 7].Name = "ground_1";
            tileMap.tiles[0, 7].IsSolid = true;
            for (int i = 1; i < 11; i++)
            {
                tileMap.tiles[i, 7].Name = "ground_2";
                tileMap.tiles[i, 7].IsSolid = true;
            }
            tileMap.tiles[11, 7].Name = "ground_3";
            tileMap.tiles[11, 7].IsSolid = true;

            tileMap.tiles[5, 5].Name = "plattform_1";
            tileMap.tiles[5, 5].IsSolid = true;
            tileMap.tiles[6,5].Name = "plattform_2";
            tileMap.tiles[6, 5].IsSolid = true;
            tileMap.tiles[7,5].Name = "plattform_3";
            tileMap.tiles[7, 5].IsSolid = true;

            tileMap.tiles[8, 6].Name = "plattform_2";
            tileMap.tiles[8, 6].IsSolid = true;

            player = new Adventurer(this, 10, 300);
            playerLight = new Light(Color.White, 200, new Vector2(10, 300));
            playerLight.FollowEntity(player);

            tileMap.LightSources.Add(playerLight);
            tileMap.LightSources.Add(new Light(Color.White, 250, new Vector2(450, 100)));

            camera = new Camera(800, 480);
            camera.position = new Vector2(player.X, player.Y);
            camera.FollowEntity(player);
            camera.Zoom = 1f;
        }
Exemple #5
0
 public void Draw(ExtendedSpriteBatch spriteBatch)
 {
     for(int x = 0; x < TileCountX; x++)
         for(int y = 0; y < TileCountY; y++)
             tiles[x,y].Draw(spriteBatch, GetNearestLight(tiles[x,y].Center));
 }