|
-
Jul 24th, 2006, 07:15 PM
#1
tri-dimension Array alternatives
Hi All,
I am looking at options for holding multiple sets of 3 elements of data to represent a 'Starry Background' (x and y co-ordinates and a colour value - all integers).
I was fine with an Array for x and y (int stararry[600][1]) prior to adding the colour component.
I could use a tri-dimensional Array but that could use a ton of memory.
I could use 3 seperate Arrays (each [600]). One for x, one for y and one for colour.
Idea's?
Cheers,
-
Jul 24th, 2006, 08:07 PM
#2
Re: tri-dimension Array alternatives
Ok, possibly a Structure?
Code:
typedef struct starAtributes
{
int x, y, colour;
} starAtributes;
starAtributes stars[600];
Last edited by Bruce Fox; Jul 24th, 2006 at 08:18 PM.
-
Jul 26th, 2006, 04:51 AM
#3
Re: tri-dimension Array alternatives
What makes you think it'll use less memory just because you use a different way of denoting the exact same structure? As long as you have 600 stars, and each star has a x, y and color components, and each of these components is 4 bytes large, you'll use 7200 bytes of memory - which is not that much, btw.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 26th, 2006, 05:06 PM
#4
Re: tri-dimension Array alternatives
My concern was with the tri-state Array. Since then I realised I could use a structure.
I now see that the two will consume the same amount of memory. 
The structure (stars) is easier to use too.
Cheers,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|