Generate coordinates in groups of 5 by 5 systematically

I need a function that will systematically generate coordinates 5,5 at a time.

For example:

[php]Starting at 0,0
Run the function.
Generate the coordinates between 0,0 and 5,5.
Run the function.
Generate the coordinates between 0,0 and 5,-5.
Run the function.
Generate the coordinates between 0,0 and -5,-5.
Run the function.
Generate the coordinates between 0,0 and -5,5.
Run the function.
Generate the coordinates between 0,5 and 5,10.
Run the function.
Generate the coordinates between 5,5 and 10,10.
Run the function.
Generate the coordinates between 5,0 and 10,5.[/php]
etc.

I’ve been trying to Pseudo code this, but am struggling with even that. If anyone could maybe write someway to logically figure this out in pseudo code that would be okay, but if anyone knows how to write this as a function that would be even better!

Break down the problem.

How should coordinates be assigned? Random numbers?

No not randomly. The coordinates need to be done systematically, so in order as above in the first post.

What would systematic be?

Generate the coordinates between 0,0 and 5,5
To me mean two numbers between 0 - 5. So, 1,3 would be valid.

Trying to understand what you want to do. So, I can figure out the how to do it

Oh sorry! I mean all the coordinates between those two numbers.

What is the overall description/purpose of what you are doing. And I don’t mean how you think you need to do something.

Okay I’ll try to give a simple explanation of what I’m trying to accomplish:

I’m building a little game where user’s have a territory spot which will be on a coordinate map. But I want to build the map in such a way that the map expands as more user’s join, ensuring their are plenty of free spots.

So in each 5 by 5 section, there will be five players with a territory spot.

EXAMPLE:
Between 0,0 and 5,5 there will be 5 players.
Between 0,0 and -5,5 there will be another 5 players.

So I want to be able to expand the map for every 5 players that join. So I need to dynamically expand the map to ensure continuous room for more players.

If anyone knows of a better/easier way of accomplishing something similar I all ears!

I don’t do game development on that kind of architecture. So, I can’t offer an alternative, but the way you are planning will cause issues when scaling.

Sponsor our Newsletter | Privacy Policy | Terms of Service