Esempio n. 1
0
        /// <summary>
        /// Do the drawing.
        /// TODO: probably should be delegated to another class.
        /// </summary>
        protected override void EndProcessing()
        {
            // TODO: i think this could benefit from the
            // integer rasterising algorith.
            // can also use for rectangles/curves, etc
            // .. also for producing steps for a motionpath
            int dx = x2 - x1;
            int dy = y2 - y1;

            int adx = Math.Abs(dx);
            int ady = Math.Abs(dy);

            if (adx > ady)
            {
                int    len = adx;
                int    ix  = dx / adx;
                double iy;
                if (adx == 0)
                {
                    iy = 0;
                }
                else
                {
                    iy = (double)dy / adx;
                }
                double y = y1;
                double x = x1;
                for (int i = 0; i <= len; i++)
                {
                    pf.DrawImage(img, (int)Math.Round(x), (int)Math.Round(y));
                    y += iy;
                    x += ix;
                }
            }
            else
            {
                int    len = ady;
                int    iy  = dy / ady;
                double ix;
                if (ady == 0)
                {
                    ix = 0;
                }
                else
                {
                    ix = (double)dx / ady;
                }
                double x = x1;
                double y = y1;
                for (int i = 0; i <= len; i++)
                {
                    pf.DrawImage(img, (int)Math.Round(x), (int)Math.Round(y));
                    x += ix;
                    y += iy;
                }
            }
        }
Esempio n. 2
0
 protected override void EndProcessing()
 {
     base.EndProcessing();
     // primative operations on the playfield (like image drawing) is done
     // Playfield itself
     pf.DrawImage(img, x, y);
 }
Esempio n. 3
0
        protected override void EndProcessing()
        {
            BufferCell[,] cells = Host.UI.RawUI.NewBufferCellArray(new string[] { text }, fg, bg);
            Image im = new Image(cells, '\0', 0, 0);

#warning "need to put an enum for alignment"

            pf.DrawImage(im, x, y);
        }
Esempio n. 4
0
        /// <summary>
        /// Draw the tilemap.
        /// FIXME: this should probably be delegated to the TileMap class.
        /// </summary>
        protected override void EndProcessing()
        {
            // optimisations?
            int tw       = tilemap.TileWidth;
            int th       = tilemap.TileHeight;
            int numlines = tilemap.MapHeight;

            // make a -ve offset in the playfield to start drawing tiles
            x -= offsetX % tw;
            y -= offsetY % th;


            // tx,ty is the index into the tile character map
            // TODO: check c# does proper truncate int div
            int tx = offsetX / tw;
            int ty = offsetY / th;

            // these vars get reset after the inner loop, so we save them here
            int txsaved = tx;
            int xsaved  = x;

            // boundary x/y
            int bx = x + w + tw;
            int by = y + h + th;

            // draw the tiles
            while (y < by && ty < numlines)
            {
                string line    = tilemap.Lines[ty];
                int    linelen = line.Length;
                while (x < bx && tx < linelen)
                {
                    string ch  = line.Substring(tx, 1);
                    Image  img = (Image)tilemap.ImageMap[ch];
                    if (img != null)
                    {
                        pf.DrawImage(img, x, y);
                    }
                    tx++;
                    x += tw;
                }
                ty++;
                y += th;
                // reset outer loop vars
                tx = txsaved;
                x  = xsaved;
            }
        }
Esempio n. 5
0
 protected override void ProcessRecord()
 {
     if (sprites != null)
     {
         foreach (Sprite s in sprites)
         {
             if (evenIfInactive || s.Active)
             {
                 s.PreDraw();
                 pf.DrawImage(s.CurrImage, s.X, s.Y);
                 s.PostDraw();
                 if (!noAnim)
                 {
                     s.StepAnim();
                 }
             }
         }
     }
 }