Qbasicnews.com

Full Version: Saving sprites to memory...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Is there a way that I could put a sprite in memory but make it smaller... for example, a 10x10 sprite... is there any possible way I could save it so that it's less than what DIM(10,10) would bring? This answer would really be appreciated... Thank you...
making smaller files should work for what you want to do, but wouldn't that tend to really slow the process of getting your sprite to video memory when it comes time to display it?
I'm not sure... don't know how to save it, put it in memory, or anything like that and make it smaller at the same time without losing sprite information...
with is the one used in PCX files (RLE?). However, I thought of another snag. When you say "store the sprite in memory," what memory do you mean--the memory allocated by an array? You'd need to know beforehand how big of an array to make. RLE (or whatever PCX files use) doesn't provide that. I don't know what compression method would. I guess you could go through the mechanics of the compression once without actually storing any data anywhere just so you can count the bytes necessary and then go through the compression process again and write the bytes, but that seems to be more cumbersome of a process than it's worth.
Since you are using 10*10 integer elements:

use this for screen 13

Code:
size%=(((x2-x1)+1)*((y2-y1)+1)+4)\2
Dim Array(size%)
Get(x1,y1)-(x2,y2),Array(0)

That divides your size by 2. ;*)
by subtracting 1 from your value of size%, since that was a 0-based array.
Quote:by subtracting 1 from your value of size%, since that was a 0-based array.

*Glenn is Bored. Again.
;*)
I came back to point out that I was thinking of a value of one somewhat larger than the standard value. For standard values of one, he'd actually save 2 bytes.
Quote:Since you are using 10*10 integer elements:

use this for screen 13

Code:
size%=(((x2-x1)+1)*((y2-y1)+1)+4)\2
Dim Array(size%)
Get(x1,y1)-(x2,y2),Array(0)

That divides your size by 2. ;*)

I've heard of this method before... what exactly is it doing?
in mode 13 you need 10 * 10 bytes to store the picture + 4 bytes to store size information. That would be a total of 104 bytes. But if you're going to store the picture in an INTEGER array, you don't need 104 elements. You only need 52 elements. (There are 2 bytes per array element.) The array defined by

DIM ARRAY%(51)

or

DIM ARRAY(51) AS INTEGER

has 52 elements, and thus allocates 104 bytes. (You were using an array containing at least 200 bytes--400 if it was a SINGLE array.)

The GET statement just copies the graphics data from video memory to the array.
Pages: 1 2 3