gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > Matrix Woes

#55580 - thegamefreak0134 - Thu Sep 29, 2005 5:18 pm

How do you do Matricies in C++? I'm aware that they may not be called that. I'm referring to "Matrix" as seen on any TI graphing calculator that supports them. A matrix is basically an array with 2 dimensions. I understand them, how do I code them?
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]

#55582 - poslundc - Thu Sep 29, 2005 6:00 pm

If you want to do two-dimensional arrays in plain C or C++, just specify multiple sizes for the array:

Code:
int myMatrix[5][3];     // 5 rows, 3 columns
int i, j;

for (i = 0; i < 5; i++)
{
     for (j = 0; j < 3; j++)
     {
           // Assign an interesting value to an element
           myMatrix[i][j] = i + j;
     }
}


If you want to create/use a more sophisticated matrix class in C++, read this faq entry as well as the two entries following it.

Dan.

#55869 - thegamefreak0134 - Mon Oct 03, 2005 4:47 pm

Thanks. Y'all are so helpful! Now I can make my Bejeweled Port. Yipee!!!
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]