# SmileBASIC for Pi

#### Wingnut

##### Well-known member
3rd Party Module Dev
Tutorial Author
Anyone tried Starter PI, SmileBASIC form Nintendo 3DS on the Raspberry Pi (It's a simple card mage).

Example code of the vector game in the video

Code:
``````'---VECTOL CAR  FOR  PI STARTER
' BY TAKUYA MATSUBARA
ACLS
NW=400
NH=240
XSCREEN 400,240,400/240
VISIBLE 0,1,0
MSG\$=""
MSGCNT=0
EMAX=10
DIM EA[EMAX]
DIM EX[EMAX]
DIM EY[EMAX]
DIM EDST[EMAX]
DIM ESPD[EMAX]
DIM ETYPE[EMAX]
DIM RSLT[EMAX]
DIM RANK[EMAX]
DIM CNT[EMAX]
DIM NAME\$[EMAX]
DIM PX[20],PY[20] 'CHECK POINT
CHMIN=&H0
CHMAX=&H7F
DIM VEC\$[CHMAX+1]
SIZE=120
SIZEH=SIZE/2
VR=240*1.5
CSIZE=SIZE/10
HX=400/2
HY=240*3/4
VIEWPAGE=0
DRAWPAGE=1
GPRIO 0
'---INIT VECTOL FONT
DIM LN[7*7],AG[7*7]  'VECTOL DATA
CX=3
CY=3
FOR Y=0 TO 6
FOR X=0 TO 6
I=X+(Y*7)
DELTAX=(X-CX)
DELTAY=(Y-CY)
LN[I]=SQR((DELTAX*DELTAX)+(DELTAY*DELTAY))
AG[I]=ATAN(DELTAY,DELTAX)
NEXT
NEXT
WHILE 1
GOSUB @TITLE
IF BT AND (1<<10) THEN BREAK
GOSUB @GAMEPLAY
WEND
ACLS
END
'---
@TITLE
REPEAT
VSYNC 1
UNTIL BUTTON()==0
W=10
AT=0
WHILE 1
SWAP VIEWPAGE,DRAWPAGE
GPAGE VIEWPAGE,DRAWPAGE
GFILL 0,0,NW-1,NH-1,#BLACK
AT=AT+1
A\$="VECTOL CAR"
X=HX-(LEN(A\$)*(W/2))
Y=HY-60
VECSTR X,Y,A\$,#WHITE,W
W=W+0.1
IF W>40 THEN W=10
BT=BUTTON()
K\$=INKEY\$()
IF K\$==" "        THEN BT=BT OR (1<<4)
IF K\$==CHR\$(&H1B) THEN BT=BT OR (1<<10)
IF BT AND (1<<10) THEN BREAK
IF BT AND (1<<4) THEN BREAK
VSYNC
WEND
RETURN
'---INIT
@GAMEPLAY
'INIT CHECK POINT
FOR N=0 TO 20-1
PX[N]=-1
PY[N]=-1
NEXT
'INIT BLOCK
OBJMAX = 60
DIM RX[OBJMAX]
DIM RY[OBJMAX]
FOR N=0 TO OBJMAX-1
RX[N]=-1
RY[N]=-1
NEXT
'INIT MAP
DIM MAP[12,12]
FOR Y=0 TO 11
FOR X=0 TO 11
MAP[X,Y]=0
NEXT
NEXT
RESTORE @MAPDATA
N=0
FOR Y=0 TO 99
IF A\$=="" THEN BREAK
FOR X=0 TO LEN(A\$)-1
ZX=X*SIZE
ZY=Y*SIZE
M\$=MID\$(A\$,X,1)
IF ASC(M\$)>=&H30 AND ASC(M\$)<=&H39 THEN
K=VAL(M\$)   'CHECK POINT NUMBER
PX[K]=ZX
PY[K]=ZY
ENDIF
IF M\$=="#" THEN
IF N>=OBJMAX THEN PRINT "OBJECT OVER":END
RX[N]=ZX
RY[N]=ZY
MAP[X,Y]=1
N=N+1
ENDIF
NEXT
NEXT
SPDMAX=2.5
'INIT CAR
MYID=4
CPUNUM=0
FOR I=0 TO EMAX-1
EA[I]=0
EX[I]=PX[0]-(I MOD 2)*16-SIZEH
EY[I]=PY[0]+((EMAX/2)-I)*10
EDST[I]=1
ESPD[I]=1
ETYPE[I]=7+(I MOD 5)
CNT[I]=2
RSLT[I]=0
RANK[I]=0
IF I==MYID THEN
NAME\$[I]="YOU"
ANG=EA[I]
AX=EX[I]
AY=EY[I]
ELSE
CPUNUM=CPUNUM+1
NAME\$[I]="CPU"+STR\$(CPUNUM)
ENDIF
NEXT
BCNT=0 'BOOSTER
NUMBER=0
TIM=-3
OVER=0
'--- MAIN
WHILE 1
SWAP VIEWPAGE,DRAWPAGE
GPAGE VIEWPAGE,DRAWPAGE
GFILL 0,0,NW-1,NH-1,#BLACK
GOSUB @OBJECT
IF MSG\$!="" THEN
IF MSGCNT<=0 THEN
BEEP 7,-2000,32
MSGCNT=60
ENDIF
ENDIF
IF MSGCNT>0 THEN
X=HX-(LEN(MSG\$)*15)
Y=HY-60
VECSTR X,Y,MSG\$,#WHITE,30
DEC MSGCNT
IF MSGCNT<=0 THEN MSG\$=""
ENDIF
IF TIM<0.1 THEN 'COUNT DOWN
J=ABS(FLOOR(TIM))
IF J>4 THEN J=4
MSG\$=STR\$(J)
IF J==0 THEN MSG\$="GO!"
ENDIF
FOR I=0 TO EMAX-1
TX = EX[I]
TY = EY[I]
TA = EA[I]
SPD = ESPD[I] 'SPEED
'CHECK POINT SEARCH
DELTAX = PX[EDST[I]]-TX
DELTAY = PY[EDST[I]]-TY
IF I==MYID THEN
GOSUB @MYCAR
ELSE
GOSUB @ENEMYCAR
ENDIF
IF TIM>=0 THEN
TX = TX+COS(RD)*SPD
TY = TY+SIN(RD)*SPD
ENDIF
'HIT BLOCK
FOR D=0 TO 45*7 STEP 45
X=FLOOR(((TX+X1)+SIZEH)/SIZE)
Y=FLOOR(((TY+Y1)+SIZEH)/SIZE)
IF MAP[X,Y]==1 THEN
TX = TX-X1
TY = TY-Y1
SPD=0
IF I==MYID THEN BEEP 13,RND(1000),32
ENDIF
NEXT
'CHECK POINT CLEAR
IF ABS(DELTAX)<SIZEH AND ABS(DELTAY)<SIZEH THEN
IF EDST[I]==0 THEN
DEC CNT[I]
IF CNT[I]<=0 THEN
RSLT[I]=TIM
INC NUMBER
RANK[I]=NUMBER
ENDIF
IF I==MYID THEN
IF CNT[I]<=0 THEN
MSG\$=STR\$(RANK[I])
ELSE
MSG\$=STR\$(CNT[I])+" LAPS LEFT"
ENDIF
ENDIF
ENDIF
INC EDST[I]
IF PX[EDST[I]]<0 THEN EDST[I]=0
ENDIF
'HIT CAR
FOR J=0 TO EMAX-1
IF I==J THEN CONTINUE
IF ABS(TX-EX[J])<CSIZE AND ABS(TY-EY[J])<CSIZE THEN
EX[J]=EX[J]+SGN(EX[J]-TX)
EY[J]=EY[J]+SGN(EY[J]-TY)
IF I==MYID AND (MAINCNT MOD 6)==0 THEN BEEP 11,-RND(1000),32
ENDIF
NEXT
ESPD[I]=SPD
EX[I]=TX
EY[I]=TY
EA[I]=TA
'PRINT CAR
DELTAX = TX-AX
DELTAY = TY-AY
L=SQR((DELTAX*DELTAX)+(DELTAY*DELTAY))
IF L<VR THEN
AT=ATAN(DELTAY,DELTAX)
X=HX+COS(RT)*L
Y=HY+SIN(RT)*L
ENDIF
NEXT
LOCATE 1,2
PRINT "TIME:";FORMAT\$("%6.2F",TIM);" SEC"
TIM=TIM+(1/60)
IF NUMBER>=EMAX THEN
INC OVER
IF OVER>120 THEN BREAK
ENDIF
IF BT AND (1<<10) THEN BREAK
VSYNC
WEND
'--- RESULT
IF BT AND (1<<10) THEN RETURN
CLS
WHILE 1
SWAP VIEWPAGE,DRAWPAGE
GPAGE VIEWPAGE,DRAWPAGE
GFILL 0,0,NW-1,NH-1,#BLACK
FOR I=0 TO EMAX-1
A\$=FORMAT\$("%2D",RANK[I])+":"
A\$=A\$+FORMAT\$("%5S",NAME\$[I])+":"
A\$=A\$+FORMAT\$("%6.2F",RSLT[I])+" SEC"
X=60
Y=16+(RANK[I]*20)
C=#WHITE
IF I==MYID THEN C=RGB(RND(255),0,255)
VECSTR X,Y,A\$,C,16
NEXT
IF BUTTON() THEN BREAK
VSYNC 1
WEND
RETURN
'---
@OBJECT
FOR N=0 TO OBJMAX-1
X=RX[N]
IF X<0 THEN BREAK
Y=RY[N]
DELTAX = X-AX
DELTAY = Y-AY
L=SQR((DELTAX*DELTAX)+(DELTAY*DELTAY))
IF L<VR THEN
AT=ATAN(DELTAY,DELTAX)
X=HX+COS(RT)*L
Y=HY+SIN(RT)*L
VECDRAW2 X,Y,30,#WHITE,SIZE*1.15,-RD
ENDIF
NEXT
X=PX[0]
Y=PY[0]
DELTAX = X-AX
DELTAY = Y-AY
L=SQR((DELTAX*DELTAX)+(DELTAY*DELTAY))
IF L<VR THEN
AT=ATAN(DELTAY,DELTAX)
X=HX+COS(RT)*L
Y=HY+SIN(RT)*L
VECDRAW2 X,Y,ASC("_"),#RED,SIZE*1.15,-RD
ENDIF
RETURN
'---
@MYCAR
AX=TX
AY=TY
ANG=TA
IF RSLT[MYID]!=0 THEN
GOSUB @ENEMYCAR
RETURN
ENDIF
BT=BUTTON()
STICK 0 out LX,LY
K\$=INKEY\$()
IF K\$==CHR\$(28) THEN LX=0.75
IF K\$==CHR\$(29) THEN LX=-0.75
IF K\$==CHR\$(&H1B) THEN BT=BT OR (1<<10)
IF K\$==" " THEN BT = BT OR (1<<4)
TA=TA+LX
IF BT AND (1<<4) THEN 'ACCEL
BCNT=(BCNT+1) MOD 12
IF BCNT==0 THEN
HZ=-3000+floor(SPD*2000)+rnd(200)
VOL= 30
BEEP 1,HZ,VOL
ENDIF
CH=26
VECDRAW2 HX,HY+CSIZE*(BCNT+7)/15,CH,#WHITE,CSIZE,0
SPD=SPD+0.05
IF SPDMAX<SPD THEN SPD=SPDMAX
ELSE
SPD=SPD-0.03
IF SPD<0 THEN SPD=0
ENDIF
'LOCATE 5,27
'PRINT "SPEED:";FORMAT\$("%3D",100*SPD/SPDMAX)
'PRINT AX,AY
RETURN
'---
@ENEMYCAR
L=SQR((DELTAX*DELTAX)+(DELTAY*DELTAY))
A1=DEG(ATAN(DELTAY,DELTAX))-TA
IF A1>180  THEN A1=A1-360
IF A1<-180 THEN A1=A1+360
TA = TA+SGN(A1)
TA = TA+RND(5)-2
IF TA>360  THEN TA=TA-360
IF TA<-360 THEN TA=TA+360
IF L>RND(300) THEN SPD=SPD+0.08
IF RND(2)     THEN SPD=SPD-0.06
IF SPD<0 THEN SPD=0
IF SPD>2.5 THEN SPD=2.5
RETURN
'---
RESTORE @FONT
FOR I=CHMIN TO CHMAX
NEXT
RETURN
'---
DEF VECSTR GX,GY,A\$,COL,SZ
WHILE LEFT\$(A\$,1)!=""
VECDRAW2 GX,GY,ASC(LEFT\$(A\$,1)),COL,SZ-1,0
GX=GX+SZ
A\$=MID\$(A\$,1,LEN(A\$)-1)
WEND
END
'---
DEF VECDRAW2 GX,GY,CH,COL,SZ,OFS
IF CH<CHMIN OR CH>CHMAX THEN CH=ASC(".")
A\$=VEC\$[CH-CHMIN]
SZ=SZ/7
J=0
FOR II=0 TO LEN(A\$)-1
IDX=ASC(MID\$(A\$,II,1))-&H41
IF IDX<0 THEN J=0:CONTINUE
TMPX=COS(AG[IDX]+OFS)*LN[IDX]
TMPY=SIN(AG[IDX]+OFS)*LN[IDX]
TMPX=(TMPX*SZ)+GX
TMPY=(TMPY*SZ)+GY
IF J THEN GLINE TMPX,TMPY,OLDX,OLDY,COL
OLDX=TMPX
OLDY=TMPY
J=J+1
NEXT
END
'---
@MAPDATA
DATA "#########"
DATA "#   0 1 #"
DATA "#8 ###  #"
DATA "# #### 2#"
DATA "#7 #### #"
DATA "# 6 ### #"
DATA "##  ## 3#"
DATA "## 5 4  #"
DATA "#########"
DATA ""
'---
@FONT
DATA ""
DATA "]VJL\c] V\"
DATA "IMb^I"
DATA "O_aUNHOU"
DATA "VOU\V"
DATA "dddj\Vd WIM[ elmf hopi XQSZ"
DATA "VD\ZomXV"
DATA "XRZ`X VR\V Hd jN"
DATA "lXZp\LJVl XQSZ"
DATA "KieK dYjd dP Tj"
DATA "DZomXD _dkqja"
DATA "lpjcEZXC]dl _ahf_"
DATA "moDm"
DATA "OCCEU\VO"
DATA "OUc]O CEomC"
DATA "lmCEop _a VPT\"
DATA "efCEop _a HPT\"
DATA "lmCEhi _a NTPV"
DATA "OXX]fkqhcZUGRAO"
DATA "CEUcom]OC"
DATA "kAGqk"
DATA "kDqk"
DATA "VD\nV WK[gW"
DATA "IMieI QSa_Q"
DATA "]kmUGE] ]_m _G"
DATA "OSokO OCGco SG"
DATA "QDS\an_VQ"
DATA "GZq`kXARG"
DATA "k^_fk APQJA GLSTG qbahq"
DATA "PQXWP ST[ZS HBFNjpldH ei"
DATA "AGqAkGG qk"
DATA "AkqGA IMieI"
DATA ""
DATA "D` gn"
DATA "CJ EL"
DATA "OU c]] Cm oE"
DATA "NIOW[cid Dn"
DATA "Gk ABIHA ijqpi"
DATA "qICK]mn\"
DATA "DEEK"
DATA "EDJfno"
DATA "CDLhnm"
DATA "V\ Dn Ii Me"
DATA "V\ Dn"
DATA "ghn"
DATA "V\"
DATA "gh"
DATA "kG"
DATA "BHdlpjNFB eM"
DATA "JDn mo"
DATA "AFNU[W]kqq"
DATA "AFNU[V [cjpk"
DATA "c]Eo"
DATA "GAV[cjpk"
DATA "GBHdlpjc[V"
DATA "AGk"
DATA "WOHBFNU[W W]dlpjc["
DATA "\WOHBFNjpk"
DATA "JK fg"
DATA "JK fgm"
DATA "GVq"
DATA "OU ]c"
DATA "A\k"
DATA "ng `Y[UNFBH"
DATA "qldHBFNcif^PJLh"
DATA "kDq ei"
DATA "Akpjc[V AFNU["
DATA "GBHdlq"
DATA "kAFNjpk"
DATA "GAkq \V"
DATA "GAk V\"
DATA "GBHdlpj\Y"
DATA "Ak V\ Gq"
DATA "CE Dn mo"
DATA "CE Dgmld"
DATA "Ak GVq"
DATA "Akq"
DATA "kAYGq"
DATA "kAqG"
DATA "BFNjpldHB"
DATA "kAFNU[V"
DATA "BHdlpjNFB qY"
DATA "kAFNU[Vq"
DATA "GBHOW[cjpk"
DATA "AG Dn"
DATA "AnG"
DATA "AkYqG"
DATA "Aq Gk"
DATA "AYG Yn"
DATA "AGkq"
DATA "EDno"
DATA "AYG Yn ^b ei"
DATA "CDnm"
DATA "JDL"
DATA "kq"
DATA "CK"
DATA "pld]W[ HLTp"
DATA "AkoibZV"
DATA "MIOdlp"
DATA "Fpld]W["
DATA "V[TLIOdlp"
DATA "MKQm ]b"
DATA "MIOW[ Miok"
DATA "Hk ]WZbpp"
DATA "KR Yn"
DATA "KR Ygmld"
DATA "Hk T]p"
DATA "Hkn"
DATA "kOIJRn RLMUq"
DATA "Hk OILTp"
DATA "IOdloiTLI"
DATA "kHLT[a]"
DATA "pMIOV^b"
DATA "Hk MJV"
DATA "MIOWZbiok"
DATA "OT Jfnp"
DATA "HdloiM"
DATA "HnN"
DATA "HdlmgK gopjN"
DATA "kM Hp"
DATA "HOWZT Miok"
DATA "pkMH"
DATA "EDRX`no"
DATA "DR `n"
DATA "CDRZ`nm"
DATA "HBCSTN"
DATA "Aq"``````

Last edited:
There is also another 3DS-related BASIC called FUZE basic, the new one version 4 is not free but I think you can download the old one becuase it has problems with new Windows. I'm not sure I ahve not tried it.

There is also another 3DS-related BASIC called FUZE basic
I am confused what this is. I don't have a Windows machine right now, I can't try the Windows version. Their website is not very clear. Is it for educational purposes only? I see they offer some coding camps and I also did come across a FUZE computer that is basically a Raspberry Pi inside a case with a breadboard exposed so you can play with electronics. Is the Nintendo Switch version running on the console and you can connect a keyboard or something?

It's a basic for making 3DS games and they ported it to windows and bc it cant run on modern windows thay have made this older version free until version 4 comes to windows 8it already exists for nintendo 3ds to buy).

The style of the langauge is aking towards Pico-8 and stuff like that, but it has a high resolution and somewhat faste execution speed.
Not as fast as Cerberus-X though, but like that it exist for Pi 3.

Interesting. Their website does not mention 3DS though but Windows, Pi and Switch and it seems to me their primary focus is their workshops people can join to learn coding using this programming language.

Sorry I meant to say Nintendo Switch of course not 3DS, I'm confused, at my age a Nintendo handheled is still just a "Nintendo"

About the workshops, exactly, they are going for what BBC did back in the 80's, aiming at schools. That seem to be thir primary income
like 5 years agoor somthing they also sold a very retro-looking computer, with breadboard ontop I think, You could get it with or without a robotarm.