Posts: 273
Threads: 51
Joined: May 2002
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
P.S. What's going on with all the posts? Spring cleaning? :wink:
Posts: 2,020
Threads: 24
Joined: Jun 2002
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.
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Posts: 6,419
Threads: 74
Joined: Mar 2002
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.
Posts: 704
Threads: 0
Joined: Dec 2002
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
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Posts: 594
Threads: 11
Joined: Oct 2002
...or in QB words:
dim shared buffer(32001)
B 4 EVER
Posts: 2,020
Threads: 24
Joined: Jun 2002
true dat, my mistake. forgot about the width/height specs.
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Posts: 273
Threads: 51
Joined: May 2002
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?
Posts: 6,419
Threads: 74
Joined: Mar 2002
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
About tuts, sorry but I don't know... Maybe another poster could help.