How do you use the circle pad?
Root / Programming Questions / [.]
GuzzlerCreated:
We're now like, three topics removed from the title of the thread but,
yeah functions are defined with DEF.
They have certain advantages over GOSUB blocks.
The way the manual (well, the "Instruction List" on the website) organizes the info about DEF is a little confusing (but it's much more complete than it used to be!) Basically it wants to show that there are three ways to use it depending on how many inputs and outputs you have.
DEF(1) gives an overview of all three types, then subsections (2) through (4) give examples of each type.
There are apparently also sprite functions and BG functions, but I don't know anything about those. Once graphics get involved, I become a total novice.
We're now like, three topics removed from the title of the thread but, yeah functions are defined with DEF. They have certain advantages over GOSUB blocks. The way the manual (well, the "Instruction List" on the website) organizes the info about DEF is a little confusing (but it's much more complete than it used to be!) Basically it wants to show that there are three ways to use it depending on how many inputs and outputs you have. DEF(1) gives an overview of all three types, then subsections (2) through (4) give examples of each type. There are apparently also sprite functions and BG functions, but I don't know anything about those. Once graphics get involved, I become a total novice.Ha! lol.
There's a nifty function for using the thumbstick to return button() values in the platformer game sample. The name escapes me but, I thought I'd throw that out there.
I see it in the source code. It's like this:
DEF STKANDBTN()
SLV=0.2 'the minimum the stick has to move in any direction
BTN=BUTTON() 'takes button values
STICK OUT SX,SY 'retrieves stick values
IF (SY>SLV) THEN BTN=BTN OR 1 'makes it so if the stick is going up then BTN counts as an up press and so on
IF (SY<-SLV) THEN BTN=BTN OR 2
IF (SX<-SLV) THEN BTN=BTN OR 4
IF (SX>SLV) THEN BTN=BTN OR 8
RETURN BTN
END