HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

The best way to make a chackers-style grid.

02-05-2007, 09:17 PM#1
vesuvan doppleganger
What I am trying to do is create a grid of circle of powers. What would be the most efficient and least aggravating way to script functions that would take two integers and return the corresponding circle, or vice versa? Thanks in advance.

The most obvious way is to just define each circle, but that would be extremely stupid. I could create several regions for the rows/columns and make a loop that would define each circle for me. Perhaps there is an easy way to do this?

By the way, I'm a competent jasser, so don't worry about dolling up any examples. Any ideas at all would be appreciated.
02-05-2007, 10:30 PM#2
Steel_Cold
There are X and Y corrdinants built into the World Editor that you could use. The way to find the different coordinants in your map would be to mouse over the circle and look to the bottom left corner of the screen.

Hope I helped.
02-05-2007, 10:54 PM#3
vesuvan doppleganger
Yes, i am aware of the coordinates. The x/y I am speaking of are the imaginary ones In my grid. I just want to be able to make these functions.

function circlex takes unit circle, returns integer

function circley takes unit circle, returns integer

function findcircle takes integer x, integer y returns unit.

Worst case scenario is that I am going to have to attach two integers to 500 units. Right now the way that I'll be using is to create a region for each column and each row :/, but it still feels very inefficient. Lets see, approximately 500 circles, thats about 46 regions I have to make, which isn't TOO bad, but I can do better.
02-05-2007, 10:59 PM#4
Naakaloh
Defining each circle wouldn't necessarily be incredibly stupid. You don't even need two numbers. Create 64 circles spaced by an offset of 200 units or something and assign their values to an array if you know your starting point you don't even need a region. Divide the index by 8 for the row and mod by 8 for the columns or whatever depending on how you assign them.

Have you actually tried anything yet for yourself? Do you have anything that you're certain you don't want to do?

Edit: Holy crap. 500? I guess by Checker-style, you didn't mean 8 by 8. Nonetheless the regions aren't necessary unless you can demonstrate that they are.
02-05-2007, 11:12 PM#5
vesuvan doppleganger
Are you suggesting that I attach two integers to 500 circles? I need an efficient way of scripting this. And no, I cant just attach a single integer, because then I cant really do any geometry involving the x and y.
02-05-2007, 11:23 PM#6
Ammorth
Use a 2d array. The formula is X+Y*Xmax then store or allocate the CoPs to the proper array index. Then all you have to do is work backwards, and you will have your X and Y. 3D arrays can also be done the same way, just add an extra component.
02-06-2007, 12:00 AM#7
vesuvan doppleganger
I just had the simplest idea ever. say the center of each circle is 100 wc3 units from the others, and my bottom left corner is at (-333,600). I want my bottom-left to be (0,0) in my grid, so the formula would be for a circles x.
(wc3x+333)/100)

lets test this.
(-333+333)/100)
0/100
0

it works for the bottom left, but what about the circle thats to its right?
(-233+333)/100)
100/100
1

so the formula states that (1,?) is to the right of (0,?), It works! Now I just make a formula for y, and its all settled! god I love math. thanks for the help.

*hits self in the head for not thinking this sooner*

EDIT: btw, is there a way to find the exact x and y placement of a unit?
02-06-2007, 12:24 AM#8
Ammorth
GetUnitX() takes unit returns real
GetUnitY() takes unit returns real
02-06-2007, 12:58 AM#9
Naakaloh
My suggestion implied one unit array with as many units as you need, what ever the case you should only have to make one global variable declaration.

Using nested for loops, place circles in rows and assign the unit to an incrementing index for the array; when you get to the number of columns for one row start a new row.

When you want to retreive the row and column of a circle, just look at its index. Dividing the index by the number of rows will give you the row and modulo-ing the index with the number of columns will give you the column.
02-06-2007, 01:27 AM#10
vesuvan doppleganger
I already have a simple thing that requires no storing of any kind, and works perfectly. But your suggestion is also very good, and I will look into it, if my current system has some sort of weakness.