(Dynamic Array) Setting Keys & Bricks & Lighting
1) I use to use the older AssArray where I could simply tell it to set "VariableName" at 7. I am now trying to use the Dynamic Array object and find where it lets you retrieve an integer from a Key, but the only Insert Value function I can find is to insert the amount based off a numerical location not a string "VariableName" location. How do I set "VariableName" to 7 with Dynamic Array? If I cannot, then what is the purpose of retrieving by key?
2) I want to create a top-down mine made up of say 50by50 black blocks with a few gold blocks scattered throughout. You will be able to dig down or up to find another floor. I was thinking of using the Dynamic Array to track the contents of each floor of the mine as a 3d Dynamic Array. Each element would contain a 0 for dirt and a 1 for gold, maybe a 2 for cleared out. That way I can rebuild the level at any time if the player re-enters the mine. Does this seem like a reasonable approach and the right tool?
3) I asked this 6 months back, but with the new MMF2 version and a dual-core processor, I thought I might revisit the topic: Simple Lighting. I want the player to only see 2 blocks around him at all times while in the mine. Overlay's seemed clumsy when I tried them last, would the concept of covering each dirt/gold block with a black block to conceal it be too cumbersome? When the player moves Left, uncover a few black blocks on the left to reveal what's underneath and cover back up a few on the right with darkness. Or is there a much simpler way for this?
Thank you,
Tom / Doc4
Re: (Dynamic Array) Setting Keys & Bricks & Lighting
The new AssArray is harrassing me with a License Agreement every time I save or even run the application. Extremely annoying. "Remind me later" is greyed out.
So, I am still trying to figure out how to make the Dynamic Array work like the AssArray. I can "set Key String Test to 1" but none of the Get Commands work with the Key of Test. Can someone please point me in the right direction?
Thanks,
Tom / Doc4
Re: (Dynamic Array) Setting Keys & Bricks & Lighting
You could try the Named Variable object as it is similar to AssArray.
You'll find it in the Bonus Packs.
Re: (Dynamic Array) Setting Keys & Bricks & Lighting
Thank you for the suggestion. I've gone through and replaced all AssArray actions with NameVariable. So long old friend... :(
Does anyone have a better solution or suggestion for my arrays by chance? I have given up on Dynamic Arrays being unable to figure them out. I am now using the "Array" object.
What I am doing is tracking a number 0-5 in X,Y coordinates on a tiled board. This board has multiple floors so I am using the full 3d array. But I need hundreds of these 3d Arrays, one per "dungeon", multiple dungeons per countryside, multiple countrysides per kingdom, multiple kingdoms per world.
So I am saving my little 3d arrays as separate files to be loaded up on frame start. They are named like (WORLD)(KINGDOM)(COUNTRYSIDE)(DUNGEON).(SOME EXTENSION) My concern is that each 150x150x10 array is 900kb. So with say 100 dungeons (arrays) my little game will slowly build up to around 100mb. Is there a better space saver? Is Dynamic Array really the way go?
Thanks,
Tom / Doc4
*in memory of the AssArray*
Re: (Dynamic Array) Setting Keys & Bricks & Lighting
Each entry in an array is a 32-bit (4 bytes) number, so 150x150x10 elements x 4 bytes/element = 900,000 bytes = 900kB.
Though if you're only storing 0-5 in each element, it'll be at least 85% wasted space. This means it should compress really well, so if you distribute your game zipped it should be ok (TEST IT!)
Alternatively, use a more controlled storage. Using the binary object and setting/reading bytes (using a formula to convert from x,y,z into an index) instead of the 4-byte numbers the array stores will make your levels 4x smaller. Using some even cleverer stuff to pack your values into half-bytes, you could half the size again.
Re: (Dynamic Array) Setting Keys & Bricks & Lighting
(as Neo) "Whoa"
Those arrays zipped from 900kb down to 2kb. Holy cow.
I think that should be plenty fine. I recall some Zip extension for MMF, so I'll see how it works and save an ungodly amount of space.
Thank you.
Re: (Dynamic Array) Setting Keys & Bricks & Lighting
My Binary array object can work as an array easily and automatically save compressed with zlib. Nifflas uses it in Knytt Stories.
Re: (Dynamic Array) Setting Keys & Bricks & Lighti
I was gonna say 'use binary array' but Jam did already X) In addition to the suggestions above, I actually think you should attempt to store all information using the binary array object itself, it's a very powerful array object.
In Knytt Stories:
...the full range of every byte is used and have a purpose. In that game, every 'tile' can have a value between 0 and 255 though, to take advantage of the size of a byte.
...the data is zlib compressed. It saves a lot of space too.
Re: (Dynamic Array) Setting Keys & Bricks & Lighti
I took a look at the Binary Array, but found it had the extra step of having to get its position by calling the XYZ location as well. An additional look up to find the XYZ, which isn't a lot, could add up over time compared to the default Array in which you simply just type in the XYZ.
Array: Write( Integer, X, Y, Z)
vs
Binary Array: Write( Integer, CombineXYZ( X,Y,Z))
With the additional step, I was just planning to stick with the Array and use the Zip object to compress everything down.
Nifflas, why do you find it so powerful? Perhaps I need to give it a second look.
Tom
(and no offense intended to Jam here)
Re: (Dynamic Array) Setting Keys & Bricks & Lighti
And what do you think the array object does with that X Y and Z position? Computers aren't 3 dimensional, you know. Binary array is probably faster than the zip object for compression as well.