Jump to content

Procedural Maps


AltarofScience

Recommended Posts

I am making a space game. The game requires a map. The map needs to contain one or more galaxies. Each galaxy should have from 100 to 1000 star systems. Each star system needs to possess a random number of planets from 1-10.

I suspect that I can use while loops to control the number of galaxies star systems and planets,  but I need to know how to assign coordinates when making the universe.

Link to comment
https://forums.phpfreaks.com/topic/249006-procedural-maps/
Share on other sites

please, this is really important for my game, how can i create a map with coordinate system to allow ships to "travel"?

i figured out how to generate random coordinates, so i could create coordinates for the center of a galaxy and each star system in a galaxy, and probably make multiple galaxies, but those will all be random dot clusters. i would like to create spiral galaxies with multiple arms of varying sizes and such, and not just dot clusters.

Link to comment
https://forums.phpfreaks.com/topic/249006-procedural-maps/#findComment-1278846
Share on other sites

I made this code:

<?php
$rad=100000;
$h=5000;
$ugal=3;
$gal=0;
while($gal<$ugal){
$xco=rand(-$rad, $rad);
$yco=rand(-$rad, $rad);
$zco=rand(-$h, $h);
echo '|';
echo $xco;
echo ',';
echo $yco;
echo ',';
echo $zco;
$v=rand(10, 20);
$usys=$v;
$sys=0;
$rads=10000;
$hs=500;
while($sys<$usys){
$xcos=rand(-$rads+$xco, $rad+$xco);
$ycos=rand(-$rad+$yco, $rad+$yco);
$zcos=rand(-$h+$zco, $h+$zco);
echo '/';
echo $xcos;
echo ',';
echo $ycos;
echo ',';
echo $zcos;
echo '/';
$sys++;
}
echo '|';
$gal++;
}

 

Which out puts these results, or many others but format:

|40168,58762,-2001/63746,144027,-5153//102639,-17356,-1650//136941,83854,-5998//123011,145799,-4154//76686,137884,-2616//114859,11075,-2067//90787,39466,-1265//131424,34430,-1708//69079,80168,2502//36170,38930,-4500//54599,99982,-5237/||-18611,-27016,-2041/8303,57253,-6618//-8854,44290,-3771//37664,23411,615//12354,-124276,-4452//72974,-43571,1285//64229,32098,-3423//-6861,-46496,-3921//-858,33672,-1419//23574,-25109,346//68339,47876,-6696//61962,-85008,2519//66619,-49085,1084//-7405,71416,-1395//76812,-54102,-1258//-4704,-69404,2914//-23123,-100604,870//16680,-61057,-5105//51008,-10595,2931//2851,-115714,-1975//-25895,60559,-3230/||-88149,52253,912/-29180,148413,4188//-7973,146844,-166//-12551,19757,5617//11357,77370,5572//-93156,103783,3482//-47864,-30258,5419//-78246,86163,5390//-46784,97466,456//-44067,85040,4267//-37549,37293,178/|

 

That format is perfect.

The problem as I said before is that it outputs only dot cluster galaxies. I mean, my game could work fine on all dot cluster galaxies. But I think players would like it better if it was obvious I went to some effort to create some other kinds of galaxies, too.

I have this vague idea that I could use an equation to create a shape, and then accept only coordinate groups that fit in that shape, but I really have no idea how to do that.

Link to comment
https://forums.phpfreaks.com/topic/249006-procedural-maps/#findComment-1278849
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.