Пример #1
0
 // Render a Bts image made up of 4 quadrants.
 private void RenderSpecialBts(BlitImage image, int posX, int posY,
                               int q1, int q2, int q3, int q4)
 {
     image.Blit(BtsTilesSmall [q1], posX, posY, false, false);
     image.Blit(BtsTilesSmall [q2], posX + 8, posY, false, false);
     image.Blit(BtsTilesSmall [q3], posX, posY + 8, false, false);
     image.Blit(BtsTilesSmall [q4], posX + 8, posY + 8, false, false);
 }
Пример #2
0
        // Load all bts tiles.
        private void LoadBtsTiles()
        {
            BlitImage tiles = new BlitImage(GraphicsIO.LoadBitmap(BtsTilesFile));
            BlitImage small = new BlitImage(GraphicsIO.LoadBitmap(BtsTilesSmallFile));

            // Load 16x16 tiles;
            BtsTiles.Clear();
            for (int y = 0; y > -tiles.Height; y -= 16)
            {
                for (int x = 0; x > -tiles.Width; x -= 16)
                {
                    BlitImage newTile = new BlitImage(16, 16);
                    newTile.Clear();
                    newTile.Blit(tiles, x, y, false, false);
                    BtsTiles.Add(newTile);
                }
            }

            // Load 8x8 tiles.
            BtsTilesSmall.Clear();
            for (int y = 0; y > -tiles.Height; y -= 8)
            {
                for (int x = 0; x > -tiles.Width; x -= 8)
                {
                    BlitImage newTile = new BlitImage(8, 8);
                    newTile.Clear();
                    newTile.Blit(small, x, y, false, false);
                    BtsTilesSmall.Add(newTile);
                }
            }
        }
Пример #3
0
 // Renders Layer 1 of a screen.
 private void RenderSceenLayer1(BlitImage screenImage, int rowMin, int colMin)
 {
     for (int row = 0; row < 16; row++)
     {
         for (int col = 0; col < 16; col++)
         {
             int  r     = rowMin + row;
             int  c     = colMin + col;
             int  tile  = GetLayer1Tile(r, c);
             bool hFlip = GetLayer1HFlip(r, c);
             bool vFlip = GetLayer1VFlip(r, c);
             screenImage.Blit(RoomTiles [tile], 16 * col, 16 * row, hFlip, vFlip);
         }
     }
 }
Пример #4
0
        // Renders Enemies on a screen.
        private void RenderScreenEnemies(BlitImage screenImage, int rowMin, int colMin)
        {
            EnemySet enemies = ActiveRoomState?.MyEnemySet;

            if (enemies != null)
            {
                foreach (Enemy e in enemies.Enemies)
                {
                    BlitImage graphics = e.MyEnemyType?.Graphics ?? EnemyTypes [0].Graphics;
                    screenImage.Blit(graphics,
                                     e.PosX - 16 * colMin - graphics.Width / 2,
                                     e.PosY - 16 * rowMin - graphics.Height / 2,
                                     false, false);
                }
            }
        }
Пример #5
0
        // Renders PLMs on a screen.
        private void RenderScreenPlms(BlitImage screenImage, int rowMin, int colMin)
        {
            PlmSet plms = ActiveRoomState?.MyPlmSet;

            if (plms != null)
            {
                foreach (Plm p in plms.Plms)
                {
                    BlitImage graphics = p.MyPlmType?.Graphics ?? PlmTypes [0].Graphics;
                    screenImage.Blit(graphics,
                                     16 * (p.PosX - colMin),
                                     16 * (p.PosY - rowMin),
                                     false, false);
                }
            }
        }
Пример #6
0
        // Render map tile sheet.
        public BlitImage RenderMapTileSheet(int paletteRow)
        {
            if (paletteRow < 0 || paletteRow >= 8)
            {
                paletteRow = 0;
            }
            BlitImage MapTileSheet = new BlitImage(128, 128);

            MapTileSheet.Black();
            int offset = 256 * paletteRow;

            for (int y = 0; y < 16; y++)
            {
                for (int x = 0; x < 16; x++)
                {
                    MapTileSheet.Blit(MapTiles [offset + 16 * y + x], 8 * x, 8 * y, false, false);
                }
            }
            return(MapTileSheet);
        }
Пример #7
0
        // Render Area map.
        public BlitImage RenderAreaMap()
        {
            BlitImage image = new BlitImage(512, 256);

            image.Black();
            AreaMap map;

            if (AreaIndex != IndexNone)
            {
                map = (AreaMap)AreaMaps [AreaIndex];
                for (int y = 0; y < 32; y++)
                {
                    for (int x = 0; x < 64; x++)
                    {
                        int  index     = 64 * y + x;
                        int  tileIndex = 256 * map.GetPalette(index) + map.GetTile(index);
                        bool hFlip     = map.GetHFlip(index);
                        bool vFlip     = map.GetVFlip(index);
                        image.Blit(MapTiles [tileIndex], 8 * x, 8 * y, hFlip, vFlip);
                    }
                }
            }
            return(image);
        }
Пример #8
0
//----------------------------------------------------------------------------------------
// BTS Rendering


        // Render bts graphics onto an image.
        public void RenderBts(BlitImage image, int posX, int posY, int bts_type, int bts_value)
        {
            bool h_flip = false;
            bool v_flip = false;
            int  index  = -1;
            int  temp   = 0;

            switch (bts_type)
            {
            case 0x0: // Air
                if (bts_value == 0x00)
                {
                    index = 71;
                }
                break;

            case 0x1: // Slope
                h_flip = ((bts_value >> 6) & 1) > 0;
                v_flip = ((bts_value >> 7) & 1) > 0;
                index  = bts_value & 63;
                break;

            case 0x2: // X-ray air, Spike air
                if (bts_value == 0x00)
                {
                    index = 88;
                }
                if (bts_value == 0x02)
                {
                    index = 90;
                }
                break;

            case 0x3: // Treadmill, Sand
                if (bts_value == 0x08 || bts_value == 0x09)
                {
                    h_flip = (bts_value & 1) > 0;
                    index  = 93;
                }
                if (bts_value == 0x82)
                {
                    index = 94;
                }
                if (bts_value == 0x85)
                {
                    index = 95;
                }
                break;

            case 0x4: // Air (shot)
                if (bts_value < 0x08)
                {
                    index = 72 + bts_value;
                }
                break;

            case 0x5: // H-copy
                if (bts_value > 0x8F)
                {
                    temp      = 1;
                    bts_value = 0x100 - bts_value;
                }
                RenderSpecialBts(image, posX, posY,
                                 50 + temp, 50 + temp, (bts_value >> 4 & 15) + 16, (bts_value & 15) + 16);
                return;

            case 0x6: // Unused
                if (bts_value == 0x00)
                {
                    index = 89;
                }
                break;

            case 0x7: // Air (bomb)
                if (bts_value < 0x08)
                {
                    index = 80 + bts_value;
                }
                break;

            case 0x8: // Solid
                if (bts_value == 0x00)
                {
                    index = 64;
                }
                break;

            case 0x9: // Door
                RenderSpecialBts(image, posX, posY,
                                 48, 49, bts_value >> 4 & 15, bts_value & 15);
                return;

            case 0xA: // Spike, X-ray wall, Enemy breakable
                if (bts_value < 0x02)
                {
                    index = 68 + bts_value;
                }
                if (bts_value == 0x03)
                {
                    index = 70;
                }
                if (bts_value == 0x0E)
                {
                    index = 91;
                }
                if (bts_value == 0x0F)
                {
                    index = 130;
                }
                break;

            case 0xB: // Crumble, Enemy solid, Speed
                if (bts_value < 0x08)
                {
                    index = 104 + bts_value;
                }
                if (bts_value == 0x0B)
                {
                    index = 92;
                }
                if (bts_value == 0x0E)
                {
                    index = 120;
                }
                if (bts_value == 0x0F)
                {
                    index = 128;
                }
                break;

            case 0xC: // Shot, Power bomb, Super, Door cap
                if (bts_value < 0x08)
                {
                    index = 96 + bts_value;
                }
                if (bts_value == 0x08)
                {
                    index = 121;
                }
                if (bts_value == 0x09)
                {
                    index = 129;
                }
                if (bts_value == 0x0A)
                {
                    index = 124;
                }
                if (bts_value == 0x0B)
                {
                    index = 132;
                }
                if (bts_value == 0x40 || bts_value == 0x41)
                {
                    h_flip = (bts_value & 1) > 0;
                    index  = 66;
                }
                if (bts_value == 0x42 || bts_value == 0x43)
                {
                    v_flip = (bts_value & 1) > 0;
                    index  = 67;
                }
                break;

            case 0xD: // V-copy
                if (bts_value > 0x8F)
                {
                    temp      = 1;
                    bts_value = 0x100 - bts_value;
                }
                RenderSpecialBts(image, posX, posY,
                                 52 + temp, (bts_value >> 4 & 15) + 16, 52 + temp, (bts_value & 15) + 16);
                return;

            case 0xE: // Grapple
                if (bts_value < 0x02)
                {
                    index = 122 + bts_value;
                }
                if (bts_value == 0x02)
                {
                    index = 131;
                }
                break;

            case 0xF: // Bomb
                if (bts_value < 0x08)
                {
                    index = 112 + bts_value;
                }
                break;

            default:
                break;
            }

            if (index == -1)
            {
                RenderSpecialBts(image, posX, posY,
                                 54, bts_type + 32, (bts_value >> 4 & 15) + 32, (bts_value & 15) + 32);
            }
            else
            {
                image.Blit(BtsTiles [index], posX, posY, h_flip, v_flip);
            }
        }
Пример #9
0
 // Renders background for a room.
 private void RenderSceenBackground(BlitImage screenImage)
 {
     screenImage.Blit(BackgroundImage, 0, 0, false, false);
 }