What does OPTION STRICT do?
It sets a flag in the SB compiler that requires all variables to be
declared (
VAR A) before use.
Many that use this also choose to use
type suffixes, because those masochists just can't get enough of this stuff.
What does this even MEAN?
Well, this means that your awesome code should to go from this:
'Despacito Dating Sim, BETA!!! do not steal
'copyright me 2019-30239
X=100
Y=200
VEL=10.2
SPSET 0,4
WHILE DEAD==0
SPOFS 0,X,Y
INC Y,VEL
VEL=VEL*0.97
IF VEL<0.01 THEN DEAD=1
VSYNC
WEND
to this:
'Despacito Dating Sim, RELEASE!!! do not steal
'copyright me 2019-30239
OPTION STRICT
VAR X%=100
VAR Y%=200
VAR VEL#=10.2
VAR DEAD%
SPSET 0,4
WHILE DEAD%==0
SPOFS 0,X%,Y%
INC Y%,VEL#
VEL#=VEL#*0.97
IF VEL#<0.01 THEN DEAD%=1
VSYNC
WEND
Wait, slow down. What's up with the #s and %s?
Geez, I told you this already. They're type suffixes. You've probably used one before, though you might not know it.
- $ is String, which is the one you've probably used a bunch of times already.
- % is Integer, which lets you store whole numbers like 0, 73948, -22, and -1.
- # is Float, or Real. This means you can have numbers with decimal points like 10.2, 3.333335, and -238.44, as well as any values that an Integer can hold!
- For more on types, visit Variable Types (Resource) by 12Me21
What happens when VEL# is added to Y%? Aren't they different types? What happens to the decimal part?
When you add a Float to an Integer (or do any operation between the two), the result becomes a Float. When you try to assign this Float value to an Integer variable (
A%=4.2), the decimal part is completely removed (
4).
Thanks.
You're welcome. :)