예제 #1
0
        private void RenderEnemies(Blitter b, IList <EnemyInstance> enemies)
        {
            b.ChangeSource(Level.SpritePatterns.PatternImage);

            if (enemies != null)
            {
                for (int i = 0; i < enemies.Count; i++)
                {
                    EnemyInstance    s           = enemies[i];
                    SpriteDefinition enemySprite = Level.GetSprite(s.EnemyType);
                    byte             pal         = (byte)(8 + Level.GetSpritePalette(s.EnemyType, s.DifficultByteValue == 8));

                    enemySprite.Draw(b, s.X * 2, s.Y * 2, pal);
                    if (s.Respawn)
                    {
                        EnemyInstance.RespawnSprite.Draw(b, s.X * 2, s.Y * 2, 0);
                    }
                    if (selectedEnemy == i)
                    {
                        Rectangle spriteBounds = enemySprite.Measure();
                        spriteBounds.X += s.X * 16;
                        spriteBounds.Y += s.Y * 16;
                        b.DrawRect(spriteBounds, NesPalette.HighlightEntry);
                    }
                }
            }
        }
 public RenderTask(ScreenRenderer display, Blitter b, Bitmap dest, EnemyInstance[] sprites, DoorInstance[] doors, bool showPhysics, bool invalidate)
 {
     this.display     = display;
     this.b           = b;
     this.doors       = doors;
     this.showPhysics = showPhysics;
     this.sprites     = sprites;
     this.dest        = dest;
     this.invalidate  = invalidate;
 }
예제 #3
0
 private void RenderStandard(Blitter b)
 {
     for (int x = 0; x < 32; x++)
     {
         for (int y = 0; y < 30; y++)
         {
             int tile = tiles[x, y];
             b.BlitTile(tile, x, y, colors[x, y]);
         }
     }
 }
예제 #4
0
        private static void RenderDoors(Blitter b, IList <DoorInstance> doors, int selectedDoorIndex)
        {
            if (doors != null)
            {
                for (int i = 0; i < doors.Count; i++)
                {
                    DoorInstance d = doors[i];
                    //foreach (DoorInstance d in doors) {
                    byte pal = 9;
                    if (d.Type == DoorType.Missile)
                    {
                        pal = 8;
                    }
                    else if (d.Type == DoorType.TenMissile)
                    {
                        pal = 10;
                    }

                    if (d.Side == DoorSide.Left)
                    {
                        if (d.Type == DoorType.MusicChange)
                        {
                            Graphic.DoorSprites.LeftDoorMusic.Draw(b, 2, 0xA, pal);
                        }
                        else
                        {
                            Graphic.DoorSprites.LeftDoor.Draw(b, 2, 0xA, pal);
                        }
                    }
                    else
                    {
                        if (d.Type == DoorType.MusicChange)
                        {
                            Graphic.DoorSprites.RightDoorMusic.Draw(b, 0x1D, 0xA, pal);
                        }
                        else
                        {
                            Graphic.DoorSprites.RightDoor.Draw(b, 0x1D, 0xA, pal);
                        }
                    }

                    if (selectedDoorIndex == i)
                    {
                        b.DrawRect(d.Bounds, NesPalette.HighlightEntry);
                    }
                }
            }
        }
예제 #5
0
        /// <summary>Renders any sprites stored in the sprites array, and the GameItem stored in gameItem, if present, and the item selection, if applicable.</summary>
        private void RenderMiscSprites(Blitter b)
        {
            ////if (gameItem != null)
            ////    gameItem.Draw(b);


            for (int i = 0; i < this._sprites.Count; i++)
            {
                SpriteListItem item = _sprites[i];
                item.SpriteDefinition.Draw(b, item.Location.X, item.Location.Y, (byte)item.PaletteIndex);
            }

            if (selectedItem != null)
            {
                Rectangle selection = selectedItem.GetCollisionRect(); //new Rectangle(selectedItem.ScreenLocation.X * 16, selectedItem.ScreenLocation.Y * 16, 16,16);
                b.DrawRect(selection, NesPalette.HighlightEntry);
            }
        }
예제 #6
0
        /////// <summary>
        /////// Queues an async render. Renders the screen in memory, additionally rendering any doors and enemies specified.
        /////// </summary>
        /////// <param name="b_UTF32">The Blitter object used for rendering.</param>
        /////// <param name="dest">The brush to render to.</param>
        /////// <param name="enemies">An array of enemies to be rendered, or null if there are no enemies.</param>
        /////// <param name="doors">An array of doors to render, or null if there are no doors.</param>
        /////// <param name="showPhysics">If true then the screen will be drawn such that the phyics of the tiles are appearent. Sprites, doors, currentLevelItems, and the selection will be omitted.</param>
        ////public Editroid.Graphic.ScreenRenderer.RenderTask BeginRender(Blitter b, Bitmap dest, EnemyInstance[] sprites, DoorInstance[] doors, bool showPhysics, bool invalidate) {
        ////    Editroid.Graphic.ScreenRenderer.RenderTask task = new Editroid.Graphic.ScreenRenderer.RenderTask(this, b, dest, sprites, doors, showPhysics, invalidate);
        ////    RenderThread.QueueTask(task, true);
        ////    return task;
        ////}

        /// <summary>
        /// Renders the screen in memory, additionally rendering any doors and enemies specified.
        /// </summary>
        /// <param name="b">The Blitter object used for rendering.</param>
        /// <param name="dest">The brush to render to.</param>
        /// <param name="enemies">An array of enemies to be rendered, or null if there are no enemies.</param>
        /// <param name="doors">An array of doors to render, or null if there are no doors.</param>
        /// <param name="showPhysics">If true then the screen will be drawn such that the phyics of the tiles are appearent. Sprites, doors, currentLevelItems, and the selection will be omitted.</param>
        public void Render(Blitter b, Bitmap dest, IList <EnemyInstance> sprites, IList <DoorInstance> doors, bool showPhysics)
        {
            using (b.Begin(Level.Patterns.PatternImage, dest)) {
                ////if (showPhysics) {
                ////    RenderPhysics(b);
                ////    RenderEnemies(b, sprites);
                ////} else {
                ////    RenderStandard(b);
                ////    RenderEnemies(b, sprites);
                ////    RenderDoors(b, doors, selectedDoor);
                ////}

                RenderStandard(b);
                if (showPhysics)
                {
                    RenderPhysics(b);
                }

                RenderEnemies(b, sprites);
                RenderDoors(b, doors, selectedDoor);

                RenderMiscSprites(b);
            }
        }
예제 #7
0
        /// <summary>
        /// Draws a sprite using a blitter.
        /// </summary>
        /// <param name="b_UTF32">The blitter to use to render the sprite.</param>
        /// <param name="xTile">The x-coordinate of the sprite (in 8x8 tiles).</param>
        /// <param name="yTile">The y-coordinate of the sprite (in 8x8 tiles).</param>
        /// <param name="pal">The number of the paletteIndex to render the sprite with.</param>
        /// <remarks>The blitter must be open for rendering before this function
        /// can be called.</remarks>
        public void Draw(Blitter b, int xTile, int yTile, byte pal)
        {
            int row       = 0;
            int destTileX = xTile;
            int destTileY = yTile;

            Blitter.FlipFlags flip = 0;
            byte palette           = pal;
            int  Offset            = 0;
            int  offsetX           = 0;
            int  offsetY           = 0;

            for (int i = 0; i < data.Length; i++)
            {
                palette = pal;
                if (data[i] >= 0xB0 && data[i] <= 0xBF)  // If data is macro, intepret
                {
                    switch (data[i])
                    {
                    case macros.FlipX:
                        flip |= Blitter.FlipFlags.Horizontal;
                        break;

                    case macros.FlipY:
                        flip |= Blitter.FlipFlags.Vertical;
                        break;

                    case macros.D4:
                        Offset  += 1024;
                        offsetY += 4;
                        break;

                    case macros.U4:
                        Offset  -= 1024;
                        offsetY -= 4;
                        break;

                    case macros.L4:
                        Offset  -= 4;
                        offsetX -= 4;
                        break;

                    case macros.R4:
                        Offset  += 4;
                        offsetX += 4;
                        break;

                    case macros.D1:
                        Offset  += 256;
                        offsetY += 1;
                        break;

                    case macros.U1:
                        Offset  -= 256;
                        offsetY -= 1;
                        break;

                    case macros.L1:
                        Offset  -= 1;
                        offsetX -= 1;
                        break;

                    case macros.R1:
                        Offset  += 1;
                        offsetX += 1;
                        break;

                    case macros.NextPal:
                        palette = (byte)((palette + 1) % 4);
                        break;

                    case macros.NextRow:
                        row++;
                        Offset    = 0;
                        destTileX = xTile;
                        destTileY = yTile + row;
                        offsetX   = offsetY = 0;
                        break;
                    }
                }
                else     // if not a macro, it is a tile. Render.
                {
                    if ((destTileX * 8 + offsetX) >= 0 &&
                        (destTileX * 8 + offsetX + 7) < 256 &&
                        (destTileY * 8 + offsetY) >= 0 &&
                        (destTileY * 8 + offsetY + 7) < 240)
                    {
                        b.BlitTileTransparent_Pixel(data[i], destTileX * 8 + offsetX, destTileY * 8 + offsetY, palette, flip); //, Offset);
                        destTileX++;
                    }
                    flip    = 0;
                    palette = pal;
                }
            }
        }
예제 #8
0
 public BlitOperationScope(Blitter b)
 {
     this.b = b;
 }
예제 #9
0
        ////private void RenderPhysics(Blitter b) {
        ////    for(int x = 0; x < 32; x++) {
        ////        for(int y = 0; y < 30; y++) {
        ////            int tile = tiles[x, y];

        ////            // Don't show non-solid tiles
        ////            if(physics[x, y] == Physics.Air)
        ////                tile = 0xFF;

        ////            b.BlitTile(tile, x, y, (byte)(colors[x, y]));

        ////            if(physics[x, y] == Physics.Breakable) {
        ////                b.DrawDitherTile(x, y, 0);
        ////            }
        ////        }
        ////    }
        ////}
        private void RenderPhysics(Blitter b)
        {
            surroundingTilesPhysics phys;

            for (int x = 0; x < 32; x++)
            {
                for (int y = 0; y < 30; y++)
                {
                    int tile = tiles[x, y];

                    GetSurroundingTilePhysics(out phys, x, y);
                    byte  color    = GetColorIndexForPhysics(phys.center);
                    Point location = new Point(x * 8, y * 8);

                    if (phys.center == Physics.Air)   // Fill air tiles
                    {
                        b.FillTile8(x, y, color);
                    }
                    else     // Outline all others
                    {
                        var  physSolid = phys.Solidify();
                        bool drawT     = physSolid.top != physSolid.center;
                        bool drawL     = physSolid.center != physSolid.left;
                        bool drawB     = physSolid.center != physSolid.bottom;
                        bool drawR     = physSolid.center != physSolid.right;
                        bool drawTL    = (drawT | drawL) || ((physSolid.topleft != physSolid.center) && !(drawT | drawL));
                        bool drawTR    = (drawT | drawR) || ((physSolid.topright != physSolid.center) && !(drawT | drawR));
                        bool drawBL    = (drawB | drawL) || ((physSolid.bottomleft != physSolid.center) && !(drawB | drawL));
                        bool drawBR    = (drawB | drawR) || ((physSolid.bottomright != physSolid.center) && !(drawB | drawR));

                        if (drawT)
                        {
                            Rectangle top = Top;
                            top.Offset(location);
                            b.DrawRect(top, color);
                        }
                        if (drawL)
                        {
                            Rectangle left = Left;
                            left.Offset(location);
                            b.DrawRect(left, color);
                        }
                        if (drawB)
                        {
                            Rectangle bottom = Bottom;
                            bottom.Offset(location);
                            b.DrawRect(bottom, color);
                        }
                        if (drawR)
                        {
                            Rectangle right = Right;
                            right.Offset(location);
                            b.DrawRect(right, color);
                        }
                        if (drawTL)
                        {
                            Rectangle topLeft = TopLeft;
                            topLeft.Offset(location);
                            b.DrawRect(topLeft, color);
                        }
                        if (drawTR)
                        {
                            Rectangle topRight = TopRight;
                            topRight.Offset(location);
                            b.DrawRect(topRight, color);
                        }
                        if (drawBL)
                        {
                            Rectangle bottomLeft = BottomLeft;
                            bottomLeft.Offset(location);
                            b.DrawRect(bottomLeft, color);
                        }
                        if (drawBR)
                        {
                            Rectangle bottomRight = BottomRight;
                            bottomRight.Offset(location);
                            b.DrawRect(bottomRight, color);
                        }

                        if (phys.center == Physics.Breakable)
                        {
                            b.DrawDitherTile(x, y, 0);
                        }
                        if (phys.center == Physics.Door || phys.center == Physics.DoorHorizontal || phys.center == Physics.DoorBubble)
                        {
                            b.DrawDitherTile(x, y, color);
                        }

                        if (phys.center == Physics.SlopeRight && y > 0)
                        {
                            b.DrawSlope_UR(x, y - 1, color);
                        }
                        if (phys.center == Physics.SlopeLeft && y > 0)
                        {
                            b.DrawSlope_UL(x, y - 1, color);
                        }
                        if (phys.center == Physics.SlopeTop && y > 0)
                        {
                            b.DrawSlope_Top(x, y - 1, color);
                        }
                    }
                }
            }
        }
예제 #10
0
 /// <summary>
 /// Renders the screen in memory with no enemies or doors.
 /// </summary>
 /// <param name="b">The Blitter object used for rendering.</param>
 /// <param name="dest">The brush to render to.</param>
 public void Render(Blitter b, Bitmap dest)
 {
     Render(b, dest, null, null, false);
 }