World Generation


Throughout development after initially setting up each stage within the game i needed a way for the character to move from stage to stage and creating each stage randomly as you transition would create an instant exploit where you could just move back and fourth between the same stage to eventually come across enough survivors. So in order to not fall into this trap i went for an array and using the specific count of the array to keep track of the players position which moves back and fourth once the player moves to the gaps of each stage.

The following for statement was used to generate the map within the start function.

       for (int i = 0; i < 100; i++)
        {
            MapType = Random.Range(0, 4);
            RNG = Random.Range(0, 100);
            if (SurvivorsCreated < SurvivorsGen)
            {
                if (RNG < SurvivorChance)
                {
                    SurvivorsCreated += 1;
                    MapType = 4;
                }
            }
            Map[i] = MapType;
            Debug.Log("map type: " + MapType);
        }

The numbers 0 to 3 are all different challenging stages with the 4th being the only type containing a survivor, however there is a fifth type which can be generated and is done so once the this void is called by another algorithm.

    public void SurvivorSaved()
    {
        Map[Location] = 5;
        MapUpdated = true;
    }

The fifth map type contains the exact same map as the 4th only without the survivor, making that section of the map without a survivor to find. and the Map updated bool is there to change the current map location once something is done to initiate said change. (such as moving to the edge of the screen or collecting a survivor).


An issue i had found with said generation however is that the majority of survivors sit in on the left hand side of the map while the right hand side is predominately empty and 'devoid of live'. i have been yet to find a fix this this although considering it doesn't 'break' the game it is merely a balancing issue with the distribution of survivors. Although any help would be appreciated.

Get Decaying Pitfall!

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.