Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,089 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Multi dimensional array ??? #291925
09/28/09 23:05
09/28/09 23:05
Joined: Jun 2008
Posts: 21
S
spaceguy76 Offline OP
Newbie
spaceguy76  Offline OP
Newbie
S

Joined: Jun 2008
Posts: 21
What is the correct way to set up a multi dimensional
array in C-lite? In Java it is:

int grad3[][] = {{1,1,0},{-1,1,0},{1,-1,0},{-1,-1,0},
{1,0,1},{-1,0,1},{1,0,-1},{-1,0,-1},
{0,1,1},{0,-1,1},{0,1,-1},{0,-1,-1}};

But that is a syntax error to plug it in that way. Anyone care to enlighten me? Please? tongue

Re: Multi dimensional array ??? [Re: spaceguy76] #291941
09/29/09 07:35
09/29/09 07:35
Joined: Jul 2009
Posts: 36
S
SomebodyNew Offline
Newbie
SomebodyNew  Offline
Newbie
S

Joined: Jul 2009
Posts: 36
I'm not sure whether you mean C-script or lite-C, but as far is I know you can't define a multidimensional array in its declaration line.

That is pretty annoying, I know.

Here is a workaround though:

1.)If you want your array to consist only of zeros -> use a loop.

2.)If you want to fill it with numbers:
Declare a ONEdimensional array and insert all the numbers you need (for example hello[100]). Then use a function that fills in the first 10 numbers in your multidimensional array's first line, the next ten in its second line and so on.

Here is the link, both methods are explained:
http://www.opserver.de/ubb7/ubbthreads.p...true#Post277469

Re: Multi dimensional array ??? [Re: SomebodyNew] #292066
09/29/09 23:31
09/29/09 23:31
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
yeah, unfortunately not possible to predefine multi-dimesional arrays

though you could init a _startup function to do it all for you?

or you could just multiply with width*height and preset it all? = { x, x;}

Re: Multi dimensional array ??? [Re: SomebodyNew] #292194
09/30/09 23:57
09/30/09 23:57
Joined: Jun 2008
Posts: 21
S
spaceguy76 Offline OP
Newbie
spaceguy76  Offline OP
Newbie
S

Joined: Jun 2008
Posts: 21
I paged through the manual a bit more and found out multidimensional arrays aren't kosher. I figured out the work around but wasn't happy with the code I was working with so I scrapped it and started over again. Thanks for the responses.

Re: Multi dimensional array ??? [Re: spaceguy76] #292231
10/01/09 10:23
10/01/09 10:23
Joined: Oct 2007
Posts: 306
Austria
A
Alan Offline
Senior Member
Alan  Offline
Senior Member
A

Joined: Oct 2007
Posts: 306
Austria
How about using a matrix? As far as I know, Matrices and multidimensional Arrays are about the same. Never used them, though, but you could check the manual on that.

Greets,


Alan


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1