Exemple #1
0
        // spawning
        public MCObject Copy()
        {
            MCObject copy = new MCObject(Type, X, Y, Count);

            copy.Location = Location;
            return(copy);
        }
Exemple #2
0
        // assemblers
        private void Disassemble()
        {
            // mode7 objects
            int offset = Bits.GetShort(buffer, 0);

            for (int i = 0; i < 8; i++)
            {
                M7ObjectsA[i] = new MCObject(buffer[offset++], buffer[offset++]);
            }
            for (int i = 0; i < 8; i++)
            {
                M7ObjectsB[i] = new MCObject(buffer[offset++], buffer[offset++]);
            }
            // side-scrolling objects A
            SSObjectsA = new List <MCObject>();
            offset     = Bits.GetShort(buffer, 2);
            WidthA     = Bits.GetShort(buffer, offset); offset += 2;
            while (Bits.GetShort(buffer, offset) != 0xFFFF)
            {
                int x    = Bits.GetShort(buffer, offset) + 256; offset += 2;
                int type = buffer[offset++];
                int size = buffer[offset++];
                int y    = buffer[offset++];
                SSObjectsA.Add(new MCObject(type, x, y, size));
            }
            // side-scrolling objects B
            SSObjectsB = new List <MCObject>();
            offset     = Bits.GetShort(buffer, 4);
            WidthB     = Bits.GetShort(buffer, offset); offset += 2;
            while (Bits.GetShort(buffer, offset) != 0xFFFF)
            {
                int x    = Bits.GetShort(buffer, offset) + 256; offset += 2;
                int type = buffer[offset++];
                int size = buffer[offset++];
                int y    = buffer[offset++];
                SSObjectsB.Add(new MCObject(type, x, y, size));
            }
            // side-scrolling L1 screens
            L1Screens = new List <int>();
            offset    = Bits.GetShort(buffer, 6);
            while (offset != Bits.GetShort(buffer, 8))
            {
                L1Screens.Add(buffer[offset++]);
            }
            // side-scrolling L2 screens
            L2Screens = new List <int>();
            offset    = Bits.GetShort(buffer, 8);
            while (offset != Bits.GetShort(buffer, 10))
            {
                L2Screens.Add(buffer[offset++]);
            }
            // side-scrolling rail screens (2nd map)
            RailScreens = new List <int>();
            offset      = Bits.GetShort(buffer, 10);
            while (offset < buffer.Length)
            {
                RailScreens.Add(buffer[offset++]);
            }
        }
Exemple #3
0
        private void pictureBoxScreens_MouseMove(object sender, MouseEventArgs e)
        {
            int x = e.X - diffX; int y = e.Y - diffY;

            if (x > pictureBoxScreens.Width - 1)
            {
                x = pictureBoxScreens.Width - 1;
            }
            if (x < 0)
            {
                x = 0;
            }
            if (y > pictureBoxScreens.Height - 1)
            {
                y = pictureBoxScreens.Height - 1;
            }
            if (y < 0)
            {
                y = 0;
            }
            //
            if (mouseDownObject >= 0 && e.Button == MouseButtons.Left)
            {
                objectX.Value = Math.Max(256, x);
                objectY.Value = y;
            }
            else if (buttonObjects.Checked)
            {
                for (int i = 0; i < minecartObjects.Count; i++)
                {
                    MCObject mco = minecartObjects[i];
                    if (x >= mco.X && x < mco.X + mco.Width &&
                        y >= mco.Y && y < mco.Y + 16)
                    {
                        pictureBoxScreens.Cursor = Cursors.Hand;
                        mouseOverObject          = i;
                        break;
                    }
                    else
                    {
                        pictureBoxScreens.Cursor = Cursors.Arrow;
                        mouseOverObject          = -1;
                    }
                }
            }
        }
Exemple #4
0
        private void newObject_Click(object sender, EventArgs e)
        {
            if (minecartObjects.Count >= 255)
            {
                MessageBox.Show("Cannot have more than 255 objects.");
                return;
            }
            int      index     = objectIndex;
            int      x         = Math.Abs(screens.AutoScrollPosition.X);
            MCObject newObject = new MCObject(1, Math.Max(272, x + 16), 16, 1);

            minecartObjects.Insert(objectIndex + 1, newObject);
            listBoxObjects.Items.Clear();
            for (int i = 0; i < minecartObjects.Count; i++)
            {
                listBoxObjects.Items.Add("Object " + i);
            }
            objectIndex = index + 1;
        }
Exemple #5
0
        //
        private void pictureBoxScreens_Paint(object sender, PaintEventArgs e)
        {
            if (L1Indexes.Count == 0)
            {
                return;
            }
            e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bicubic;
            Rectangle dst;
            Rectangle src;

            // draw screens
            for (int i = 0; i < L1Indexes.Count; i++)
            {
                dst = new Rectangle(i * 256, 0, 256, 256);
                if (L1Indexes[i] < L1Indexes.Count)
                {
                    src = new Rectangle(0, 0, 256, 256);
                    if (screenIndex < screenImages.Count)
                    {
                        if (Index == 3 && i % 2 == 0)
                        {
                            if (screenBGImage == null)
                            {
                                int[] BGPixels = Do.TilesetToPixels(bgtileset.Tileset_tiles, 32, 16, 0, false);
                                screenBGImage = Do.PixelsToImage(BGPixels, 512, 256);
                            }
                            dst.Width = 512;
                            src.Width = 512;
                            e.Graphics.DrawImage(screenBGImage, dst, src, GraphicsUnit.Pixel);
                            dst.Width = 256;
                            src.Width = 256;
                        }
                        e.Graphics.DrawImage(screenImages[i], dst, src, GraphicsUnit.Pixel);
                    }
                }
                else
                {
                    Font  font  = new Font("Tahoma", 10F, FontStyle.Bold);
                    SizeF size  = e.Graphics.MeasureString("(INVALID SCREEN INDEX)", font, new PointF(0, 0), StringFormat.GenericDefault);
                    Point point = new Point(((256 - (int)size.Width) / 2) + (i * 256), (256 - (int)size.Height) / 2);
                    Do.DrawString(e.Graphics, point, "(INVALID SCREEN INDEX)", Color.Black, Color.Red, font);
                }
                if (this.screenIndex == i)
                {
                    Pen pen = new Pen(new SolidBrush(Color.Gray), 2);
                    pen.DashStyle = DashStyle.Dot;
                    e.Graphics.DrawRectangle(pen, new Rectangle(i * 256, 0, 256 - 1, 256 - 1));
                }
            }
            // draw objects
            for (int i = 0; buttonObjects.Checked && i < minecartObjects.Count; i++)
            {
                MCObject obj = minecartObjects[i];
                Pen      pen;
                if (objectIndex == i)
                {
                    pen = new Pen(Color.Red, 2);
                }
                else
                {
                    pen = new Pen(Color.Red, 1);
                }
                e.Graphics.DrawRectangle(pen, new Rectangle(obj.X - 1, obj.Y - 1, obj.Count * 32 - 16 + 2, 16 + 2));
                Bitmap image = obj.Type == 1 ? MinecartData.Coin : MinecartData.Mushroom;
                for (int x = 0; x < obj.Count; x++)
                {
                    e.Graphics.DrawImage(image, x * 32 + obj.X, obj.Y, 16, 16);
                }
            }
        }