View previous topic :: View next topic |
Author |
Message |
Ysoft_Entertainment VB Programmer

Joined: 23 Sep 2003 Posts: 810 Location: Wherever There is a good game.
|
Posted: Tue Apr 15, 2008 6:43 am Post subject: Need a little formula |
|
|
Ok here is what I need
the situation:
I have a 7,7 array, like so
1 2 3 4 5 6 7
1
2
3
4
5
6
7
how would get 2,2 coordinates from 9?
to get 9 you can do this ((2-1)*7)+2. I just don't know what formula to use to get 2,2 from back from 9. _________________ Try my OHR exporter/importer.
OHRGFX
Striving to become better pixel artist then Fenrir Lunaris. Unfortunately the laziness gets in the way of my goals. |
|
Back to top |
|
 |
Moogle1 Scourge of the Seas Halloween 2006 Creativity Winner


Joined: 15 Jul 2004 Posts: 3377 Location: Seattle, WA
|
Posted: Tue Apr 15, 2008 9:59 am Post subject: |
|
|
First of all, your array should be 0-6, otherwise this gets confusing fast.
- 0 1 2 3 4 5 6
0 \ |
1 - X
2
3
4
5
6
Better. So (1,1) would be 1*7+1 = 7. (2,2) would be 2*7+2 = 16.
Your formula in reverse would be:
coord1 = n mod 7
coord2 = n / 7 _________________
|
|
Back to top |
|
 |
Ysoft_Entertainment VB Programmer

Joined: 23 Sep 2003 Posts: 810 Location: Wherever There is a good game.
|
Posted: Tue Apr 15, 2008 10:28 am Post subject: |
|
|
Thanks moogle. _________________ Try my OHR exporter/importer.
OHRGFX
Striving to become better pixel artist then Fenrir Lunaris. Unfortunately the laziness gets in the way of my goals. |
|
Back to top |
|
 |
|