Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arrays question
#1
Hallo.

So i was looking for an answer on the forums but couldn't find it.
How do i change content of an array?
I have game maps in array of course and i want to load different screen layout to the same array i used before.

I know i can do:

dim a(10) as ubyte => {1,2,3,...}

Now how to change it to something else?

In the olden days i used data to fill arrays quickly, dut that doesn't seems to be case anymore ^_^

edit: well i guess i can make a 3D array and instead of loading data into 2D array, simply switch to another layer of 3D array. But i dont know what is better memory-wise. The data needs to be there any way, but i don't know, i just don't like having huuuuge 3D array of all the screens in the game in memory at all times...
Plus i was hoping i could load data to new area from file...
Reply
#2
rikokun Wrote:Hallo.
edit: well i guess i can make a 3D array and instead of loading data into 2D array, simply switch to another layer of 3D array. But i dont know what is better memory-wise. The data needs to be there any way, but i don't know, i just don't like having huuuuge 3D array of all the screens in the game in memory at all times...
Plus i was hoping i could load data to new area from file...

I'm not sure I understand your question.
You mean change the ARRAY Shape (dimensions)? Unfortuntely this is not implemented (yet) in ZX BASIC. This are called Dynamic Arrays. They are a bit slower but better under many circumstances.
If your question is not related to this, please tell me so I can help you.
Reply
#3
No, i ment something like

Dim a(4)

let a(0-4) = 1, 2, 3, 4, 5

I know you can put the values stright in the array when you declare it, but it would be nice to be able to be able to change its content later

Never mind, i found a way arround it by poking it using defb and reading data straight out of memory Smile
Reply
#4
rikokun Wrote:No, i ment something like

Dim a(4)

let a(0-4) = 1, 2, 3, 4, 5

I know you can put the values stright in the array when you declare it, but it would be nice to be able to be able to change its content later

Never mind, i found a way arround it by poking it using defb and reading data straight out of memory Smile

I'm confused by this question, too. It's an array - of course you can change the contents.

let a(3)=8 - and you've changed the fourth value (remember it starts at 0) to 8...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)