Qbasicnews.com

Full Version: memory
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am about to start a new 2d scrolling game, but I need a lot of sprites in it, how can I load about 200 sprites into arrays.

Also I need a lot of variables which will take up a lot of memory. I was thinking about storing all my variables and sprites in .dat files and loading them when necessary but is there an easier way
Quote:but is there an easier way?

Sorry but no Sad The "other way" is working with EMS and XMS and storing stuff there, but IMHO that is far more complicated than using data files.
and btw, I'd code the engine first before you worry too much about running out of memory. 64k goes a surprisingly long way with just a bunch of tile-sized sprites and operation variables.

[example, Empyrean (link in sig) allocates memory for several hundred 16x16 tiles, plus a backdrop image, and still has mountains of memory left over to store the locations of over a thousand smoke and blood particles.]

EDIT: I just realised that the zip file isn't on my new site. If you're actually interested, it can be found at the old page: http://members.lycos.co.uk/drunkenogre/
Super array handler!!!!

Yeah.. i know... it wouldnt work.. too slow...

But now i think about it... you could use the super array handler to sotre all the sprites in one array. Then when needed, load them into a proper qb array. You could have say, 10 sprite arrays, allowing up t 10 differnt sprites at a time...
If that 200 sprite is not too big, you may be able to BLOAD/BSAVE them in GET and PUT's format. For example I have 72 sprites stored in just 18Kb this way (72*2 at all, this size includes the masks too). So you may not need to do anything with EMS or XMS.
I was thinking about using get and put at any 1 time I may need access up to about 50 sprite + masks, if I could store all those in arrays and use get and put that would work

would it work quick enogh if everytime i needed a sprite I opened a txt file and copied it to an array

I have a 9 * 9 tile screen but some of the sprites will be the same. the main character and all the monsters have 4 different sprites 1 for each direction

If any one is interested it hopefully will be a copy of chips challenge. an old windows 3.11 game
TXT files???

If you want to use them, preload them. Make an init function which displays the pictures from the TXTs, and saves them into arrays (by GETting them).

For example if you have 9*9 sprites:

Code:
FOR i=0 to spritenumber-1
Open... 'Open the file here, and display it's data at
...     'location 0,0 (by PSETting)
GET(0,0)-(8,8),array(i*74) 'array is INTEGER
NEXT i

This should work if you use 16 colors. If you work on the 256 color screen, then the multiplier should be 146 at the array when GETting (I do not know much about GET at 256 colors, it should be tried out which multiplier works fine - the pictures will not overlap, but the array will not have empty spaces between them).

So (16 colors) the array would need to have 14800 elements if you have exactly 200 sprites (it is 29600 byte).

This array will contain all of them, and can be used later with PUT to display the sprites.