Exemple #1
0
        public Bitmap generateMiniMap(int mapIndex, loader tileObj, maps mapObj)
        {
            int x = mapObj.mapX[mapIndex];
            int y = mapObj.mapY[mapIndex];

            int    tileW    = tileObj.tileWidth;
            int    tileH    = tileObj.tileHeight;
            Bitmap mapImage = new Bitmap(x, y);

            //Image tempImg = mapImage;
            // using (Graphics g = Graphics.FromImage(mapImage))
            {
                for (int i = 0; i < x * y; i++) //y-1 to skip last row
                {
                    int currPos   = i;
                    int currRow   = 0;
                    int typeIndex = mapObj.mapData[mapIndex][i];
                    int tileIndex = mapObj.mapDataIndices[mapIndex][i];
                    //True img is the index of tiles directly from the file.dat (but stored inside an array)
                    int trueImgIndex = mapObj.DTileIndices[typeIndex][tileIndex];
                    while (currPos >= x) //x-1 to skip last column
                    {
                        currPos -= x;
                        currRow += 1;
                    }

                    mapImage.SetPixel(currPos, currRow, tileObj.tiles[trueImgIndex].GetPixel(15, 15));
                }
            }
            //mapImage = mapImage.Clone(new Rectangle(0,0,x-1,y-1),mapImage.PixelFormat);

            return(mapImage);
        }
Exemple #2
0
        static void initTile()
        {
            //Get data for tile
            CGraphicTileset generator = new CGraphicTileset();

            tileObject = new loader();
            Tuple <string[], Bitmap[], int, int, int> tileData = generator.LoadTileset("Terrain.dat", "img");

            tileObject.lines      = tileData.Item1;
            tileObject.tiles      = tileData.Item2;
            tileObject.numTiles   = tileData.Item3;
            tileObject.tileWidth  = tileData.Item4;
            tileObject.tileHeight = tileData.Item5;
        }
Exemple #3
0
        public EntireMapsIndex generateMapIndex(int mapIndex, loader tileObj, maps mapObj)
        {
            int x = mapObj.mapX[mapIndex];
            int y = mapObj.mapY[mapIndex];

            int             tileW = tileObj.tileWidth;
            int             tileH = tileObj.tileHeight;
            EntireMapsIndex ans   = new EntireMapsIndex();

            ans.data = new int[y][];
            for (int i = 0; i < y; i++)
            {
                ans.data[i] = new int[x];
            }

            //Bitmap mapImage = new Bitmap(x * tileW, y * tileH);
            //Image tempImg = mapImage;

            for (int i = 0; i < x * y; i++)     //y-1 to skip last row
            {
                int currPos   = i;
                int currRow   = 0;
                int typeIndex = mapObj.mapData[mapIndex][i];
                int tileIndex = mapObj.mapDataIndices[mapIndex][i];
                //True img is the index of tiles directly from the file.dat (but stored inside an array)
                int trueImgIndex = mapObj.DTileIndices[typeIndex][tileIndex];
                while (currPos >= x)     //x-1 to skip last column
                {
                    currPos -= x;
                    currRow += 1;
                }
                ans.data[currRow][currPos] = trueImgIndex;

                /*g.DrawImage(tileObj.tiles[trueImgIndex], new Rectangle(currPos * tileW, currRow * tileH, tileW, tileH),  // destination rectangle
                 * 0,                          // source rectangle x
                 * 0,                          // source rectangle y
                 * tileW,                        // source rectangle width
                 * tileH,                       // source rectangle height
                 * GraphicsUnit.Pixel);*/
            }


            return(ans);
        }
Exemple #4
0
        public Bitmap generateMap(int mapIndex, loader tileObj, maps mapObj)
        {
            int x = mapObj.mapX[mapIndex];
            int y = mapObj.mapY[mapIndex];

            int    tileW    = tileObj.tileWidth;
            int    tileH    = tileObj.tileHeight;
            Bitmap mapImage = new Bitmap(x * tileW, y * tileH);
            Image  tempImg  = mapImage;

            using (Graphics g = Graphics.FromImage(mapImage))
            {
                for (int i = 0; i < x * y; i++) //y-1 to skip last row
                {
                    int currPos   = i;
                    int currRow   = 0;
                    int typeIndex = mapObj.mapData[mapIndex][i];
                    int tileIndex = mapObj.mapDataIndices[mapIndex][i];
                    //True img is the index of tiles directly from the file.dat (but stored inside an array)
                    int trueImgIndex = mapObj.DTileIndices[typeIndex][tileIndex];
                    while (currPos >= x) //x-1 to skip last column
                    {
                        currPos -= x;
                        currRow += 1;
                    }

                    g.DrawImage(tileObj.tiles[trueImgIndex], new Rectangle(currPos * tileW, currRow * tileH, tileW, tileH), // destination rectangle
                                0,                                                                                          // source rectangle x
                                0,                                                                                          // source rectangle y
                                tileW,                                                                                      // source rectangle width
                                tileH,                                                                                      // source rectangle height
                                GraphicsUnit.Pixel);
                }
                g.Save();
            }

            return(mapImage);
        }