LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

DATA help

Root / Programming Questions / [.]

zagg2000Created:
How do i use DATA (and what ever els) to put a SP on screen? This is what i mean. DATA "B" B is the bom sprite. when i put a B In Those "" i want a bomb to show up on screen. and the X,Y is according to where in the "" its at.

put a label before your DATAs, like this:
@LABELNAME
DATA "B",10000,"etc."
DATA ...
...
then use RESTORE @labelName to start reading the DATA at that label: use READ variableName to read a single value from the DATA (you'll probably put it in some kind of loop) you can also READ multiple values at once, like: READ firstVariable, secondVariable, ...

Could you possibly make a quick Program based on what i sed earlyer? Please?

Can you give an example of what your DATA would look like?

Well I dont realy know...im new to working with DATA. all i wont you to do is make a small program that places a sprite As may Bs i have in the "". like what the system Game Gunner uses.

12ME21?

You can set the definition number and the position on the data and the load it on other part of your code. Example:
'Array that hold the sprites instances.
VAR sprites[0]

sprites=loadSprites()

'If you want to reload the sprites, then do the following

clearSprites sprites
sprites=loadSprites()

'================================================

DEF loadSprites()
 VAR sprites[0]
 VAR SP,DN,X,Y

 RESTORE @SPRITES
 WHILE 1
   READ DN,X,Y
   IF DN==-1 THEN BREAK
   SP=SPSET(DN)
   SPOFS SP,X,Y
   PUSH sprites,SP
 WEND

 RETURN sprites
END

DEF clearSprites ARR[]
 VAR SP
 WHILE LEN(ARR)>0
  SP=POP(ARR)
  SPCLEAR SP
 WEND
END

@SPRITES
DATA 0,200,100
DATA 1,80,80
DATA -1,0,0


DEF without END

also, where do i put the DATA "B" for the sprite?

DEF without END
I can't see your code but that means that you didn't close a DEF with an "END" sentence.
also, where do i put the DATA "B" for the sprite?
I didn't. You can't set a sprite with a string. (However, you can make a static map data structure to store sprite definition number(value) asosiated with strings(key).)
? spriteMap("B")

DEF spriteMap(S$)
 IF !CHKLABEL("@"+S$) THEN RETURN -1 'NO RESULT
 GOTO "@"+S$
 @A 
 RETURN 0
 @B
 RETURN 1
END


What if i dont wanna print the RESULT?

What if i dont wanna print the RESULT?
remove the question mark

i did. it errored.

NSEXX3KJ Please download this and look at the code.

Remove the question mark
i did. it errored.
You can't have a function with a return value and give it to nothing, something has to eat it
DEF EAT V:END

DEF myDEF()
 RETURN 0
END

EAT myDEF()