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.

Newcomers AppGameKit Corner / Question about multidimensional arrays and their sizes

Author
Message
Mandemon
8
Years of Service
User Offline
Joined: 1st Jan 2016
Location: Finland
Posted: 27th Dec 2017 20:15
Not a first time working with AppGameKit, I got pretty good grasp as using Tier 2 stuff but I am, for a challenge, using Tier 1 to construct a relatively simple strategy game.

However, I tried looking up answer regarding dynamic sizes of multidimensional arrays in Tier 1, but I could not find anything. It seems that you need to predetermine the size of the multidimensional array and once you have done so, you have to redeclare it's size (which can't he done using variables, only constants?) in order to change it's size?

Problem here is that I want to have different sized combat maps, using hexes. However, as I currently understand that multidimensional arrays can't be dynamically adjusted, so I can't just keep adding to them as I need based on configuration file that the game will read.

Is this really the case, or is there some way to readjust the size of the array that I have simply missed based on data that I might not know before the start of the program?
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 27th Dec 2017 20:53
Its possible to resize multidimensional arrays in AppGameKit teir one

https://www.appgamekit.com/documentation/guides/12_array_changes.htm
https://www.appgamekit.com/documentation/guides/arrays_0062.htm

you can use the .length attribute of any array to change the size based on variables

consider this code



and this code to resize the whole array


also checkout the .insert command too that can be used on arrays
Mandemon
8
Years of Service
User Offline
Joined: 1st Jan 2016
Location: Finland
Posted: 27th Dec 2017 22:32
I knew about insert, but when I tried it didn't seem to work. Still, I thank you. I will probably clear out entire map anyway (deleting any sprites etc. in it to release memory while I am at it), so being able to rebuild the entire set sounds good.

Login to post a reply

Server time is: 2024-11-24 04:32:36
Your offset time is: 2024-11-24 04:32:36