예제 #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);
                    }
                }
            }
        }
예제 #2
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);
                    }
                }
            }
        }
예제 #3
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);
            }
        }
예제 #4
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);
                        }
                    }
                }
            }
        }