The Daily Click ::. Forums ::. Klik Coding Help ::. Four dimensions array? Is the Dynamic array the best way to do that and how does it work?
 

Post Reply  Post Oekaki 
 

Posted By Message

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
27th March, 2009 at 19:33:29 -

From it's help file, it seems like the Dynamic Array could go up to 10 dimensions. It just doesn't work like the normal mmf2 array though. By that I mean that it won't simply let me write a value to XYZ. I really would need help to know how to use that thing.

Or if there is a way to store many values in a single compartment from a normal 3D Array, that would be even better since I wouldn't have to change everything.
As a last resort, I could also probably use 4 different 3D arrays, but it wouldn't be as practical.
------------------------------------------------------------------------
In-dept info of why I need a 4th dimension to my array.
I'm currently working on a level editior where backdrops are created from an external active picture. For now, I've got tile rotation and horizontal flipping to work corectly. Everything works, except for the fact that I can only store one value for every "compartment". So I can only spawn one tile/object per x-y coordinate.
I'd like to be able to create; background, obstacle, foreground & active object all at the same position.

Array values are use as follows:
X dimension = X coordinate on screen (x8 pxls)
Y dimension = Y coordinate on screen (x8 pxls)
Z dimension = Frame number

The values stored are used as follows:
1st digit = Angle
2nd digit = X coord. to paste from active picture
3rd digit = Y coord. to paste from active picture
positive or neg. = Flipped or not
example: 115 or -368


 
...

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
27th March, 2009 at 19:58:18 -

the binary array is probably the *fastest* way to do 4 dimensions, but you'll need to write code to extract x/y/z/t coordinates yourself

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
27th March, 2009 at 20:25:34 -

By "binary array", my guess is that you refer to the normal mmf2 array, is it?

I also guess that by "extract" you meant guetting for example; 321, 145, 344 and 456 from 321145344456 with the mod operator?

If yes, then it wouldn't be possible as it is now, since in my case, each values stored can either be positive or negative. So I couldn't store them one after the other.


 
...

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
27th March, 2009 at 21:06:06 -

Nevermind

Instead of having the first(left) digit possible range of value going from -4 to -1 and 1 to 4, wich was the source of the problem as of why I couldn't store many value together, I'll do this:

I'll add 5 to the value so that it gets to 1 to 4 or 6 to 9. Then I'll subtract 5 to it when I need that value.

A real 4D array would still be nice, but I'm alright for now

 
...

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
30th March, 2009 at 19:56:42 -

A 4-dimensional array? Oh man I did a 3-dimensional one before and that was tough enough to keep straight.
A 4-dimensional one would make my head a'splode!

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
30th March, 2009 at 20:05:03 -

No I meant the binary array object
You can store negative numbers by having them as signed bits.

Try reading this;
http://www.create-games.com/article.asp?id=714

You'd need to create a formula for the 4th dimension, however. The current binary array lets you lookup 1/2/3 dimensions using those exact same formulas as a built in function, but you'd need a custom fourth



Basically your entire array is one long string of 1's and 0's, saved in chunks of 8 (a byte);

10101011101011010101101010101101
would represent a 2x2x1 array. There are 4 elements:
(1)10101011 (2)10101101 (3)01011010 (4)10101101
all the x/y/z formula does is tell the binary object which position to read from, given by those formulas

Edited by Pixelthief

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456
   

Post Reply



 



Advertisement

Worth A Click