Qbasicnews.com
April 09, 2020, 07:55:26 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: memory  (Read 2000 times)
andy
Senior Member
**
Posts: 175



WWW
« on: April 14, 2004, 12:00:41 PM »

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
Logged

eminiscing about trapezoids in conjunction with stratospherical parabolas:

No questions asked.

www.stickskate.com
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #1 on: April 14, 2004, 12:14:56 PM »

Quote from: "andy"
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.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
wizardlife
Na_th_an
*****
Posts: 1456


WWW
« Reply #2 on: April 14, 2004, 12:50:54 PM »

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/
Logged

LooseCaboose
I hold this place together
*****
Posts: 981



« Reply #3 on: April 14, 2004, 07:01:37 PM »

http://qbnz.com/pages/downloads/utilities/memory.zip
Logged

esus saves.... Passes to Moses, shoots, he scores!
KiZ
__/--\__
*****
Posts: 2879


WWW
« Reply #4 on: April 15, 2004, 09:02:16 AM »

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...
Logged
Spotted Cheetah
Ancient QBer
****
Posts: 400



WWW
« Reply #5 on: April 15, 2004, 01:46:28 PM »

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.
Logged

fter 60 million years a civilization will search for a meteorite destroying most of the living creatures around this age...

There must be a better future for the Cheetahs!

http://rcs.fateback.com/
andy
Senior Member
**
Posts: 175



WWW
« Reply #6 on: April 15, 2004, 04:35:11 PM »

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
Logged

eminiscing about trapezoids in conjunction with stratospherical parabolas:

No questions asked.

www.stickskate.com
Spotted Cheetah
Ancient QBer
****
Posts: 400



WWW
« Reply #7 on: April 16, 2004, 08:49:45 PM »

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.
Logged

fter 60 million years a civilization will search for a meteorite destroying most of the living creatures around this age...

There must be a better future for the Cheetahs!

http://rcs.fateback.com/
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!