c# - Civilization 1 like tilemap generation -


okay so, have looked @ lot of question people self beginners in programming. , of time questions hard answer or understand question is. best specific possible problems above mentioned doesn't happen.

first off have been following tutorials on @ http://xnagpa.net/xna4rpg.php. , tile engine based off 1 jamie mcmahon makes in rpg tutorial series. know general structure of tile engine like.

secondly try explain i'm trying inside tile engine. found article how original civilization generated maps. http://forums.civfanatics.com/showthread.php?t=498630 , rather approach generating "world" style map if will. ie: oceans, continents, islands ect. decided try take , implement tile engine. works part. parts added tile engine supposed randomly pick location in specified map layer (y,x) , location generate chunk of land(or tiles) , replace tiles in map layer tiles created in chunk of land. (ill show code in minute) , desired amount of either number of landmasses(chunks) or continue creating chunks of land until number of land tiles equal desired amount of land tiles.

my problem: program supposed (as mentioned above) except ever makes 1 landmass.(chunk of land tiles) else fine reason not make more 1 landmass. suspect making other landmasses somehow way tile engine set display map layers causing landmass's covered water. maybe layering issue. shouldn't because landmass's part of same layer. i'm baffled why doing this.

   public void generatelandchunks(maplayer layer)     {         tile tile = new tile(0, 3);              random random = new random();              int x = random.next(8, layer.width - 10);              int y = random.next(10, layer.height - 20);              int length = random.next(10, 70);             (int = 0; < length; i++)             {                 if (length != 0 && x > 8 || x < layer.width - 10 && y > 10 || y < layer.height - 20)                 {                     layer.settile(y, x, tile);                     layer.settile(y, x + 1, tile);                     layer.settile(y + 1, x, tile);                  }                  x = random.next(x - 1, x + 2);                 y = random.next(y - 1, y + 2);             }       } 

this method generating actual chunks want to. (above)

            maplayer randomlayer = new maplayer(100, 100);          (int y = 0; y < randomlayer.height; y++)         {             (int x = 0; x < randomlayer.width; x++)             {                 tile tile = new tile(1, 3);                 randomlayer.settile(x, y, tile);             }         }          int landmasses = 5;         (int = 0; < landmasses; i++)         {             randomlayer.generatelandchunks(randomlayer);         } 

this create map layer. set entire map water tiles(tile (1,3)) tell generate 5 landmasses.

it seems should work. , said first one. doesn't display other 4 land masses.

my question: there can see here i'm doing wrong in order accomplish i'm trying do?

if need more of code understand whats going on let me know , ill post ever need. , said other have posted exact same in jamie mcmahon's tile engine.

i'm sorry if have come off unclear or if question hard answer. tried make straight forward possible. thank time.

so text such simple answer. problem new random object generated every time, , "random" values same every time. how random number generators work, numbers not random, "pseudorandom", , if use same random function , same seed same progression of seemingly random numbers.

default random constructor seeds generator value based on time, if 2 generators created small time period time value same.

move random object outside function, used random generations, or move loop inside (but random outside loop).


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -