Page 1 of 1

Scripting Difficulties

Posted: Sat Dec 31, 2005 10:34 pm
by DaveUnit
Hokay, here's the situation...
I'm loading images to qb via a script command, it makes an image and index array for the image file. The problem I'm having is, when I want to draw the screen, how do I get QB to draw graphics from those arrays without hard-coding it? I don't wanna have to hard-code in an array to my DrawScreen routine everytime I want a images from a new image file. I need QB to handle that on its own so I can have as many image files as I want (well as much as QB can handle) without having to change add another line of code to my engine.
Any help at all is much appreciated.
Thank you all so much.
G'day,

~Dave~

Posted: Sun Jan 01, 2006 11:26 am
by Seb McClouth
Look around at forum on how to make libraries... That might help ya...

Posted: Sun Jan 01, 2006 2:59 pm
by The Awakened
Post your code, dude. :D

Posted: Sun Jan 01, 2006 4:05 pm
by {Nathan}
Yes, I think I might get what you are saying, but I am not sure. Please elaborate. If you are asking what I think you are, check the tutorial section for TileX (I think that is what it is... it is an old commented program that uses DEF FN. It is pretty good if you are going for tile*tile scrolling. It takes a little work to learn from, but it really is a great thingy...).

Posted: Sun Jan 01, 2006 6:19 pm
by DaveUnit
Sorry for confusing any of you, I'm having a tough time explaining this... Lemme give it another shot.

I want my DrawScreen routine to go through all images loaded and draw them to the screen at their specified coordinates. Ugh, this is hard for me to explain after this...

Rather then having to hard code in a few lines for every new image array I have to put the correct sprite, I want my routine to handle that on its own so I can simply load the images via script, and put them on screen via the DrawMap routine.
So if I say LOADIMAGE whatever.??? in my script then put it on the map, All I want to do is hafta type DRAWSCREEN and the routine will be able to put that image on screen.

I need the routine to draw the screen to recognize image arrays without having to change my code to look for that specific array.

I'm having a hard time explaining this for some reason so if you still aren't getting what I'm trying to say I'll try to word it better yet again. I don't have any real code because I'm still in planning and have no idea of how to do this.
Hope I'm not confusing the hell out of you... :oops:
Sorry for the headache,
~Dave

Posted: Sun Jan 01, 2006 9:27 pm
by The Awakened
Heh, didn't you kind of ask this same question in this thread:

http://www.petesqbsite.com/forum/viewtopic.php?t=1197

:D

That's what you need to do: put all of your images into the same array. It's easier to put them all into the same file and load them all at once. But if you need to load individual files (not reccommended), then the code looks like this:

Code: Select all


DEF SEG = VARSEG(Images(Index))
BLOAD "image.img", VARPTR(Images(Index))
DEF SEG

Index = Index + ImageSize

ImageSize is just a variable that represents the size of one image, in QB integers. Keep Index as a global variable, so that it doesn't reset to 0.

I really recommend you use the first method (put everything in the same file), since its easier to keep track of.

Fire away with any more questions. :)

-The Awakened