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 DBPro Corner / About arrays

Author
Message
Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 27th Aug 2011 03:21 Edited at: 27th Aug 2011 03:25
Hi my friends ,

I am working with my game and I would like to make huge changes in my code.

I have ready made function for my items on the floor , but my current version of my items function are limited , I can drop only 50 items in each subsquare of my game 200 items in each square.

I am studying about Matrix1 Utilities arrays plugin.

I would like to ask , if is it possible to able to change the size of my array in runtime.

For example I have my array:



The last dimension of my array is the amount of maximum items I have in my each subsquare.

Items(Levels,Horizontal,Vertical,Subsquare,max_items).

If I want to redim this array or change the size in the runtime (on the fly) is it possible to be happen?
Matrix1 Utilities are possible to do this?

When one of my subsquares will be full of items then , I will increase the capacity by one and if I pickup the item from the floor again, so the size of the array will decreased again and I will release memory. Or I scan all levels with all dropped items and see which square have the most items in , to resize the array in the largest amount of items.

For example if in my whole levels the most full subsquare have 11 items then I redim all array to 11 like:



Technically , I will have infinity ammount of items dropped and I can release and memory.

So I will reserve memory for 11 items only and not for 50 items for my all levels in my whole game.

And in generic if I want to change my level size from 54,54 to 20,30 or if I want to add or remove some level , for example in my level editor , when I create some adventure , I will need to add some one new level in my module , so , I will need to resize my new dimension of my array from 10 levels deep to 15 levels.



Does all of these are possible?

Thank you...
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 27th Aug 2011 17:04
Just use the DIM command to resize the array as needed:


Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 27th Aug 2011 22:36
If I use dim command again on run time , then I will have the new size?

I didn't know that. This is perfect. I think I solved my infinity dropped items in my games.

I will try it. I will make some changes.
Thank you very very much....

Login to post a reply

Server time is: 2024-11-24 01:21:36
Your offset time is: 2024-11-24 01:21:36