Full Version: VPage array...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How many cells in my array [ex: myarray(*cells*)] should have to make a virtual page of one screen. I always use VPage(31999) but that's for a large scroller. And how do I calculate the space necessary for x number of screens held in the array or the buffer if you like. Oh, and a better word for cell. Thanks Smile

P.S. What's going on with all the posts? Spring cleaning? :wink:
the forum was attacked by some people who knew a bug in phpbb2 and most were deleted.

the number of bytes, bits, whatever is what you need to know. in mode 13h, or any 256 color mode, each pixel takes up one byte. since the smallest unit qb has (short of string * 1) is an integer, that takes up two bytes. so think here:

1 (byte per pixel) * 320 (width of screen) * 200 (height of screen) / 2 (bytes per integer) = 32000

since 0 is an array unit too, 31999 is sufficient.

HOWEVER: you dont get a lot of memory in pure does. dos has a 640k memory limit and qb a 64k one (if you dont use $dynamic). if you need to use more than one off screen buffer, or if your program is graphic-intensive in general look into using ems memory.
To make a scroller you DONT need a huge offscreen buffer!! (well, you could do it that way, but it would be SLOW AND MEMORY KILLING).

With your vpage%(32001) buffer you have enough. What you should do is only draw the portion of the game map which the player should see. It is easy to do using tiles.

Check out relsoft's scrolling tutorial to find out.
data (in mode 13) in an array that you can use with GET and PUT, you need 64,004 bytes. (There are 4 extra bytes for size information at the front of the array
...or in QB words:

dim shared buffer(32001)
true dat, my mistake. forgot about the width/height specs.
Suppose I have a map arranged like so where 1 square is one screen and the star is the player, where if he passes the screen the other map loads:


This is a non-scrollable map. If it were scrollable, I understand how to use the screen buffer now. So I would have the left map in memory, then when the player passes the screen boundary, I would clear my map array, reallocate the array to use the second map, then draw the map blah blah blah. Would I have to use $dynamic to reallocate my array which the reallocation would reside in a subroutine? I hear it gets tricky using $dynamic variables. Is there a good tutorial out there which explains proper usage of dynamic array allocation?
It is not very tricky. Also, if you don't use $DYNAMIC, you will get out of memory very soon.

If the map you are gonna load is the same size as the previous, you don't need to reallocate your arrays, just overwrite the values. If it isn't, ERASE will clear your array and REDIM will give it new dimensions. Not so tricky Wink

About tuts, sorry but I don't know... Maybe another poster could help.