Main sections
GENSPRITE()
id% = GENSPRITE()
This command returns an index that can be used to open a resource with LOADSPRITE without overwriting already loaded data.
If no more memory is available, -1 will be returned.
The obvious advantage of this approach is that you can write libraries that fit seamlessly into existing projects without interferring with with the existing code.
If using these commands to allocate indicies in any part of your code, you should use them throughout your whole program.
The example here:
LOADSPRITE "foo.png", 0
LOADSPRITE "bar.png", 1
DRAWSPRITE 0,0,0
DRAWSPRITE 1,0,100
SHOWSCREEN
MOUSEWAIT
Can be written as:
GLOBAL gImgFoo = GENSPRITE(); LOADSPRITE "foo.png", gImgFoo
GLOBAL gImgBar = GENSPRITE(); LOADSPRITE "bar.png", gImgBar
DRAWSPRITE gImgFoo,0,0
DRAWSPRITE gImgBar,0,100
SHOWSCREEN
MOUSEWAIT