Exemplo n.º 1
0
        /// <summary>
        /// Creates a Map Sprite from the given image
        /// </summary>
        public MapSprite(GBA.Image image)
            : base(WIDTH, HEIGHT)
        {
            if (image.Width != Width || image.Height != Height)
            {
                throw new Exception(
                          "Image given has invalid dimensions: it should be " + Width + "x" + Height + " pixels");
            }

            Tileset idleTiles = new GBA.Tileset();
            Tileset moveTiles = new GBA.Tileset();
            byte    size      = 0x02;

            if (image.IsRegionEmpty(new Rectangle(0, 32, Tile.SIZE, HEIGHT - 32)) &&
                image.IsRegionEmpty(new Rectangle(24, 32, Tile.SIZE, HEIGHT - 32)))
            {
                size = 0x01;
            }
            else if (
                image.IsRegionEmpty(new Rectangle(Tile.SIZE, 32 + 32 * 0, Tile.SIZE * 2, Tile.SIZE * 2)) &&
                image.IsRegionEmpty(new Rectangle(Tile.SIZE, 32 + 32 * 1, Tile.SIZE * 2, Tile.SIZE * 2)) &&
                image.IsRegionEmpty(new Rectangle(Tile.SIZE, 32 + 32 * 2, Tile.SIZE * 2, Tile.SIZE * 2)))
            {
                size = 0x00;
            }

            idleTiles.Parse(image, TileMap.Place(Map_Idle(size), 0, 4, W_TILES, H_TILES));
            moveTiles.Parse(image, TileMap.Place(Map_Move(), 4, 0, W_TILES, H_TILES));

            AddSprite(new Sprite(image.Colors, idleTiles, new TileMap(Map_Idle(size))), 0 * 8, 4 * 8);
            AddSprite(new Sprite(image.Colors, moveTiles, new TileMap(Map_Move())), 4 * 8, 0 * 8);
            IdleSize = size;
        }
Exemplo n.º 2
0
 void Core_LoadTestView()
 {
     try
     {
         GBA.Palette palette = new GBA.Palette(CurrentPalette);
         palette[0] = palette[0].SetAlpha(true);
         GBA.Tileset tileset = null;
         byte        size    = (byte)CurrentIdle["Size"];
         int         frame   = Test_TrackBar.Value * 16;
         GBA.TileMap tilemap = new TileMap(4, 4);
         if (Test_Idle.Checked)
         {
             tilemap.Map(MapSprite.Map_Test(frame, size));
             tileset = CurrentMapSprite.Sprites[MapSprite.IDLE].Sheet;
         }
         frame++;
         if (Test_MoveSide.Checked)
         {
             tilemap.Map(MapSprite.Map_Test(frame));
             tileset = CurrentMapSprite.Sprites[MapSprite.WALK].Sheet;
         }
         frame += 16 * 4;
         if (Test_MoveDown.Checked)
         {
             tilemap.Map(MapSprite.Map_Test(frame));
             tileset = CurrentMapSprite.Sprites[MapSprite.WALK].Sheet;
         }
         frame += 16 * 4;
         if (Test_MoveUp.Checked)
         {
             tilemap.Map(MapSprite.Map_Test(frame));
             tileset = CurrentMapSprite.Sprites[MapSprite.WALK].Sheet;
         }
         frame += 16 * 4;
         if (Test_Selected.Checked)
         {
             tilemap.Map(MapSprite.Map_Test(frame));
             tileset = CurrentMapSprite.Sprites[MapSprite.WALK].Sheet;
         }
         TestSprite = new GBA.Sprite(palette, tileset, tilemap);
         Test_ImageBox.Load(TestSprite);
     }
     catch (Exception ex)
     {
         Program.ShowError("Could not load the map sprite test image.", ex);
     }
 }