I'm trying to write a civ like game from scratch, but it is to have diagonal wrap: go off the top edge and you come out at the left side the same distance from the north pole (upper left corner); go off the bottom edge and you come ouat at the right side the same distance from the south pole (lower right corner).
I've got a map generator that's pretty good, and it applies the wrap.
Run the attached program (place directly in your root C: directory and click on the executable in the folder) and you will see that land features on the top edge match up with those on the left edge for example. Rain clouds even travel on the wrap correctly during terrain generation, but I can't get the display to correctly show the edges.
All the current code is in the folder, but
here's the relevant function.
Any advice on how to do this?
I've got a map generator that's pretty good, and it applies the wrap.
Run the attached program (place directly in your root C: directory and click on the executable in the folder) and you will see that land features on the top edge match up with those on the left edge for example. Rain clouds even travel on the wrap correctly during terrain generation, but I can't get the display to correctly show the edges.
All the current code is in the folder, but
here's the relevant function.
Code:
void DisplayTerrain()
{
short distance=0;
short tileX=0;
short tileY=0;
short displayX=0;
short displayY=0;
while (tileX<640)
{
while (tileY<640)//tile is where it comes from on the map array
{
displayX=(tileX-zoomX)*zoom;//display is where it shows on the screen
displayY=(tileY-zoomY)*zoom;
//THIS GETS THREE EXTRA MAPS TO THE SOUTHEAST, unchanged orientation
//if (tileX<zoomX)
// displayX=(640-(zoomX-tileX))*zoom;
//if (tileY<zoomY)
// displayY=(640-(zoomY-tileY))*zoom;
if (displayX>0)
if (displayY>0)
if (displayX<640)
if (displayY<640)
StandardDisplay(displayX,displayY,tileX,tileY);
//this creates a northwest corner: totally correct!
//also parts of a mirror image north and south, not right
if (zoomX<1)
{
distance=0-zoomX;
if (tileX<distance)
{
displayX=0-((tileX-distance)*zoom);
};
};
if (zoomY<1)
{
distance=0-zoomY;
if (tileY<distance)
{
displayY=0-((tileY-distance)*zoom);
};
};
if (displayX>0)
if (displayY>0)
if (displayX<640)
if (displayY<640)
StandardDisplay(displayX,displayY,tileX,tileY);
tileY=tileY+1;
};
tileY=0;
tileX=tileX+1;
};
}
Any advice on how to do this?