Exemple #1
0
        private void UpdateBlock(int x, int y)
        {
            BitmapData data         = BackBuffer.LockBits(new Rectangle(x * 16, y * 16, 16, 16), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
            int        tileValue    = CurrentWorld.LevelData[x, y];
            int        PaletteIndex = tileValue / 0x40;
            Block      b            = CurrentDefiniton[tileValue];

            RenderTile(_CurrentTable[b[0, 0]], 0, 0, PaletteIndex, data);
            RenderTile(_CurrentTable[b[0, 1]], 0, 8, PaletteIndex, data);
            RenderTile(_CurrentTable[b[1, 0]], 8, 0, PaletteIndex, data);
            RenderTile(_CurrentTable[b[1, 1]], 8, 8, PaletteIndex, data);

            WorldPointer p = CurrentWorld.Pointers.Find(pt => pt.X == x && pt.Y == y);

            if (p != null)
            {
                RenderSpecialTileAlpha(_SpecialTable[0xA2], 0, 0, 5, data, 1.0);
                RenderSpecialTileAlpha(_SpecialTable[0xB2], 0, 8, 5, data, 1.0);
                RenderSpecialTileAlpha(_SpecialTable[0xA3], 8, 0, 5, data, 1.0);
                RenderSpecialTileAlpha(_SpecialTable[0xB3], 8, 8, 5, data, 1.0);
            }

            BackBuffer.UnlockBits(data);

            if (!DelayDrawing)
            {
                Redraw(new Rectangle(x * 16, y * 16, 16, 16));
            }
        }
Exemple #2
0
        private void FullRender()
        {
            if (BackBuffer == null)
            {
                return;
            }

            if (_CurrentTable == null || _CurrentPalette == null || _CurrentDefiniton == null)
            {
                Graphics.FromImage(BackBuffer).Clear(Color.Black);
                return;
            }

            BitmapData data = BackBuffer.LockBits(new Rectangle(0, 0, BackBuffer.Width, BackBuffer.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);

            for (int i = 0; i < _CurrentWorld.Height; i++)
            {
                for (int j = 0; j < _CurrentWorld.Width; j++)
                {
                    int   tileValue    = CurrentWorld.LevelData[j, i];
                    int   PaletteIndex = tileValue / 0x40;
                    Block b            = CurrentDefiniton[tileValue];
                    RenderTile(_CurrentTable[b[0, 0]], j * 16, i * 16, PaletteIndex, data);
                    RenderTile(_CurrentTable[b[0, 1]], j * 16, i * 16 + 8, PaletteIndex, data);
                    RenderTile(_CurrentTable[b[1, 0]], j * 16 + 8, i * 16, PaletteIndex, data);
                    RenderTile(_CurrentTable[b[1, 1]], j * 16 + 8, i * 16 + 8, PaletteIndex, data);

                    if (_ShowPointers)
                    {
                        WorldPointer p = CurrentWorld.Pointers.Find(pt => (pt.X == j && pt.Y == i));
                        if (p != null)
                        {
                            RenderSpecialTileAlpha(_SpecialTable[0xA2], j * 16, i * 16, 5, data, 1.0);
                            RenderSpecialTileAlpha(_SpecialTable[0xB2], j * 16, i * 16 + 8, 5, data, 1.0);
                            RenderSpecialTileAlpha(_SpecialTable[0xA3], j * 16 + 8, i * 16, 5, data, 1.0);
                            RenderSpecialTileAlpha(_SpecialTable[0xB3], j * 16 + 8, i * 16 + 8, 5, data, 1.0);
                        }
                    }
                }
            }
            BackBuffer.UnlockBits(data);
        }