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 / dynamic 2d struct arrays? (newbie)

Author
Message
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 18th Feb 2009 04:02
I want to create a dynamic array with 2 dimensions. I could do it like:
int map[(yheight*xwidth]
to get an array the same size as map[xwidth][yheight]

but can i use a struct, on a dynamic array, with 2 dimensions?

err, it's not "Gimm3 teh codez" or anything, but if you could add in declaring map[mapsize][mapsize] to my code below, that'd help alot.

all i get when i run it is a black screen
prasoc
16
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 18th Feb 2009 10:39
You arn't setting "mapsize" to any number. I am not sure about the array of structs, but it might be "map_struct map[mapsize];"
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 18th Feb 2009 13:38
You can't declare a dynamic array like that.

If it is to hold a map, and you are only going to resize it between levels, then the best way is to do this:



Use GetItem(x,y) to access an item in the array, and use AllocateMap(width,height) to create the map, and then to resize it.

Because GetItem returns a reference, you can assign to it too:
GetItem(0,0) = map_struct();

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
prasoc
16
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 18th Feb 2009 17:28
You learn something new every day
Hayer
19
Years of Service
User Offline
Joined: 4th Nov 2005
Location: Norway
Posted: 18th Feb 2009 22:49
and you dont need to declare "x".
U could simply type



Keep it simple.
Questions? Mail me
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 19th Feb 2009 01:10
eh, oh well. i guess it's not that much of a difference between typing
map[10][10]
and
map[mapindex(10,10)]

thanks.

Login to post a reply

Server time is: 2024-11-25 15:42:31
Your offset time is: 2024-11-25 15:42:31