Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using multiple sprites with SUB's
#1
Ok i've checked the tutorials, and searched for "sub sprites" and I can't find anything to help.


My problem is this, I'm making a crappy animation, and I have a sub for each scene.

So when i was making the scenes I would make them their own file, then copy and paste into the subs. Now the problem seems to be that you cant have the DATA in the sub, it says:

"Illegal in procedure or DEF FN" I looked up the DEF with the QB help file, doesn't make any sense to me.

So I placed just the DATA into the main program. It works for scene1, which has only one sprite, but once it calls scene2(which uses the sprite from scene1, and a new sprite), it says out of data, and stops at the READ command for the second sprite.

Then I tried putting the entire array into the main program, and only left GET in the subs, so then it says "array not defined", of course.

So anyone have any ideas? And also if you need any of the code to help, just say so.

Thanks
Reply
#2
Post the whole code so that we can help you...
B 4 EVER
Reply
#3
lol....how do you copy and paste from inside qbasic...do you have to open it with notepad or something?[/code]
Reply
#4
DATA can only be read once. To quote myself from another thread:
Quote:Think on DATA as a line of lemmings, each time you read an item of data, the next lemming jumps off the cliff and dies. So you can't READ that lemming(data) again... unless you RESTORE that lemming to life... with RESTORE.

RESTORE brings all the lemmings back to life and lines them up at the top off the cliff. Also, you can put the DATA statements at the end of the code, they don't have to be in the flow control loops at all.
So with that in mind, the best thing to do is group your data under different labels, and use RESTORE on each when needed.
The moral of the story: you can't read dead lemmings.
In a world without walls and doors, who needs Windows and Gates?
Reply
#5
What post was that? I dont really know anything about data labels or anything.

I tried putting RESTORE before the READ statements, but I was just getting black sprites like there was no READ.
Reply
#6
Quote:lol....how do you copy and paste from inside qbasic...do you have to open it with notepad or something?[/code]
Yep, open it with Notepad, and copy the code here.
size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
Reply
#7
Not only that, but when you get Out of Data errors, you should also check your code to see if you read too much data by accident. I sometimes do that when I use FOR ... NEXT loops to read my data...
earn.
Reply
#8
hmm I have WinXP with QBasic v 4.5 I think, its encrypted or something when I open with notepad:

Code:
ü  ‚ Qÿÿ$ ´ ¾Ó ƒ >¿ ®   ‡      Â¦ñ   s  V ÷ ’ º Ä OÚ _ Î    t { h     ¬              Â»R H rightÉ @delayÅ¡  Victoria   Day¤  left²@scene1   z WHEN   color2   color1ß @firework S   C T   xY yä  COL) Wë  d3 joec BF   y2| delay1

heh that's just part of it
Reply
#9
.
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply
#10
You can't put DATAs inside a SUB. All DATA statements have to be in the main section (outside all subs). What you can do, is use a label for each section's data:

Code:
DataForSub1:
DATA ...

DataForSub2:
DATA...

...

And then, inside your SUBs, just do a RESTORE <label> where <label> is the correct label that precedes the DATA you need (DataForSub1 for SUB 1, and such).

About posting code: When you're gonna save the code, be sure to check "Save as Text", then hit Save. That way, QB will get rid of its crappy bytecode format and will save your code as a normal, plain text file that you'll be able to open with notepad.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)