Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you explain how do you create a map.txt file? #1

Open
Mustafa-Agha opened this issue Jan 12, 2024 · 0 comments
Open

Can you explain how do you create a map.txt file? #1

Mustafa-Agha opened this issue Jan 12, 2024 · 0 comments

Comments

@Mustafa-Agha
Copy link

Mustafa-Agha commented Jan 12, 2024

..........................
..........................
..oo..oo..oo..oo..oo..oo..
..oo..oo..oo..oo..oo..oo..
..oo..oo..oo..oo..oo..oo..
..oo..oo..oo..oo..oo..oo..
..oo..oo..ooQQoo..oo..oo..
..oo..oo..ooQQoo..oo..oo..
..oo..oo..oo..oo..oo..oo..
..oo..oo..........oo..oo..
..oo..oo..........oo..oo..
..........oo..oo..........
..........oo..oo..........
oo..oooo..........oooo..oo
QQ..oooo..........oooo..QQ
..........oo..oo..........
..........oooooo..........
..oo..oo..oooooo..oo..oo..
..oo..oo..oo..oo..oo..oo..
..oo..oo..oo..oo..oo..oo..
..oo..oo..oo..oo..oo..oo..
..oo..oo..........oo..oo..
..oo..oo..........oo..oo..
..oo..oo...oooo...oo..oo..
...........o..o...........
...........o..o...........

This is converted by this method

private void GenerateObjects(string[] m)
    {
        for (int i = 0; i < 26; i++)
        {
            for (int j = 0; j < 26; j++)
            {
                Transform t = null;
                if (m[i][j] == 'o')
                {
                    t = Instantiate(wall, new Vector3(j - 13, 13 - (i + 1), 0), wall.rotation) as Transform;
                }
                else if (m[i][j] == 'Q')
                {
                    t = Instantiate(iron, new Vector3(j - 13, 13 - (i + 1), 0), wall.rotation) as Transform;
                }
                else if (m[i][j] == 'b')
                {
                    t = Instantiate(bush, new Vector3(j - 13, 13 - (i + 1), 0), wall.rotation) as Transform;
                }
                else if (m[i][j] == 'i')
                {
                    t = Instantiate(ice, new Vector3(j - 13, 13 - (i + 1), 0), wall.rotation) as Transform;
                }
                else if (m[i][j] == 'w')
                {
                    t = Instantiate(water, new Vector3(j - 13, 13 - (i + 1), 0), wall.rotation) as Transform;
                }
                if (m[i][j] != '.')
                {
                    t.parent = generatedWallFolder;
                }
            }
        }
    }

Can you make a tool to convert specific png to this map.txt file?

I'm thinking of something like convert the png image to 26x26 (416x416 == 16x16) and read each block based on color
If the color is black then we add . if white then we add Q and so on..
I think this will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant