Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / 2D arrays..?

Author
Message
Murloc
15
Years of Service
User Offline
Joined: 28th Dec 2008
Location: Utena,Lithuania
Posted: 20th Feb 2009 06:21
Still can't get used to it.. Maybe the one part where I need most practice.. Ohh well here's the problem.

How I need to initialise an array which have to hold 2x2 tiles? i mean:

for example.

Then by variating 0,1,2,3 I could edit it? Need a very simple example..

Thanks in advance

~Murloc.

Theory-When you know everything,but nothing works.
Practice-When everything works,but you don't know why.
Programming merges these two-Nothing works,and you don't know why.
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 20th Feb 2009 11:16
int myArray[2][2];
would give you a two by two array.
To get or set top right for example, you may use (depending on whether you want to use row or column first)
myArray[1][0] = 3;
etc
Murloc
15
Years of Service
User Offline
Joined: 28th Dec 2008
Location: Utena,Lithuania
Posted: 20th Feb 2009 11:40 Edited at: 20th Feb 2009 11:44
U didn't understand me.. Or maybe i didn't explained well..

I want to make an 2D array and the use it as map.

For example:


this will represent only one active tile in upper right corner,others with zero will be not existing. But I still can't get it how to make array to hold all the tiles data,I mean values=tiles.

Theory-When you know everything,but nothing works.
Practice-When everything works,but you don't know why.
Programming merges these two-Nothing works,and you don't know why.
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 20th Feb 2009 11:51
Quote: "But I still can't get it how to make array to hold all the tiles data"


Jezza just explained this to you.

Murloc
15
Years of Service
User Offline
Joined: 28th Dec 2008
Location: Utena,Lithuania
Posted: 20th Feb 2009 12:49
Ohh well I got it Thanks guys.

Theory-When you know everything,but nothing works.
Practice-When everything works,but you don't know why.
Programming merges these two-Nothing works,and you don't know why.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 23rd Feb 2009 17:15
int myArray [2][2] = {{0,1},{1,0}};

or, to make it maybe a bit neater

int myArray [2][2] =
{
{0,1},
{1,0}
};

Lilith, Night Butterfly
I'm not a programmer but I play one in the office

Login to post a reply

Server time is: 2024-09-30 19:32:37
Your offset time is: 2024-09-30 19:32:37