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.

DarkBASIC Professional Discussion / problem with loading matrix tiles from array

Author
Message
Section 812
17
Years of Service
User Offline
Joined: 24th Feb 2008
Location:
Posted: 7th Apr 2014 04:41
I'm doing something wrong here. I'm working with saving matrix tiles to an array and then
to a file and loading them, I have read the posts in the forums but they don't seem to work for me. the following code is the method
I'm trying to use. it seems that the array gets saved fine but upon
loading I get an error of illegal tile number.

[/code]DIM tex(80,60)

do

IF mouseclick()=1
set matrix tile 1,xpos,ypos,imnum#
tex(xpos,ypos) = imnum#
endif


loop

function save_textures()
SAVE ARRAY file$+".mtrl",tex(0)
endfunction

function load_textures()
load array texfile$+".mtrl",tex(0)
For xpos= 0 to collums
For ypos= 0 to rows
set Matrix tile 1,xpos,ypos,tex(xpos,ypos)
Next ypos
next xpos
endfunction[code]

does anyone know what I'm doing wrong here?



ShellfishGames
12
Years of Service
User Offline
Joined: 6th Feb 2013
Location:
Posted: 7th Apr 2014 11:06 Edited at: 7th Apr 2014 11:09
Have you made sure that load_textures() is called after the matrix has been created?
I assume rows and collums are global variables. Is it possible that the values differ and the loaded array has a different size?

And finally, although I'm not sure about that, I think load array doesn't work properly with multidimensional arrays.

Also.. this surely isn't taken directly from your actual code, but just a small reconstruction right? The functions seem to lack parameters and the main loop wouldn't do much as xpos, ypos and imnum# aren't defined anywhere.


Edit: If you're sure the matrix exists when calling the loading function, you could also find out which element exactly causes the crash. Note that you're assiging 81*61 vertices in this code, so if you set up your matrix with 80*60 elements that might be the cause.

Section 812
17
Years of Service
User Offline
Joined: 24th Feb 2008
Location:
Posted: 8th Apr 2014 01:32
that code is just a rough draft of the method I was using it's not the actual code. I'm 100% positive the matrix has been created before hand.
I did not know that I was assigning 81/61, guess that means 0 gets counted as well. I will check that out.
I'm sure that it is the array loading and no other element and I think
I remember hearing something about the multidemensional array problem.
I will give it one more go and if that is the case then I'll just
write and read it from a text file.
thank you Shellfishgames



Login to post a reply

Server time is: 2025-05-14 09:31:41
Your offset time is: 2025-05-14 09:31:41