Пример #1
0
        private void ChunkDisplay_MouseMove(object sender, MouseEventArgs e)
        {
            switch (e.Button)
            {
            case MouseButtons.Left:
                tilepoint = new Point(((int)(e.X)) / (int)(16 * ZoomLevel), ((int)(e.Y)) / (int)(16 * ZoomLevel));     //Get the tile that was clicked, not the position on the screen
                //Make sure our point is in the chunk!
                if (tilepoint.X < 0)
                {
                    tilepoint.X = 0;
                }
                if (tilepoint.Y < 0)
                {
                    tilepoint.Y = 0;
                }
                if (tilepoint.X >= 8)
                {
                    tilepoint.X = 7;
                }
                if (tilepoint.Y >= 8)
                {
                    tilepoint.Y = 7;
                }

                if (AutoSetDirectionBool)
                {
                    Chunks.ChunkList[curChunk].Mappings[tilepoint.Y][tilepoint.X].Direction = AutoDirection;
                }
                if (AutoSetVisualPlaneBool)
                {
                    Chunks.ChunkList[curChunk].Mappings[tilepoint.Y][tilepoint.X].VisualPlane = AutoVisualPlane;
                }
                if (AutoSetCollisionABool)
                {
                    Chunks.ChunkList[curChunk].Mappings[tilepoint.Y][tilepoint.X].CollisionFlag0 = AutoCollisionA;
                }
                if (AutoSetCollisionBBool)
                {
                    Chunks.ChunkList[curChunk].Mappings[tilepoint.Y][tilepoint.X].CollisionFlag1 = AutoCollisionB;
                }
                if (MenuItem_PlaceTiles.Checked)
                {
                    if (StageTilesList.SelectedIndex < 0)
                    {
                        StageTilesList.SelectedIndex = 0;
                    }
                    Chunks.ChunkList[curChunk].Mappings[tilepoint.Y][tilepoint.X].Tile16x16 = (ushort)StageTilesList.SelectedIndex;
                }
                RedrawChunk();     //If you don't know what this would do then you clearly shouldn't be here lol
                break;

            case MouseButtons.Middle:
                StageTilesList.SelectedIndex = Chunks.ChunkList[curChunk].Mappings[tilepoint.Y][tilepoint.X].Tile16x16;
                StageTilesList.Refresh();
                break;
            }
        }
Пример #2
0
        public void LoadTileSet(Bitmap TileSet)
        {
            StageTilesList.Images.Clear();                               // Clear the previous images, since we load the entire file!
            int tsize = TileSet.Height;                                  //Height of the image in pixels

            for (int i = 0; i < (tsize / 16); i++)                       //We divide by 16 to get the "height" in blocks
            {
                Rectangle CropArea = new Rectangle(0, (i * 16), 16, 16); //we then get tile at Y: i * 16,
                //we have to multiply i by 16 to get the "true Tile value" (1* 16 = 16, 2 * 16 = 32, etc.)

                Bitmap CroppedImage = CropImage(TileSet, CropArea); // crop that image
                StageTilesList.Images.Add(CroppedImage);            // add it to the tile list
            }
            StageTilesList.Refresh();                               // Update the tileList control
        }