1. ## Text-based spherical map.

Hey everyone. I must preface this by saying that I am a complete novice.

Simply put, I am making a silly text based game, and I am trying to find a way to make the world map a sphere.

By this I mean if the player goes too far to the right, they end up on the left, and too far up, they end up on the bottom.

I can do this easily enough by making it wrap around, but this isn't technically correct as diagonals are involved.

-Me

2. Same as always... give it your best shot, post your code --using code tags please-- and maybe we can help. But until we see code, there's not much we can do.

3. Here goes.

What I'm trying to do is get the math so that the 'map' array is spherical, and not so... flat?

-Me

4. Code:
```int movedir( int dir )
{
switch( dir )
{
case NORTH: if( you.ycoord == 0 ) you.ycoord = YSIZE-1; else you.ycoord--; break;
case EAST: you.xcoord = (you.xcoord + 1) % XSIZE; break;
case SOUTH: you.ycoord = (you.ycoord + 1) % YSIZE; break;
case WEST: if( you.xcoord == 0 ) you.xcoord = XSIZE-1; else you.xcoord--; break;
default: return -1;
}
return 0;
}```
Something like that.

Quzah.

5. Would that give spherical movement, or just loop from the left side to the right, or the top side to the bottom, etc?

6. That wraps around. You aren't really saying how your map is "spherical". Do you have an actual map that's shorter at the poles than the equator? How are you splitting it up? If you're just using a 2D array to store the whole thing, then do something like I've mentioned. You can have alternate sizes for each row, and then just keep track of the particular row size, and call that any place I've used % above.
Code:
`dir = (dir + 1) % rowtable[ row ];`
You could use hexes or something like a soccer ball instead.

Quzah.

7. Would that give spherical movement, or just loop from the left side to the right, or the top side to the bottom, etc?
I think maybe the effect you're going for is when you get to the world-drawing routine, you'll want that to wrap around too, ie when you get to the edge of the map, it will draw the opposite edge so that there's no visual break when you do the warp. (I feel like I didn't make that last sentence very coherent but I'm really tired so that's why.)

At least that's what I hope you're going for, rather than attempting to represent a non-euclidean geometry with text graphics... although I've suddenly become interested in making some sort of non-euclidean puzzle game.