Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Redim problem...
#1
I made a map editor for my engine that you can cutomize the grid width and height of the map to make it versatile. In my game, I have a subroutine that loads the info from the map and allocates the map array according to the width and height of the map. But here's the problem, when I use redim in that subroutine, it won't let me allocate a map that's over (32, 29). When it redims a map with (32, 30), it crashes. Everything seems correct. At the begining I use:
'$dynamic
redim shared Map(1 to 1, 1 to 1) as integer

and in the MapInit subroutine, when it loads the info from the map file, I have:

redim Map(1 to GridXMax, 1 to GridYMax)

Everything seems correct. Like I said, it works if it isn't higher that (32,29) ???
I noticed that if I use Dim instead and don't make it dynamic it works fine for any map size, but the map always have to be the same size. Does anybody know anything about this? Thanks
Reply
#2
i would do this:

Code:
Main:
DIM MAP(1,1)
LoadMapDimensions
SYSTEM 'end this demo

GetMapArray:
REDIM MAP(1 to dimensionX, 1 to dimensionY)
Return

SUB LoadMapDimensions
'load dimensions
gosub GetMapArray
'load mapdata
END SUB

and don't forget that the dimensions you're loading have to start with the coutning #'s, not 0

I didn't exactly change anything did I?
ammit potato!
Reply
#3
Yeah, that's sorta what I did. But the map array has to be dynamic. I want to be able to reload differant size maps into the same array when I switch levels.
Reply
#4
qb.exe /ah
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#5
doesn't that just set arrays into xms? not sure how it works... how does it help?
ammit potato!
Reply
#6
Try Aga's way.

QB/L Rel/Ah

;*)
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#7
Quote:doesn't that just set arrays into xms? not sure how it works... how does it help?

No, it allows arrays to be >64K.
Reply
#8
I tried all that, but to no avail. The array isn't bigger than that, much smaller. I think I located the problem. I unloaded some tiles that I had loaded, and it allowed me a larger map array. So that means it was because I was low on memory. But when I use dim as a static array, it let me use tons more subscripts for my array. Why would declaring a dynamic array reduce the amount of memory available by a lot?
Reply
#9
then the program would only set aside the memory for the tiels as they are needed, rather than at the very beginning of the program.

if using 7.1, try /Ea also, without the /ah though
ammit potato!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)