public static World generateWorld(int width, int height)
        {
            World world = new World(width, height);

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    //World Generation logic here

                    if (y == 20)
                    {
                        world.setTile(new TileGrass(), x, y);
                        world.setBackground(new BackgroundDirt(), x, y);
                    }
                    if (y > 20)
                    {
                        world.setTile(new TileDirt(), x, y);
                        world.setBackground(new BackgroundDirt(), x, y);
                    }
                    if (y > 23)
                    {
                        world.setTile(new TileStone(), x, y);
                        world.setBackground(new BackgroundStone(), x, y);
                    }

                }
            }

            return world;
        }
Exemplo n.º 2
0
        public void generate(World world, int xPos, int yPos)
        {
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    if (world.getTile(xPos + x, yPos + y) != null && !shouldReplaceTiles)
                    {
                        break;
                    }

                    world.setTile(tiles[x + y * width], xPos + x, yPos + y);
                }
            }
        }
Exemplo n.º 3
0
        public override void tick(World world, int xPos, int yPos)
        {
            Random chance = new Random();

            if (world.getTile(xPos, yPos - 1) != null)
            {
                if (chance.Next(800) == 0)
                {
                    world.setTile(new TileDirt(), xPos, yPos);
                }
            }
            else
            {
                /*
                 * A B
                 * CXD
                 * E F
                 */

                //ABCDEF are tiles being checked. X is the grass bloc

                Random random = new Random();

                //A
                {
                    int x = xPos - 1;
                    int y = yPos - 1;

                    if (world.getTile(x, y) != null && world.getTile(x, y).ID == 1)
                    {
                        if (world.getTile(x, y - 1) == null || world.getTile(x, y - 1).isTransparent)
                        {
                            if (random.Next(1000) == 0)
                            {
                                world.setTile(new TileGrass(), x, y);
                            }
                        }
                    }
                }
                //B
                {
                    int x = xPos + 1;
                    int y = yPos - 1;

                    if (world.getTile(x, y) != null && world.getTile(x, y).ID == 1)
                    {
                        if (world.getTile(x, y - 1) == null || world.getTile(x, y - 1).isTransparent)
                        {
                            if (random.Next(1000) == 0)
                            {
                                world.setTile(new TileGrass(), x, y);
                            }
                        }
                    }
                }

                //C
                {
                    int x = xPos - 1;
                    int y = yPos;

                    if (world.getTile(x, y) != null && world.getTile(x, y).ID == 1)
                    {
                        if (world.getTile(x, y - 1) == null || world.getTile(x, y - 1).isTransparent)
                        {
                            if (random.Next(1000) == 0)
                            {
                                world.setTile(new TileGrass(), x, y);
                            }
                        }
                    }
                }

                //D
                {
                    int x = xPos + 1;
                    int y = yPos;

                    if (world.getTile(x, y) != null && world.getTile(x, y).ID == 1)
                    {
                        if (world.getTile(x, y - 1) == null || world.getTile(x, y - 1).isTransparent)
                        {
                            if (random.Next(1000) == 0)
                            {
                                world.setTile(new TileGrass(), x, y);
                            }
                        }
                    }
                }

                //E
                {
                    int x = xPos - 1;
                    int y = yPos + 1;

                    if (world.getTile(x, y) != null && world.getTile(x, y).ID == 1)
                    {
                        if (world.getTile(x, y - 1) == null || world.getTile(x, y - 1).isTransparent)
                        {
                            if (random.Next(1000) == 0)
                            {
                                world.setTile(new TileGrass(), x, y);
                            }
                        }
                    }
                }

                //F
                {
                    int x = xPos + 1;
                    int y = yPos + 1;

                    if (world.getTile(x, y) != null && world.getTile(x, y).ID == 1)
                    {
                        if (world.getTile(x, y - 1) == null || world.getTile(x, y - 1).isTransparent)
                        {
                            if (random.Next(1000) == 0)
                            {
                                world.setTile(new TileGrass(), x, y);
                            }
                        }
                    }
                }
            }
        }