Page 1 of 1

Changing Sprite Arrays

Posted: Fri Dec 03, 2010 1:25 pm
by ThirtyNitesOfMX
I have my game set up like this:

dim shared character sprite arrays

then i set Char1Name$ = whoever i want to be the 1st character

and it will load their sprites as follows:

DEF SEG = VARSEG(Char1Right(0))
BLOAD path$ + "\Characters\" + CHAR1Name$ + "\rightTIL.til", Varprt(Char1Right(0))
DEF SEG = VARSEG(Char1RightMsk(0))
BLOAD path$ + "\Characters\" + CHAR1Name$ + "\rightMSK.msk", Varprt(Char1RightMsk(0))

the first character is the one i want walking around on the field map.
this all works fine.

when i want to switch out characters, i need to replace all the sprite arrays for char1 with different .til and .msk images so it will show someone else walking around on the map.

i thought i would be able to do this by changing Char1Name$ and then importing images again with the same def seg statements but it says "out of range" when i try and do this.

any help would be greatly appriciated.

Posted: Fri Dec 03, 2010 3:38 pm
by burger2227
Did you use DEF SEG AFTER each PUT for the next BLOAD. You need to reset the pointer to the Default.

I assume each character folder has the same names and the array is big enough.

PS: I sent you an email...

Posted: Fri Dec 03, 2010 10:01 pm
by ThirtyNitesOfMX
def seg after each put command?? thats crazy. how come i can PUT over and over. shouldnt i just need to def seg before i load a different image into it?

Posted: Fri Dec 03, 2010 10:32 pm
by burger2227
This SUB uses one SHARED Image Integer Array. The sprite is indexed after the mask. Just enter the file names and PUT position. Continue PUTs from Image(0) and Image(10000).

Code: Select all

SUB LoadImage (Mask$, Sprite$, Col, Row)
DEF SEG = VARSEG(Image(0)
   BLOAD Mask$, VARPTR(Image(0))
   PUT (Col, Row), Image(0), AND 
   BLOAD Sprite$, VARPTR(Image(10000))
   PUT (Col, Row), Image(10000) 
DEF SEG   ' Restore default BASIC segment.
END SUB
Size the array for what you need.

Ted