FUZEBASIC Programmers Reference Guide
FUZEBASIC Programmers Reference Guide
www.fuze.co.uk
or email [email protected]
Introduction
Arithmetic, Bitwise and Logical operators Published in the United Kingdom ©2012 - 2017 FUZE Technologies Ltd. FUZE CODE
STUDIO, FUZE BASIC, FUZE logos, designs, documentation and associated materials are
Numerical representation Copyright FUZE Technologies Ltd. FUZE is a registered trademark [UK00002655290].
Functions, Constants & Procedures No part of this document may be copied, reproduced and or distributed without written
consent from FUZE Technologies Ltd. All rights reserved. The Arduino brand, Arduino
logo and design of their boards are copyright of Arduino LLC. Any other brand names are
Joystick and Gamepad commands the copyright of their respective owners.
Keycodes (scanKeyboard) FUZE BASIC is developed by FUZE Technologies Ltd in the UK by;
Using the BBC micro:bit Jon Silvera - Project manager and author of this guide
Luke Mulcahy - Lead programmer
David Silvera - FUZE Product manager
Using the OWI USB Robot Arm Colin Bodley - Technical consultant & Documentation contributor
Additional information – www.fuze.co.uk
Manual Version: Date: 10th May 2017 FUZE BASIC Version: 3.9.1
2
Contents Introduction
Introduction & Welcome to FUZE BASIC Using FUZE BASIC with Arduino / Genuino, BBC micro:bit
This reference guide aims to provide a comprehensive and detailed and the OWI USB Robot Arm.
explanation of every command in the FUZE BASIC library.
It is an evolving document because FUZE BASIC is constantly being FUZE BASIC will only recognise an Arduino or BBC micro:bit device
updated and improved. To download the latest version please visit once the driver software has been installed.
the resources section on the www.fuze.co.uk website.
For Arduino devices: Please visit the official Arduino website at
https://www.arduino.cc and download / install the latest version.
FUZE BASIC is currently available for Microsoft Windows®,
Raspberry Pi, The FUZE and Linux.
For BBC micro:bit devices: Please visit the official ARM mbed
site at https://developer.mbed.org/handbook/Windows-serial-
Installing FUZE BASIC configuration and download & install the driver.
For details on installing and getting started we highly recommend you
begin with the FUZE BASIC Project Worksheets which can be If you’re using multiple devices then please see the
downloaded for free from the FUZE website. DETECTDEVICE and SETDEVICE statements so you can easily
switch between them.
Conventions used in this guide:
There are many example programs listed in this manual. The following OWI USB Robot Arm (Maplin): No driver is required for Linux
colours are used to determine the different program construct types; and Raspberry Pi based systems but if you are using FUZE BASIC
- COMMANDS - STATEMENTS & FUNCTIONS for Windows then a driver is required. Please see the FUZE BASIC
website for more details.
- SYSTEM & FIXED VARIABLES
- USER DEFINED VARIABLES Community - your input is welcomed
- REM or comments If you spot any errors or think we could explain something better, or
even have alternative suggestions for examples then please submit
them to [email protected]. Please note however that this intended
to be a none technical guide - please keep submissions short, simple
and well documented.
Immediate mode commands are entered into FUZE Immediate mode is the start mode for FUZE BASIC
BASIC’s direct mode. For example try typing in;
PRINT 10 + 20 + 30 and then press enter. and depending which retro styled interface you
The following system commands can be used in have selected will look something like this;
immediate mode are explained in the following
pages.
CD Commodore 64
SAVE
CHAIN SHOWKEYS
CLEAR TROFF Amstrad CPC
CLS TRON
CONT VERSION BBC Model B
DIR
EDIT Sinclair
ESCAPE Please note: ZX Spectrum
EXIT You do not need to learn
HELP immediate mode
INSERT Atari 8 BIT
commands to use BASIC. In
LISTGAMEPADS
fact you may never even Apple ][
LOAD
need to use them. You can
LOOK
NEW simply jump straight to the
RUN editor by pressing F2.
Press the INS key to switch between them. Then
press F2 or type EDIT to switch to the code editor.
4
Contents Immediate mode Commands
CD Example
CD fuzebasic
Purpose
Switch to the folder named fuzebasic. There must be a folder called
Change the current directory
‘fuzebasic’ in the current folder to work.
Syntax
CD ..
CD foldername Go back to the parent folder ( CD ../.. will go back two folders.)
Description
Change the current folder to the one specified. CD /
Go back to root folder.
Associated
LOAD, SAVE, CHAIN, DIR
5
Contents Immediate mode Commands
CHAIN Example
Syntax
CHAIN filename$
Description
Loads in a program from the local non-volatile storage.
As with SAVE, you need to supply the filename without
any quotes. Do not include the .fuze file extension.
Note, if your filename has spaces then you must enter it
within quotation marks. CHAIN "my game" for example.
Associated
LOAD, SAVE, NEW
6
Contents Immediate mode Commands
CLEAR Example
Purpose variable=10
Clear variable memory. PRINT variable
CLEAR
Syntax
PRINT variable
CLEAR
Description
Clears all variables and deletes all arrays. It also removes
any active sprites from the screen. Stopped programs
may not be continued after a CLEAR command.
Associated
NEW
7
Contents Immediate mode Commands
CLS Example
Purpose PAPER=WHITE
Clear the video display screen. INK=BLACK
CLS
Syntax PRINT "Hello World"
CLS
END
Description
Clears the video display screen and places the cursor in
the top left corner. The background is set to the current
background (PAPER) colour.
Associated
PAPER
8
Contents Immediate mode Commands
CONT Example
Purpose CONT
Continue running a program that has been stopped.
Syntax
CONT
Description
Continues program execution after a STOP instruction.
Variables are not cleared.
Associated
STOP
9
Contents Immediate mode Commands
DIR Example
Purpose DIR
List FUZE BASIC program files in the current or specified
directory.
Syntax
DIR [directory]
Description
Lists the program files in your current working directory
or the optional specified directory. These will have the
.fuze file extension.
Associated
LOAD, SAVE
10
Contents Immediate mode Commands
EDIT Example
Purpose EDIT
Edit the program in memory.
Syntax
EDIT
Description
Edits the program in memory using a full screen editor.
11
Contents Immediate mode Commands
Syntax
ESCAPE (key press)
Description
Halts the current program’s execution and returns to
immediate mode. All variables remain intact so it is
possible to examine them for debugging.
Associated
12
Contents Immediate mode Commands
EXIT Example
Purpose EXIT
Exit FUZE BASIC and return to the environment.
Syntax
EXIT
Description
Exit FUZE BASIC and return to the environment you
started it in.
Associated
13
Contents Immediate mode Commands
HELP Example
Purpose HELP
Display help commands in immediate mode
Syntax
HELP
Description
Lists the full immediate mode command set.
Associated
14
Contents Immediate mode Commands
Syntax
INSERT (key press)
Description
Cycles through the various retro styled skins in
immediate mode. BBC Micro anyone?
Associated
15
Contents Immediate mode Commands
LISTGAMEPADS Example
Purpose LISTGAMEPADS
To display any connected joysticks and gamepads.
Syntax
LISTGAMEPADS
Description
This lists, by name, any attached joystick devices
currently connected via USB or wireless USB, if
supported by the OS.
Associated
16
Contents Immediate mode Commands
LOAD Example
Syntax
LOAD filename$
Description
Loads in a program from the local non-volatile storage.
As with SAVE, you need to supply the filename without
any quotes. Do not include the .fuze file extension.
Note, if your filename has spaces then you must enter it
within quotation marks. LOAD "my game" for example.
Associated
SAVE
17
Contents Immediate mode Commands
LOOK Example
Purpose LOOK
Syntax
LOOK
Description
Erm…
Associated
18
Contents Immediate mode Commands
NEW Example
Purpose NEW
Start a new program
Syntax
NEW
Description
Deletes the program in memory. There is no verification
and once it’s gone, it’s gone. Remember to save first!
Associated
CLEAR
19
Contents Immediate mode Commands
RUN Example
Purpose RUN
Runs the program in memory.
Syntax
RUN
Description
Runs the program in memory. Note that using RUN will
clear all variables.
Associated
ESCAPE (key press)
20
Contents Immediate mode Commands
SAVE Example
Syntax
SAVE filename$
Description
Saves your program to the local non-volatile storage.
The filename$ is the name of the file you wish to save
and may not contain spaces. If you have already saved a
file, then you can subsequently execute SAVE without
the filename and it will overwrite the last file saved.
(This is reset when you load a new program or use the
NEW command)
Associated
LOAD
21
Contents Immediate mode Commands
SHOWKEYS Example
Description
It is possible to set the 12 function keys at the top of
the keyboard to user defined values. This command will
show what the current definitions are. By default
function key 2 is defined to enter the EDIT command
and F3 the RUN command but it is possible to
overwrite these.
Associated
keyF1$, keyF2$, keyF3$, keyF4$, keyF5$, keyF6$, keyF7$,
keyF8$, keyF9$, keyF10$, keyF11$, keyF12$
22
Contents Immediate mode Commands
TROFF Example
TROFF
Purpose
Disables TRON
Syntax
TROFF
Description
If TRON is enabled then TROFF switches it off.
Associated
TRON
23
Contents Immediate mode Commands
TRON Example
Purpose TRON
Enables TRON mode for debugging.
Associated
TROFF
24
Contents Immediate mode Commands
VERSION Example
Purpose VERSION
Print the current version of FUZE BASIC.
Syntax
VERSION
Description
Displays the current version of FUZE BASIC along with
relevant program information.
25
Arithmetic, Bitwise and Logical operators Contents
Arithmetic operators
Purpose
Arithmetic operators are used to perform calculations
with numbers and variables.
Syntax
value = 10 * 10
answer = value DIV 10
IF value <= 10 THEN …
Description
^ —––––– Exponent or “raise to the power of”
* —––––– Multiply
/ —––––– Divide
MOD —––––– Modulo
DIV —––––– Integer Divide
+ —––––– Addition
- —––––– Subtraction
< —––––– Less than
<= —––––– Less than or equal to
> —––––– More than
>= —––––– More than equal to
= —––––– Equal to
<> —––––– Not equal to
26
Arithmetic, Bitwise and Logical operators Contents
Bitwise operators
Purpose
Binary operators allow logical operations to be
performed on numbers and variables.
Syntax
value = number | number
value = number & number
value = number XOR number
value = number << bits to shift
value = number >> bits to shift
Description
| Bitwise OR
& Bitwise AND
XOR Bitwise XOR
<< Bitwise shift left
>> Bitwise shift right
27
Arithmetic, Bitwise and Logical operators Contents
Logical operators
Purpose
Logical operators
Syntax
IF value = NOT value2 THEN…
IF value = 1 AND value2 = 2 THEN …
IF value = 1 OR value2 = 2 THEN …
Description
NOT Logical NOT
AND Logical AND
OR Logical OR
28
Numerical representation Contents
Numerical representation
Purpose
Number values are generally entered in decimal but it
can be very useful to represent a value in its binary or
hexadecimal format.
Syntax
129 decimal
0b10000001 binary - prefixed with “0b”
0x81 hexadecimal - prefixed with “0x”
The command..
29
Functions, Constants & Procedures Contents
ABS Example
Returns the absolute value of the supplied argument DEF FN ElapsedYears( Year1, Year2 )
number i.e. If the argument is negative, make it positive. =ABS( Year1-Year2 )
Associated
ABS, SGN
34
Contents Functions, Constants & Procedures
ACOS Example
This is the inverse of the COS function returning the PRINT "In Radians: "; ACOS( 0.5 )
angle for a given cosine. CLOCK
PRINT "In Minutes: "; ACOS( 0.5 )
END
Associated
ACOS, ASIN, ATAN, COS, CLOCK, DEG, PI, PI2, RAD, SIN,
TAN
35
Contents Functions, Constants & Procedures
ADVANCESPRITE Example
CLS
Purpose
Advances a sprite a specified amount sprite = NEWSPRITE( 1 )
LOADSPRITE( "fighter.png", sprite, 0 )
Syntax PLOTSPRITE( sprite, 0, GHEIGHT/2, 0 )
ADVANCESPRITE( sprite, distance ) FOR angle = 0 TO 300 LOOP
Description SETALPHA((100 / 360)*angle)
Moves a sprite forward by the specified distance. The CIRCLE (GETSPRITEX(sprite), GETSPRITEY(sprite), 10, 1)
direction is set by the SETSPRITEANGLE function. This is SETSPRITEANGLE( sprite, angle )
very useful when used with rotating sprites. ADVANCESPRITE( sprite, 5 )
UPDATE
REPEAT
END
Associated
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE,
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY,
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE,
SETSPRITEALPHA, SETSPRITEANGLE, SETSPRITEFLIP,
SETSPRITEORIGIN, SETSPRITESIZE, SPRITECOLLIDE,
SPRITECOLLIDEPP, SPRITEOUT
36
Contents Functions, Constants & Procedures
ANALOGREAD Example
Purpose REM Attach 3.3V (FUZE & micro:bit) or 5V (Arduino) to analog pin 0
TX
RX
1
SDA
AREF
GND
13
IOREF
12
RESET
~11
3.3V
POWER
DIGITAL (PWM~)
~12
5V
GND ~9
8
GND
Vin 7
~6
ANALOG IN
A0
~5
A1
4
Associated A2
A3 ~3
2
A4
TX 1
ON
ANALOGREAD, ANALOGWRITE, DIGITALREAD, A5
RX 0
37
Contents Functions, Constants & Procedures
ANALOGWRITE Example
REM Attach an LED (active leg) to the analog out pin and the other leg to
Purpose
GND. For an Arduino device we use the PWM output pins to send an anlog
Sends a value to an analog output.
signal out.
Syntax
ANALOGWRITE( 0 ) LOOP
FOR a = 0 TO 255 STEP 10 LOOP
Description
ANALOGWRITE (9, a) // (change 9 to 0 for FUZE)
Depending on the system, a value between 0 and 255
WAIT (0.01)
(FUZE 3.3V max) (Arduino 5V max & micro:bit 3.3V max)
REPEAT
can be sent to the pin.
FOR a = 255 TO 0 STEP -10 LOOP
Note: ANALOGWRITE (9, a) // (change 9 to 0 for FUZE)
If you have more than one device attached then please WAIT (0.01)
refer to DETECTDEVICES, DEVICETYPE and SETDEVICE REPEAT
UPDATE SCL
TX
RX
1
SDA
AREF
REPEAT IOREF
GND
13
12
RESET
~11
3.3V
POWER
DIGITAL (PWM~)
~12
5V
GND ~9
8
GND
Vin 7
NOTE: long leg ~6
ANALOG IN
A0
~5
is active and A1
4
Associated goes to the
A2
A3 ~3
2
A4
TX 1
power supply
ON
ANALOGREAD, ANALOGWRITE, DIGITALREAD, A5
RX 0
38
Contents Functions, Constants & Procedures
ASC Example
Description
Returns the ASCII value represented by the first
character of string$ e.g. "A" would return 65. It is the
opposite of the CHR$ function.
Associated
ASC, CHR$, DATE$, DEFCHAR, GET$, LEFT$, LEN, MID$,
NUMFORMAT, PRINT, PRINTAT, RIGHT$, SPACE$, STR$,
TIME$, VAL
39
Contents Functions, Constants & Procedures
ASIN Example
This is the inverse of the SIN function returning the PRINT "In Radians: "; ASIN( 0.5 )
angle for a given sine. CLOCK
PRINT "In Minutes: "; ASIN( 0.5 )
END
Associated
ACOS, ASIN, ATAN, COS, CLOCK, DEG, PI, PI2, RAD, SIN,
TAN
40
Contents Functions, Constants & Procedures
ATAN Example
This is the inverse of the TAN function returning the PRINT "In Radians: "; ATAN( 1 )
angle for a given tangent. CLOCK
PRINT "In Minutes: "; ATAN( 1 )
END
Associated
ACOS, ASIN, ATAN, ATAN2, COS, CLOCK, DEG, PI, PI2,
RAD, SIN, TAN
41
Contents Functions, Constants & Procedures
ATAN2 Example
Purpose CLS
Returns the arctangent between the point specified and LOOP
the origin. PRINTAT (0, 0); "Degrees: "; ATAN2 (MOUSEY, MOUSEX)
REPEAT
Syntax END
angle=ATAN2( y, x )
Associated
ACOS, ASIN, ATAN, ATAN2, COS, CLOCK, DEG, PI, PI2,
RAD, SIN, TAN
42
Contents Functions, Constants & Procedures
BREAK Example
Associated
CONTINUE, LOOP, LOOP REPEAT, FOR REPEAT, REPEAT
UNTIL, UNTIL REPEAT, WHILE REPEAT
43
Contents Functions, Constants & Procedures
CHR$ Example
Associated
ASC, CHR$, DATE$, DEFCHAR, GET$, LEFT$, LEN, MID$,
NUMFORMAT, PRINT, PRINTAT, RIGHT$, SPACE$, STR$,
TIME$, VAL
44
Contents Functions, Constants & Procedures
CIRCLE Example
Purpose CLS
Draw a circle on the screen. PRINT "Draw a filled yellow circle ";
PRINT "In the centre of the screen"
Syntax COLOUR = YELLOW
CIRCLE( centrex, centrey, radius, fill) CIRCLE( GWIDTH/2, GHEIGHT/2, 200, TRUE )
Description UPDATE
Draws a circle at position ( centrex, centrey ) with the END
specified radius in the current foreground COLOUR. The
final parameter fill is either TRUE or FALSE, and specifies
filled (TRUE) or outline (FALSE).
Associated
CIRCLE, COLOUR, ELLIPSE, HLINE, LINE, LINETO, PLOT,
PLOTTEXT, POLYEND, POLYPLOT, POLYSTART,
RGBCOLOUR, RECT, SETALPHA, TRIANGLE, VLINE
45
Contents Functions, Constants & Procedures
CLEARKEYBOARD Example
Associated
CLEARKEYBOARD, GET, GET$, INKEY, INPUT,
SCANKEYBOARD
46
Contents Functions, Constants & Procedures
CLOCK Example
Associated
ACOS, ASIN, ATAN, COS, CLOCK, DEG, PI, PI2, RAD, SIN,
TAN
47
Contents Functions, Constants & Procedures
CLONESPRITE Example
CLS
Purpose
sprite1 = NEWSPRITE ( 1 )
Create a new sprite from an existing one.
LOADSPRITE ("fighter.png", sprite1, 0 )
Syntax sprite2 = CLONESPRITE (sprite1)
CLONESPRITE ( sprite handle ) SETSPRITEANGLE(sprite2,90)
Description LOOP
Copies a sprite and its settings from an existing one PLOTSPRITE ( sprite1, 100, 100, 0 )
(sprite handle) into a new one. PLOTSPRITE ( sprite2, 400, 100, 0 )
REPEAT
Associated
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE,
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY,
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE,
SETSPRITEALPHA, SETSPRITEANGLE, SETSPRITEFLIP,
SETSPRITEORIGIN, SETSPRITESIZE, SPRITECOLLIDE,
SPRITECOLLIDEPP, SPRITEOUT
48
Contents Functions, Constants & Procedures
CLOSE Example
Associated
CLOSE, EOF, FFWD, INPUT#, OPEN, PRINT#, REWIND,
SEEK
49
Contents Functions, Constants & Procedures
Description
Completely clear the screen of text and graphics. Note,
this does not clear sprites from the screen.
Associated
CLS, CLS2, COPYREGION, FREEIMAGE, FULLSCREEN, GETIMAGEH,
GETIMAGEW, GRABREGION, LOADIMAGE, PLOTIMAGE,
ROTATEIMAGE, SAVEREGION, SAVESCREEN, SCALEIMAGE,
SCROLLDOWN, SCROLLLEFT, SCROLLRIGHT, SCROLLUP,
SETIMAGEORIGIN, SETMODE, UPDATE, UPDATEREGION
50
Contents Functions, Constants & Procedures
Purpose y = GHEIGHT / 2
radius = GWIDTH / 10
Clear screen without an update.
FOR x = 0 TO GWIDTH STEP 0.5 LOOP
Syntax CLS
CLS2 COLOUR = PINK
CIRCLE ( x, y, radius, 1 )
Description
Ideally suited to games and graphical programming. UPDATE
CLS2 clears the background or buffer screen and does REPEAT
not issue an update command. This means you can FOR x = GWIDTH TO 0 STEP -0.5 LOOP
wipe the screen buffer, redraw on it and then issue an CLS2
update. This ensures flicker free updates. It is also faster COLOUR = YELLOW
than CLS. CIRCLE ( x, y, radius, 1 )
UPDATE
REPEAT
Associated
CLS, CLS2, COPYREGION, FREEIMAGE, FULLSCREEN, GETIMAGEH,
GETIMAGEW, GRABREGION, LOADIMAGE, PLOTIMAGE,
ROTATEIMAGE, SAVEREGION, SAVESCREEN, SCALEIMAGE,
SCROLLDOWN, SCROLLLEFT, SCROLLRIGHT, SCROLLUP,
SETIMAGEORIGIN, SETMODE, UPDATE, UPDATEREGION
51
Contents Functions, Constants & Procedures
COLOUR Example
FONTSIZE(1)
Purpose
Set the current graphics height = GHEIGHT / 30
plot colour. FOR col = 0 TO 29 LOOP
COLOUR = col
Syntax
RECT(0, col * height, GWIDTH, height, 1)
COLOUR = setcolour
READ NameOfColour$
Description text$ = STR$(col) + " " + NameOfColour$
Set the current graphics PLOTTEXT(text$, GWIDTH / 2, (height * col) + height / 2);
plot colour as follows: REPEAT
UPDATE
END
DATA "Black", "DarkGrey", "Grey", "Silver"
DATA "LightGrey", "White", "Maroon", "Red"
DATA "Purple", "Raspberry", "Pink", "LightPink"
DATA "DarkGreen", "Green", "BrightGreen", "Olive"
DATA "Lime", "LightGreen", "Navy", "Blue", "Teal"
DATA "Cyan", "Aqua", "LightBlue", "Brown"
Associated DATA "LightBrown", "Orange", "Gold", "Yellow"
CIRCLE, COLOUR, ELLIPSE, HLINE, LINE, LINETO, PLOT, DATA "LightYellow"
PLOTTEXT, POLYEND, POLYPLOT, POLYSTART,
RGBCOLOUR, RECT, SETALPHA, TRIANGLE, VLINE
52
Contents Functions, Constants & Procedures
CONTINUE Example
Associated
COPYREGION Example
COS Example
Purpose CLS
Returns the cosine of the given angle. PRINT "Draw ellipse in screen centre"
DEG
Syntax
FOR Angle = 0 TO 360 STEP 0.01 LOOP
cosine=COS( angle )
COLOUR=RND(30)
Description Xpos = 300 * COS( Angle ) + GWIDTH / 2
Returns the cosine of the argument angle. This is the Ypos = 150 * SIN( Angle ) + GHEIGHT / 2
ratio of the side of a right angled triangle, that is LINE (GWIDTH/2, GHEIGHT/2, Xpos, Ypos)
adjacent to the angle, to the hypotenuse (the longest PLOT( Xpos, Ypos )
side). REPEAT
END
Associated
ACOS, ASIN, ATAN, COS, CLOCK, DEG, PI, PI2, RAD, SIN,
TAN
55
Contents Functions, Constants & Procedures
DATA Example
Associated
DATA, READ, RESTORE
56
Contents Functions, Constants & Procedures
Example
DATE$ PRINT "Today is "; FN FormatDate(DATE$)
END
Purpose DEF FN FormatDate()
DayNo = VAL( RIGHT$( DATE$, 2 ))
Return the current date. MonthNo = VAL( MID$( DATE$, 5, 2 ))
Year$ = LEFT$( DATE$, 4 )
Syntax SWITCH ( DayNo MOD 10 )
todaysdate$ = DATE$ CASE 1
DaySuffix$ = "st"
Description ENDCASE
This returns a string with the current date in the format: CASE 2
YYYY-MM-DD. For example: 2015-03-24. DaySuffix$ = "nd"
ENDCASE
CASE 3
DaySuffix$ = "rd"
ENDCASE
DEFAULT
DaySuffix$ = "th"
ENDCASE
ENDSWITCH
FOR I = 1 TO MonthNo LOOP
READ MonthName$
REPEAT
Result$ = STR$( DayNo ) + DaySuffix$ + " "
= Result$ + MonthName$ + " " + Year$
Associated DATA "January","February","March","April"
ASC, CHR$, DATE$, DEFCHAR, GET$, LEFT$, LEN, MID$, DATA "May","June","July","August"
NUMFORMAT, PRINT, PRINTAT, RIGHT$, SPACE$, STR$, DATA "September","October","November"
TIME$, VAL DATA "December"
57
Contents Functions, Constants & Procedures
DEF FN Example
Associated
DEF FN, FN, LOCAL
58
Contents Functions, Constants & Procedures
Purpose CLS
Create a user defined procedure. PROC Hexagon( 200, 200, 100, Red)
UPDATE
Syntax END
DEF PROC name( { parameter } {, parameter} ) DEF PROC Hexagon( x, y, l, c )
{ commands }
PENUP
ENDPROC MOVETO( x-l * COS( 30 ), y + l/2 )
Description COLOUR = c
Allows you to create your own routines that can be PENDOWN
called by their label. Once you have written a procedure FOR I = 1 TO 6 LOOP
to do a particular task you can copy it into other RIGHT( 60 )
programs that require it. Procedures are usually defined MOVE( l )
after the END of the program.
REPEAT
ENDPROC
Associated
DEF PROC, LOCAL, PROC, ENDPROC
59
Contents Functions, Constants & Procedures
DEFCHAR Example
Associated
ASC, CHR$, DATE$, DEFCHAR, GET$, LEFT$, LEN, MID$,
NUMFORMAT, PRINT, PRINTAT, RIGHT$, SPACE$, STR$,
TIME$, VAL
60
Contents Functions, Constants & Procedures
DEG Example
Purpose CLS
Set angle units to degrees. PRINT "Draw ellipse in screen centre"
DEG
Syntax
FOR Angle = 0 TO 360 STEP 0.01 LOOP
DEG
COLOUR=RND(30)
Description Xpos = 300 * COS( Angle ) + GWIDTH / 2
Switches the internal angle system to degree mode. Ypos = 150 * SIN( Angle ) + GHEIGHT / 2
There are 360 degrees in a full circle. LINE (GWIDTH/2, GHEIGHT/2, Xpos, Ypos)
PLOT( Xpos, Ypos )
REPEAT
END
Associated
ACOS, ASIN, ATAN, COS, CLOCK, DEG, PI, PI2, RAD, SIN,
TAN
61
Functions, Constants & Procedures
DETECTDEVICES Example
Purpose devices=DETECTDEVICES
Check for BBC micro:bit and Arduino / compatible CLS
devices. IF devices = FALSE THEN
PRINT "No devices found"
Syntax
END
PRINT DETECTDEVICES
ELSE
Description PRINT devices; " devices found"
Returns value corresponding to the number of PRINT
compatible devices connected. FOR ID = 0 TO devices LOOP
IF DEVICETYPE(ID) = 1 THEN
Note:
PRINT "BBC micro:bit :ID="; ID
If you have more than one device attached then please
refer to DETECTDEVICES, DEVICETYPE and SETDEVICE ENDIF
IF DEVICETYPE(ID) = 2 THEN
PRINT "Arduino or compatible device :ID="; ID
ENDIF
REPEAT
END
Associated
DETECTDEVICES, DEVICETYPE, SETDEVICE
62
Functions, Constants & Procedures
DEVICETYPE Example
Purpose devices=DETECTDEVICES
Checks which devices are connected (Arduino / CLS
compatible or BBC micro:bit) IF devices = FALSE THEN
PRINT "No devices found"
Syntax
END
PRINT DEVICETYPE( ID )
ELSE
Description PRINT devices; " devices found"
Returns a value corresponding to the device type: PRINT
FOR ID = 0 TO devices LOOP
1 = BBC micro:bit IF DEVICETYPE(ID) = 1 THEN
2 = Arduino or compatible device
PRINT "BBC micro:bit :ID="; ID
Note: ENDIF
If you have more than one device attached then please IF DEVICETYPE(ID) = 2 THEN
refer to DETECTDEVICES, DEVICETYPE and SETDEVICE PRINT "Arduino or compatible device :ID="; ID
ENDIF
REPEAT
END
Associated
DETECTDEVICES, DEVICETYPE, SETDEVICE
63
Contents Functions, Constants & Procedures
DIGITALREAD Example
TX
RX
1
Note: SDA
10
AREF
1
2
3
4
5
6
7
8
9
If you have more than one device attached then please GND
F G H I J
13
IOREF
12
refer to DETECTDEVICES, DEVICETYPE and SETDEVICE RESET
3.3V
~11
POWER
OrangePip
DIGITAL (PWM~)
~12
5V
GND ~9
8
GND
Vin 7
A B C D E
~6
ANALOG IN
A0
~5
A1
4
A2
A3 ~3
Associated 2
1
2
3
4
5
6
7
8
9
10
A4
TX 1
ON
A5
RX 0
ANALOGREAD, ANALOGWRITE, DIGITALREAD,
DIGITALWRITE, PINMODE, PWMWRITE, SOFTPWMWRITE FUZE IO board Arduino or compatible IO board
64
Contents Functions, Constants & Procedures
DIGITALWRITE Example
Description DIGITALWRITE( 2, 1 )
This procedure sets a digital pin to the supplied value - WAIT( 1 )
0 for off or 1 for on. As with DIGITALREAD, you may REM Set output Low ( off )
need to set the pin mode (to output) beforehand. DIGITALWRITE( 2, 0 )
WAIT( 1 )
Note:
REPEAT
If you have more than one device attached then please
END
refer to DETECTDEVICES, DEVICETYPE and SETDEVICE SCL
TX
RX
1
SDA
10
AREF
1
2
3
4
5
6
7
8
9
GND
F G H I J
13
IOREF
12
RESET
~11
3.3V
POWER
OrangePip
DIGITAL (PWM~)
~12
5V
GND ~9
8
GND
Vin 7
A B C D E
~6
ANALOG IN
A0
~5
A1
4
Associated A2
A3 ~3
2
1
2
3
4
5
6
7
8
9
10
A4
ANALOGREAD, ANALOGWRITE, DIGITALREAD, TX 1
ON
A5
RX 0
65
Contents Functions, Constants & Procedures
DIM Example
66
Contents Functions, Constants & Procedures
ELLIPSE Example
CLS
Purpose
REM Draw a filled red ellipse at
Draw an ellipse on the screen.
REM location 200, 200
Syntax COLOUR = red
ELLIPSE( xpos, ypos, xradius, yradius, fill ) ELLIPSE( 200, 200, 100, 50, TRUE )
Description UPDATE
Draws an ellipse centred at position ( xpos, ypos ) with END
the specified xradius and yradius in the current
foreground COLOUR. The final parameter fill is either
TRUE or FALSE, and specifies filled (TRUE) or outline
(FALSE).
Associated
CIRCLE, COLOUR, ELLIPSE, HLINE, LINE, LINETO, PLOT,
PLOTTEXT, POLYEND, POLYPLOT, POLYSTART,
RGBCOLOUR, RECT, SETALPHA, TRIANGLE, VLINE
67
Contents Functions, Constants & Procedures
ELSE Example
Purpose Number = 13
Execute statement(s) when a tested condition is False. IF Number MOD 2 = 0 THEN
PRINT "Number is Even"
Syntax ELSE
IF condition THEN PRINT "Number is Odd"
{ statements } ENDIF
ELSE END
{ statements }
ENDIF
Associated
CASE, DEFAULT, ELSE, ENDIF, ENDCASE, ENDSWITCH, IF
THEN, SWITCH
68
Contents Functions, Constants & Procedures
END Example
Syntax
END
Description
Program execution is ended. Programs must terminate
with the END or STOP commands or an error will occur.
Associated
STOP, CONTINUE, BREAK
69
Contents Functions, Constants & Procedures
ENDIF Example
Purpose DayOfWeek = 5
Terminate a multiline conditional statement. IF DayOfWeek < 6 THEN
PRINT "It is a Weekday"
Syntax PRINT "Go to Work!"
IF condition THEN ENDIF
{ statements }
END
ENDIF
Description
We can extend the IF statement over multiple lines, if
required. The way you do this is by making sure there is
nothing after the THEN statement and ending it all with
the ENDIF statement.
Associated
CASE, DEFAULT, ELSE, ENDIF, ENDCASE, ENDSWITCH, IF
THEN, SWITCH
70
Contents Functions, Constants & Procedures
ENDPROC Example
Purpose CLS
Defines the end of a PROCedure PROC hello
END
Syntax DEF PROC hello
ENDPROC PRINTAT ( 10,10 ); "Hello"
Description ENDPROC
End a PROCedure and return to the next command after
the procedure was called.
Associated
DEF PROC, LOCAL, PROC, ENDPROC
71
Contents Functions, Constants & Procedures
EOF Example
Associated
CLOSE, EOF, FFWD, INPUT#, OPEN, PRINT#, REWIND,
SEEK
72
Contents Functions, Constants & Procedures
EXP Example
Associated
LOG
73
Contents Functions, Constants & Procedures
FADE Example
Purpose
Fades the screen display
Syntax
FADE ( percent )
Description
Associated
FADE
74
Contents Functions, Constants & Procedures
FALSE Example
Associated
TRUE
75
Contents Functions, Constants & Procedures
FFWD Example
Associated
CLOSE, EOF, FFWD, INPUT#, OPEN, PRINT#, REWIND,
SEEK
76
Contents Functions, Constants & Procedures
FN Example
Associated
DEF FN, FN, LOCAL
77
Contents Functions, Constants & Procedures
FONTSIZE Example
Purpose CLS
FOR size = 1 TO 7 LOOP
Scale the text font.
INK = RND(30)
Syntax FONTSIZE( size )
FONTSIZE( scale ) PRINT "Hello World"
Description REPEAT
Change the size of the text font. Maximum 20. END
Associated
HTAB, HVTAB, INK, FONTSIZE, NUMFORMAT, PAPER,
PAPEROFF, PAPERON, PLOTTEXT, PRINTAT, PRINT,
TWIDTH, THEIGHT, VTAB
78
Contents Functions, Constants & Procedures
Associated
BREAK, CONTINUE, LOOP, LOOP REPEAT, FOR REPEAT,
REPEAT UNTIL, UNTIL REPEAT, WHILE REPEAT
79
Contents Functions, Constants & Procedures
FREEIMAGE Example
Purpose CLS
handle = LOADIMAGE( "ball.png" )
Release an image from memory
PLOTIMAGE( handle, 0, 0 )
Syntax UPDATE
FREEIMAGE( handle ) FREEIMAGE( handle )
Description handle = LOADIMAGE( "fighter.png" )
Frees up the memory space taken up by a stored image PLOTIMAGE( handle, 100, 100 )
UPDATE
END
Associated
CLS, CLS2, COPYREGION, FREEIMAGE, FULLSCREEN, GETIMAGEH,
GETIMAGEW, GRABREGION, LOADIMAGE, PLOTIMAGE,
ROTATEIMAGE, SAVEREGION, SAVESCREEN, SCALEIMAGE,
SCROLLDOWN, SCROLLLEFT, SCROLLRIGHT, SCROLLUP,
SETIMAGEORIGIN, SETMODE, UPDATE, UPDATEREGION
80
Contents Functions, Constants & Procedures
FULLSCREEN Example
Associated
FULLSCREEN, GHEIGHT, GWIDTH, ORIGIN, SETMODE
81
Contents Functions, Constants & Procedures
GET Example
Description
This pauses program execution and waits for you to
type a single character on the keyboard, then returns
the value of the key pressed as a numeric variable
(ASCII).
Associated
CLEARKEYBOARD, GET, GET$, INKEY, INPUT,
SCANKEYBOARD
82
Contents Functions, Constants & Procedures
GET$ Example
Description
This pauses program execution and waits for you to
type a single character on the keyboard, then returns
the key as a string variable.
Associated
ASC, CHR$, DATE$, DEFCHAR, GET$, LEFT$, LEN, MID$,
NUMFORMAT, PRINT, PRINTAT, RIGHT$, SPACE$, STR$,
TIME$, VAL
83
Contents Functions, Constants & Procedures
GETDISTANCE Example
Purpose UPDATEMODE = 0
Find the distance between two points. LOOP
CLS2
Syntax
x = MOUSEX
value = GETDISTANCE( x1, y1, x2, y2 )
y = MOUSEY
Description xx = GWIDTH / 2
Returns the distance between two specified screen yy = GHEIGHT / 2
locations. COLOUR = GREY
CIRCLE (xx, yy, 50, 1)
COLOUR = WHITE
LINE (xx, yy, x, y)
COLOUR = RED
CIRCLE (x, y, 50, 1)
dist = GETDISTANCE (x, y, xx, yy)
PRINTAT (0, 0); "Distance="; dist
UPDATE
REPEAT
Associated
GETDISTANCE, GETSPRITEDISTANCE
84
Contents Functions, Constants & Procedures
GETSPRITEDISTANCE Example
Purpose UPDATEMODE = 0
Find the distance between two sprites points. sp1=NEWSPRITE( 1 )
LOADSPRITE("gem0.png", sp1, 0)
Syntax SETSPRITEORIGIN(sp1,GETSPRITEW(sp1)/2,GETSPRITEH(sp1)/2)
value = GETSPRITEDISTANCE( sprite1, sprite2 ) sp2=NEWSPRITE(1)
Description LOADSPRITE("gem4.png", sp2, 0)
Returns the distance between two specified sprite SETSPRITEORIGIN(sp2,GETSPRITEW(sp2)/2,GETSPRITEH(sp2)/2)
positions. LOOP
CLS2
x = MOUSEX
y = MOUSEY
xx = GWIDTH / 2
yy = GHEIGHT / 2
PLOTSPRITE (sp1, xx, yy, 0)
COLOUR = WHITE
LINE ( xx, yy, x, y)
PLOTSPRITE (sp2, x, y, 0)
dist = INT(GETSPRITEDISTANCE (x, y, xx, yy))
Associated
PRINTAT (0, 0); "Distance="; dist
GETDISTANCE, GETSPRITEDISTANCE
UPDATE
REPEAT
85
Contents Functions, Constants & Procedures
Associated
CLS, CLS2, COPYREGION, FREEIMAGE, FULLSCREEN, GETIMAGEH,
GETIMAGEW, GRABREGION, LOADIMAGE, PLOTIMAGE,
ROTATEIMAGE, SAVEREGION, SAVESCREEN, SCALEIMAGE,
SCROLLDOWN, SCROLLLEFT, SCROLLRIGHT, SCROLLUP,
SETIMAGEORIGIN, SETMODE, UPDATE, UPDATEREGION
86
Contents Functions, Constants & Procedures
GETMOUSE Example
Purpose CLS
Read values from an attached mouse LOOP
GETMOUSE (x, y, b)
Syntax
CIRCLE (x, y, 30, 1)
GETMOUSE( xpos, ypos, buttons )
REM LOOP colour if left button pressed
0 - no buttons pressed
1 - left button pressed
2 - middle button pressed
3 - left & middle buttons pressed
4 - right button pressed
5 - left & right buttons pressed
6 - right & middle button pressed
7 - left, middle & right buttons pressed
Associated
MOUSEOFF, MOUSEON, MOUSEX, MOUSEY, MOUSEBUTTON,
GETMOUSE, SETMOUSE, LEFTCLICK, MIDDLECLICK ,
RIGHTCLICK, WHEELUP, WHEELDOWN, LOCKMOUSE
87
Contents Functions, Constants & Procedures
GETPIXEL Example
Purpose CLS
Return the colour of the specified pixel. COLOUR = RED
Xpos = GWIDTH / 2
Syntax Ypos = GHEIGHT / 2
colour = GETPIXEL( xpos, ypos ) PLOT( Xpos, Ypos )
Description PRINT GETPIXEL( Xpos, Ypos )
This returns the internal colour code ( 0 - 15 ) of the END
pixel at the specified point ( xpos, ypos ). This is for the
"named" colours - e.g. Red, Green etc. It returns -1 if the
pixel colour is not a standard colour - in which case, you
need to use GETPIXELRGB.
Associated
GETPIXELRGB
88
Contents Functions, Constants & Procedures
GETPIXELRGB Example
Purpose CLS
Return the RGB colour of the specified pixel. RGBCOLOUR( 49, 101, 206 )
Xpos = GWIDTH / 2
Syntax Ypos = GHEIGHT / 2
RGBcolour = GETPIXELRGB( xpos, ypos ) CIRCLE( Xpos, Ypos, 50, TRUE )
Description pixel = GETPIXELRGB( Xpos, Ypos )
This returns the RGB colour of the pixel at the specified PRINT "RGB = "; pixel
point ( xpos,ypos ). This will return a 24-bit value. PRINT "Red = "; ( pixel >> 16 ) & 0xFF
PRINT "Green = "; ( pixel >> 8 ) & 0xFF
PRINT "Blue = "; ( pixel >> 0 ) & 0xFF
END
Associated
GETPIXEL
89
Contents Functions, Constants & Procedures
GETSPRITEANGLE Example
sprite = NEWSPRITE ( 1 )
Purpose
Returns a sprite’s current angle LOADSPRITE ( "fighter.png", sprite, 0 )
angle = 0
Syntax PLOTSPRITE ( sprite, GWIDTH / 2, GHEIGHT / 2, 0 )
GETSPRITEANGLE( spriteIndex ) LOOP
Description CLS2
Returns the angle of the sprite with the specified SETSPRITEANGLE ( sprite, angle )
spriteIndex. angle = angle + 1
IF angle > 359 THEN angle = 0
PRINTAT( 0,0 ); GETSPRITEANGLE( sprite )
UPDATE
REPEAT
Associated
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE,
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY,
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE,
SETSPRITEALPHA, SETSPRITEANGLE, SETSPRITEFLIP,
SETSPRITEORIGIN, SETSPRITESIZE, SPRITECOLLIDE,
SPRITECOLLIDEPP, SPRITEOUT
90
Contents Functions, Constants & Procedures
Associated
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE,
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY,
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE,
SETSPRITEALPHA, SETSPRITEANGLE, SETSPRITEFLIP,
SETSPRITEORIGIN, SETSPRITESIZE, SPRITECOLLIDE,
SPRITECOLLIDEPP, SPRITEOUT
91
Contents Functions, Constants & Procedures
Example
GETSPRITEPIXELRGBA UPDATEMODE = 0
earth = NEWSPRITE (1)
Purpose LOADSPRITE ("planetEarth.png", earth, 0)
LOOP
Get a single pixel colour value from a specified sprite.
CLS2
Syntax PLOTSPRITE (earth, 0, 0, 0)
IF LEFTCLICK THEN SPRITECENTRE (earth)
value = GETSPRITEPIXELRGBA( spriteID, subSpriteID, x, y)
IF RIGHTCLICK THEN SETSPRITEORIGIN (earth, 0, 0)
px = GETSPRITEPIXELRGBA (earth, 0, MOUSEX, MOUSEY)
alpha = (px >> 24) & 0xFF
Description
rp = (px >> 16) & 0xFF
Returns a 32BIT Red, Green, Blue & Alpha value from gp = (px >> 8) & 0xFF
the specified x, y position, relative to the sprite’s lower bp = (px >> 0) & 0xFF
left coordinate. PRINTAT (TWIDTH - 20, 0); "RGBA = "; px
PRINTAT (TWIDTH - 20, 1); "Red = "; rp
PRINTAT (TWIDTH - 20, 2); "Green = "; gp
PRINTAT (TWIDTH - 20, 3); "Blue = "; bp
PRINTAT (TWIDTH - 20, 4); "Alpha = "; alpha
RGBCOLOUR (rp, 0, 0)
RECT (GWIDTH - 200, 0, 50, rp, 1)
RGBCOLOUR (0, gp, 0)
Associated RECT (GWIDTH - 150, 0, 50, gp, 1)
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE, RGBCOLOUR (0, 0, bp)
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY, RECT (GWIDTH - 100, 0, 50, bp, 1)
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE, RGBCOLOUR (rp, gp, bp)
SETSPRITEALPHA, SETSPRITEANGLE, SETSPRITEFLIP, RECT (GWIDTH - 50, 0, 50, 255, 1)
SETSPRITEORIGIN, SETSPRITESIZE, SPRITECOLLIDE, UPDATE
SPRITECOLLIDEPP, SPRITEOUT REPEAT
92
Contents Functions, Constants & Procedures
Purpose UPDATEMODE = 0
Get the X and Y position of a sprite. sprite = NEWSPRITE ( 1 )
LOADSPRITE ( "fighter.png", sprite, 0 )
Syntax
LOOP
value1 = GETSPRITEX( spriteIndex )
CLS2
value2 = GETSPRITEY( spriteIndex )
PLOTSPRITE ( sprite, GWIDTH / 2, GHEIGHT / 2, 0 )
PRINT GETSPRITEX ( sprite )
Description PRINT GETSPRITEY ( sprite )
Returns the X and or Y position in pixels of the sprite UPDATE
with the specified spriteIndex. REPEAT
Associated
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE,
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY,
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE,
SETSPRITEALPHA, SETSPRITEANGLE, SETSPRITEFLIP,
SETSPRITEORIGIN, SETSPRITESIZE, SPRITECOLLIDE,
SPRITECOLLIDEPP, SPRITEOUT
93
Contents Functions, Constants & Procedures
Associated
FULLSCREEN, GHEIGHT, GWIDTH, ORIGIN, SETMODE
94
Contents Functions, Constants & Procedures
GRABREGION Example
Purpose image=LOADIMAGE("img.png")
Grab a region of the screen to a temporary buffer SETMODE(GETIMAGEW(image), GETIMAGEH(image))
PLOTIMAGE(image, 0, 0)
Syntax
UPDATE
handle = GRABREGION( x, y, width, height )
box = GRABREGION( 0, 0, 200, 200 )
Description LOOP
Grab a region of the screen with x and y as the location PLOTIMAGE( box, RND(GWIDTH), RND(GHEIGHT))
and with width and height in pixels. The region can be UPDATE
recalled by its handle and pasted using PLOTIMAGE. WAIT(0.1)
REPEAT
END
Associated
CLS, CLS2, COPYREGION, FREEIMAGE, FULLSCREEN, GETIMAGEH,
GETIMAGEW, GRABREGION, LOADIMAGE, PLOTIMAGE,
ROTATEIMAGE, SAVEREGION, SAVESCREEN, SCALEIMAGE,
SCROLLDOWN, SCROLLLEFT, SCROLLRIGHT, SCROLLUP,
SETIMAGEORIGIN, SETMODE, UPDATE, UPDATEREGION
95
Contents Functions, Constants & Procedures
HIDESPRITE Example
Purpose CLS
Remove a sprite from the screen. fuzelogo$ = "logo.png"
sprite1 = NEWSPRITE ( 1 )
Syntax
sprite2 = NEWSPRITE ( 1 )
HIDESPRITE( spriteindex )
LOADSPRITE ( fuzelogo$, sprite1, 0 )
Description LOADSPRITE ( fuzelogo$, sprite2,0 )
This removes the sprite at the specified spriteindex from PLOTSPRITE ( sprite1, 100, 100, 0 )
the screen. You do not have to erase a sprite from the PLOTSPRITE ( sprite2, 200, 200, 0 )
screen when you move it, just call PLOTSPRITE with the UPDATE
new coordinates. WAIT( 2 )
REM Remove a sprite from the screen
HIDESPRITE ( sprite2 )
UPDATE
END
Associated
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE,
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY,
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE,
SETSPRITEALPHA, SETSPRITEANGLE, SETSPRITEFLIP,
SETSPRITEORIGIN, SETSPRITESIZE, SPRITECOLLIDE,
SPRITECOLLIDEPP, SPRITEOUT
96
Contents Functions, Constants & Procedures
HLINE Example
Purpose CLS
Draw a horizontal line. COLOUR = RED
FOR ypos = 0 TO GHEIGHT STEP 100 LOOP
Syntax HLINE( 0, GWIDTH, ypos )
HLINE( xpos1, xpos2, ypos ) REPEAT
Description UPDATE
Draws a horizontal line on row y, from column xpos1 to END
column xpos2.
Associated
CIRCLE, COLOUR, ELLIPSE, HLINE, LINE, LINETO, PLOT,
PLOTTEXT, POLYEND, POLYPLOT, POLYSTART,
RGBCOLOUR, RECT, SETALPHA, TRIANGLE, VLINE
97
Contents Functions, Constants & Procedures
Purpose CLS
Set/Read the current text cursor horizontal and vertical FOR xpos = 0 TO TWIDTH STEP 2 LOOP
positions. HTAB = xpos
PRINT HTAB
Syntax
REPEAT
HTAB = value1 END
value1 = HTAB
VTAB = value2 Example2
value2 = VTAB
CLS
FOR ypos = 0 TO THEIGHT LOOP
Description
VTAB = ypos
Set/Read the current text cursor horizontal and vertical
positions. PRINT VTAB
REPEAT
END
Associated
HTAB, HVTAB, INK, FONTSIZE, NUMFORMAT, PAPER,
PAPEROFF, PAPERON, PLOTTEXT, PRINTAT, PRINT,
TWIDTH, THEIGHT, VTAB
98
Contents Functions, Constants & Procedures
HVTAB Example
Purpose CLS
Move the current text cursor to the specified position. FONTSIZE(5)
INK = PINK
Syntax
HVTAB( TWIDTH / 2 - LEN("CENTRE")/2, THEIGHT / 2 )
HVTAB( xpos, ypos )
PRINT "CENTRE"
Description HVTAB( 0, 0 )
The cursor is moved to the supplied column xpos and END
line ypos. Note that (0,0) is top-left of the text screen.
Associated
HTAB, HVTAB, INK, FONTSIZE, NUMFORMAT, PAPER,
PAPEROFF, PAPERON, PLOTTEXT, PRINTAT, PRINT,
TWIDTH, THEIGHT, VTAB
99
Contents Functions, Constants & Procedures
IF THEN Example
Associated
CASE, DEFAULT, ELSE, ENDIF, ENDCASE, ENDSWITCH, IF
THEN, SWITCH
100
Contents Functions, Constants & Procedures
INK Example
Purpose CLS
Set/Read the current text foreground colour. string$ = "This is multicoloured text"
FOR I = 1 TO LEN( string$ ) LOOP
Syntax INK = I MOD 30 + 1
foregroundcolour = INK
PRINT MID$( string$, I - 1 , 1 );
INK = foregroundcolour
REPEAT
Description INK = WHITE
Set/Read the current text foreground (ink) colour. PRINT
END
Associated
HTAB, HVTAB, INK, FONTSIZE, NUMFORMAT, PAPER,
PAPEROFF, PAPERON, PLOTTEXT, PRINTAT, PRINT,
TWIDTH, THEIGHT, VTAB
101
Contents Functions, Constants & Procedures
INKEY Example
REM Show the ASCII code for the last key pressed
Purpose
Get a single character code from the keyboard without LastKey = -1
REM Press Esc to Quit
pausing.
LOOP
Syntax Key=INKEY
asciicode = INKEY IF Key<> - 1 AND Key <> LastKey THEN
Description PRINT "Key Pressed: "; Key
This is similar to GET except that program execution is LastKey = Key
not paused; If no key is pressed, then -1 is returned. The ENDIF
following constants are predefined to test for special REPEAT
keys: KeyUp, KeyDown, KeyLeft, KeyRight, KeyIns,
KeyHome, KeyDel, KeyEnd, KeyPgUp, KeyPgDn, KeyF1,
KeyF2, KeyF3, KeyF4, KeyF5, KeyF6, KeyF7, KeyF8, KeyF9,
KeyF10, KeyF11, KeyF12.
Associated
CLEARKEYBOARD, GET, GET$, INKEY, INPUT,
SCANKEYBOARD
102
Contents Functions, Constants & Procedures
INPUT Example
Description
When FUZE BASIC encounters the INPUT statement,
program execution stops, a question mark(?) is printed
and it waits for you to type something. It then assigns
what you typed to the variable. If you typed in a string
when it was expecting a number, then it will assign zero
to the number. To stop it printing the question mark,
you can optionally give it a string to print.
Associated
CLEARKEYBOARD, GET, GET$, INKEY, INPUT,
SCANKEYBOARD
103
Contents Functions, Constants & Procedures
INPUT# Example
Associated
CLOSE, EOF, FFWD, INPUT#, OPEN, PRINT#, REWIND,
SEEK
104
Contents Functions, Constants & Procedures
INT Example
Description
Returns the integer part of the specified number.
105
Contents Functions, Constants & Procedures
LEFT Example
Associated
LEFT, MOVE, MOVETO, PENDOWN, PENUP, RIGHT,
TANGLE
106
Contents Functions, Constants & Procedures
LEFT$ Example
Description
Returns a sub-string of string$ with number characters
from the left (start) of the string. If number is greater
than or equal to the length of string$ then the whole
string is returned.
Associated
ASC, CHR$, DATE$, DEFCHAR, GET$, LEFT$, LEN, MID$,
NUMFORMAT, PRINT, PRINTAT, RIGHT$, SPACE$, STR$,
TIME$, VAL
107
Contents Functions, Constants & Procedures
LEFTCLICK Example
Purpose UPDATEMODE = 0
Returns TRUE if left mouse button is clicked FONTSIZE (4)
LOOP
Syntax
CLS2
value = LEFTCLICK
INK = LIGHTBLUE
Description PRINTAT (0, 0); "Mouse status"
Returns a value of 0 or 1 (TRUE or FALSE) depending on INK = RASPBERRY
whether it is press or not. PRINTAT (0, 2); "Left button="; LEFTCLICK
PRINTAT (0, 3); "Middle button="; MIDDLECLICK
PRINTAT (0, 4); "Right button="; RIGHTCLICK
PRINTAT (0, 5); "Wheel up="; WHEELUP
PRINTAT (0, 6); "Wheel down="; WHEELDOWN
UPDATE
REPEAT
Associated
MOUSEOFF, MOUSEON, MOUSEX, MOUSEY, MOUSEBUTTON,
GETMOUSE, SETMOUSE, LEFTCLICK, MIDDLECLICK ,
RIGHTCLICK, WHEELUP, WHEELDOWN, LOCKMOUSE
108
Contents Functions, Constants & Procedures
LEN Example
Associated
ASC, CHR$, DATE$, DEFCHAR, GET$, LEFT$, LEN, MID$,
NUMFORMAT, PRINT, PRINTAT, RIGHT$, SPACE$, STR$,
TIME$, VAL
109
Contents Functions, Constants & Procedures
LERP Example
UPDATEMODE=0
Purpose
Return an interpolated value between two values. MOUSEON
PAPER=DARKGREY
Syntax position=0
LERP( value1, value2, position) LOOP
CLS2
Description COLOUR=ORANGE
Returns a value between two numbers determined by CIRCLE(GWIDTH/2,GHEIGHT/2,10,1)
the position (between 0 and 1). COLOUR=LIGHTBLUE
CIRCLE(MOUSEX,MOUSEY,20,1)
Example; COLOUR=LIGHTGREEN
PRINT LERP (0, 100, 0.5) //results in 50 cx = LERP(GWIDTH/2,MOUSEX,position)
PRINT LERP (8, 16, 0.5) //results in 12 cy = LERP(GHEIGHT/2,MOUSEY,position)
PRINT LERP (0, GWIDTH, 0.1) // one tenth of the display width
CIRCLE( cx, cy, 20, 1)
PRINT LERP (0, 255, 0.5) // If used as a gradient then this is 50% along
position=position+0.001
IF position>1 THEN position=0
UPDATE
Associated REPEAT
SPLINE END
110
Contents Functions, Constants & Procedures
LINE Example
Purpose CLS
Draw a line between two points LOOP
COLOUR = RND(30)
Syntax startX=RND(GWIDTH)
LINE( xpos1, ypos1, xpos2, ypos2 ) startY=RND(GHEIGHT)
endX=RND(GWIDTH)
Description
endY=RND(GHEIGHT)
Draw a line between point ( xpos1, ypos1 ) and point
LINE( startX, startY, endX, endY)
(xpos2, ypos2) in the current COLOUR.
UPDATE
REPEAT
END
Associated
CIRCLE, COLOUR, ELLIPSE, HLINE, LINE, LINETO, PLOT,
PLOTTEXT, POLYEND, POLYPLOT, POLYSTART,
RGBCOLOUR, RECT, SETALPHA, TRIANGLE, VLINE
111
Contents Functions, Constants & Procedures
LINETO Example
CLS
Purpose
Draw a line from the last point plotted. COLOUR = YELLOW
PLOT (0, 0)
Syntax LOOP
LINETO( xpos1, ypos1 ) LINETO(RND(GWIDTH), RND(GHEIGHT))
Description UPDATE
Draws a line from the last point plotted (by the PLOT or WAIT(0.1)
LINE procedures) to point ( xpos1, ypos1 ). REPEAT
END
Associated
CIRCLE, COLOUR, ELLIPSE, HLINE, LINE, LINETO, PLOT,
PLOTTEXT, POLYEND, POLYPLOT, POLYSTART,
RGBCOLOUR, RECT, SETALPHA, TRIANGLE, VLINE
112
Contents Functions, Constants & Procedures
LISTDIR Example
CLS
Purpose
Saves a TXT file containing the current folder’s file LISTDIR
contents. files=OPEN( "files.list" )
WHILE NOT EOF( files ) LOOP
Syntax
INPUT# files, text$
LISTDIR
PRINT text$
Description REPEAT
Saves a TXT file called “files.list” into the current working CLOSE ( files )
directory containing file structure within. END
Associated
113
Contents Functions, Constants & Procedures
LOADFONT Example
FONTSIZE (6)
Purpose
Draw a line from the last point plotted. UPDATEMODE = 0
CLS
Syntax LOOP
LINETO( xpos1, ypos1 ) CLS2
Description INK = RND (30) + 1
LOADFONT ("A8BitMed.ttf")
Draws a line from the last point plotted (by the PLOT or
PLOTTEXT (RND (200), 100, "THIS font IS nice")
LINE procedures) to point ( xpos1, ypos1 ).
INK = RND (30) + 1
NOTE LOADFONT ("szxp.ttf")
The fonts used in the example overleaf are stored in the PLOTTEXT (RND (200), 200, "THIS font IS nice")
extras folder. We recommend you copy which ever you INK = RND (30) + 1
need to a separate work folder. LOADFONT ("mode7.ttf")
PLOTTEXT (RND (200), 350, "THIS font IS nice")
INK = RND (30) + 1
LOADFONT ("ZX8.ttf")
PLOTTEXT (RND (200), 500, "THIS font IS nice")
Associated WAIT (0.05)
FONTSIZE, LOADFONT UPDATE
REPEAT
114
Contents Functions, Constants & Procedures
LOADIMAGE Example
LOADMUSIC Example
Description
Loads an uncompressed music file in wav format (file
extension .wav) from the file filename into memory and
returns a handle which can then be used to play the
music using the PLAYMUSIC function.
Associated
LOADMUSIC, LOADSAMPLE, PAUSEMUSIC, PLAYMUSIC,
PLAYSAMPLE, RESUMECHAN, RESUMEMUSIC,
SETMUSICVOL, STOPCHAN, STOPMUSIC
116
Contents Functions, Constants & Procedures
LOADSAMPLE Example
Purpose channel = 0
Load a sound sample into memory ready to be played. volume = 70
SETCHANVOL( channel, volume )
Syntax intro = LOADSAMPLE( "powerup.wav" )
handle = LOADSAMPLE( filename ) PLAYSAMPLE( intro, channel, 0 )
Description WAIT( 4.5 )
The LOADSAMPLE function loads a sound sample from END
the uncompressed WAV format file called filename and
returns a handle to it so that it can be played using the
PLAYSAMPLE function. You can load up to 32 sound
samples into memory at the same time.
Associated
LOADMUSIC, LOADSAMPLE, PAUSEMUSIC, PLAYMUSIC,
PLAYSAMPLE, RESUMECHAN, RESUMEMUSIC,
SETMUSICVOL, STOPCHAN, STOPMUSIC
117
Contents Functions, Constants & Procedures
LOADSPRITE Example
Purpose CLS
REM Create a new sprite with 1 version
Load a sprite from a file into memory.
SpriteIndex = NEWSPRITE(1)
Syntax REM Load a sprite from a file
LOADSPRITE( filename$, index, subindex ) Fuzelogo$ = "logo.png"
Description LOADSPRITE( Fuzelogo$, SpriteIndex, 0 )
This loads a sprite from the supplied filename$ into REM Draw the sprite on the screen
memory and associates it with the given sprite index PLOTSPRITE( SpriteIndex, 200, 200, 0 )
and subindex. The index is the handle returned by a call UPDATE
to NEWSPRITE and the subindex is the version of the END
sprite to allow for animation. The first subindex is 0.
Associated
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE,
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY,
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE,
SETSPRITEALPHA, SETSPRITEANGLE, SETSPRITEFLIP,
SETSPRITEORIGIN, SETSPRITESIZE, SPRITECOLLIDE,
SPRITECOLLIDEPP, SPRITEOUT
118
Contents Functions, Constants & Procedures
LOCAL Example
Purpose CLS
X=20
Define variables to be local to a user defined procedure
or PROC Test( X )
function. PRINT "Global X=" + STR$( X )
END
Syntax DEF PROC Test( X )
LOCAL variable LOCAL X
Description X=500
Allows a variable name to be reused in a procedure or PRINT "Local X=" + STR$( X )
function without affecting its value in the calling ENDPROC
program.
Associated
DEF FN, DEF PROC, FN, LOCAL
119
Contents Functions, Constants & Procedures
LOG Example
Purpose X = EXP( 10 )
Return the natural logarithm of the specified number. PRINT X // Will print 22026.46579
PRINT LOG( X ) // Will print 10
Syntax END
naturallogarithm = LOG( number)
Description
Returns the natural logarithm of the specified
number.This is the opposite of the EXP function i.e. LOG(
EXP( X ) ) = X. Logarithms are used in science to solve
exponential radioactive decay problems and in finance
to solve problems involving compound interest.
Associated
EXP
120
Contents Functions, Constants & Procedures
LOCKMOUSE Example
LOCKMOUSE(true)
Purpose distance = 1
Constrain the mouse point to the display window. maxcirc = 360
spacer = 1
Syntax size=5
LOCKMOUSE( [TRUE or FALSE] ) DIM circ1(maxcirc, 3)
FOR n = 0 TO maxcirc STEP spacer LOOP
Description circ1(n, 2) = RND (30)
Very useful when using the mouse to control a program circ1(n, 3) = n * distance
as it keeps the mouse focused on the display window. REPEAT
LOOP
CLS2
FOR n = 0 TO maxcirc STEP spacer LOOP
COLOUR = circ1(n, 2)
circ1(n, 0) = MOUSEX + circ1(n, 3) * COS (n)
circ1(n, 1) = MOUSEY + circ1(n, 3) * SIN (n)
circ1(n, 3) = circ1(n, 3) + distance
x=ABS (gWidth / 2 - circ1(n, 0))
y=ABS (gHeight / 2 - circ1(n, 1))
IF x > gWidth / 2 OR y > gHeight / 2 THEN circ1(n, 3) = 0
CIRCLE (circ1(n, 0), circ1(n, 1), size, 1)
REPEAT
Associated
UPDATE
MOUSEOFF, MOUSEON, MOUSEX, MOUSEY, MOUSEBUTTON, REPEAT
GETMOUSE, SETMOUSE, LEFTCLICK, MIDDLECLICK ,
END
RIGHTCLICK, WHEELUP, WHEELDOWN, LOCKMOUSE
121
Contents Functions, Constants & Procedures
Description
Execute the statements again and again forever. The
BREAK command can be used to terminate a loop.
Pressing the Esc key will also interrupt the loop (and
program).
Associated
BREAK, CONTINUE, LOOP, LOOP REPEAT, FOR REPEAT,
REPEAT UNTIL, UNTIL REPEAT, WHILE REPEAT
122
Contents Functions, Constants & Procedures
MAX Example
Associated
MIN
123
Contents Functions, Constants & Procedures
MICROTIME Example
Associated
TIME
124
Contents Functions, Constants & Procedures
MID$ Example
Associated
ASC, CHR$, DATE$, DEFCHAR, GET$, LEFT$, LEN, MID$,
NUMFORMAT, PRINT, PRINTAT, RIGHT$, SPACE$, STR$,
TIME$, VAL
125
Contents Functions, Constants & Procedures
MIDDLECLICK Example
Purpose UPDATEMODE = 0
Returns TRUE if the middle mouse button is clicked FONTSIZE (4)
LOOP
Syntax
CLS2
value = MIDDLECLICK
INK = LIGHTBLUE
Description PRINTAT (0, 0); "Mouse status"
Returns a value of 0 or 1 (TRUE or FALSE) depending on INK = RASPBERRY
whether it is press or not. PRINTAT (0, 2); "Left button="; LEFTCLICK
PRINTAT (0, 3); "Middle button="; MIDDLECLICK
PRINTAT (0, 4); "Right button="; RIGHTCLICK
PRINTAT (0, 5); "Wheel up="; WHEELUP
PRINTAT (0, 6); "Wheel down="; WHEELDOWN
UPDATE
REPEAT
Associated
MOUSEOFF, MOUSEON, MOUSEX, MOUSEY, MOUSEBUTTON,
GETMOUSE, SETMOUSE, LEFTCLICK, MIDDLECLICK ,
RIGHTCLICK, WHEELUP, WHEELDOWN, LOCKMOUSE
126
Contents Functions, Constants & Procedures
MIN Example
Associated
MAX
127
Contents Functions, Constants & Procedures
Associated
MOUSEOFF, MOUSEON, MOUSEX, MOUSEY, MOUSEBUTTON,
GETMOUSE, SETMOUSE, LEFTCLICK, MIDDLECLICK ,
RIGHTCLICK, WHEELUP, WHEELDOWN, LOCKMOUSE
128
Contents Functions, Constants & Procedures
Purpose CLS
UPDATEMODE = 0
To find the mouse X position
FONTSIZE ( 5 )
Syntax LOOP
value1 = MOUSEX CLS2
value2 = MOUSEY PRINTAT( 0, 0 ); "Mouse X Position="; MOUSEX;
PRINTAT( 0, 1 ); "Mouse Y Position="; MOUSEY;
Description
UPDATE
Returns the X or Y position of the current mouse
REPEAT
location
Associated
MOUSEOFF, MOUSEON, MOUSEX, MOUSEY, MOUSEBUTTON,
GETMOUSE, SETMOUSE, LEFTCLICK, MIDDLECLICK ,
RIGHTCLICK, WHEELUP, WHEELDOWN, LOCKMOUSE
129
Contents Functions, Constants & Procedures
MOUSEBUTTON Example
Purpose UPDATEMODE = 0
Read the button(s) state from an attached mouse FONTSIZE (4)
LOOP
Syntax
CLS2
value = MOUSEBUTTON
INK = LIGHTBLUE
Description PRINTAT (0, 0); "Mouse status"
Read the current state of the mouse buttons. INK = RASPBERRY
PRINTAT (0, 2); "Button value="; MOUSEBUTTON
The returned values are; UPDATE
REPEAT
0 - no buttons pressed
1 - left button pressed
2 - middle button pressed
3 - left & middle buttons pressed
4 - right button pressed
5 - left & right buttons pressed
6 - right & middle button pressed
7 - left, middle & right buttons pressed
Associated
MOUSEOFF, MOUSEON, MOUSEX, MOUSEY, MOUSEBUTTON,
GETMOUSE, SETMOUSE, LEFTCLICK, MIDDLECLICK ,
RIGHTCLICK, WHEELUP, WHEELDOWN, LOCKMOUSE
130
Contents Functions, Constants & Procedures
MOVE Example
Purpose CLS
Move the graphics turtle forward COLOUR = RED
MOVE( 50 )
Syntax DEG
MOVE( distance ) LEFT( 90 )
Description MOVE( 50 )
This causes the virtual graphics turtle to move forwards PENDOWN
distance in screen pixels. A line will be drawn if the pen FOR I = 1 TO 4 LOOP
is down. LEFT( 90 )
MOVE( 100 )
REPEAT
UPDATE
END
Associated
LEFT, MOVE, MOVETO, PENDOWN, PENUP, RIGHT,
TANGLE
131
Contents Functions, Constants & Procedures
MOVETO Example
Associated
LEFT, MOVE, MOVETO, PENDOWN, PENUP, RIGHT,
TANGLE
132
Contents Functions, Constants & Procedures
NEWSPRITE Example
CLS
COLOUR = YELLOW
Purpose CIRCLE( 100, 100, 50, TRUE )
Create a new sprite. SAVEREGION( "pac1.bmp", 50, 50, 100, 100 )
COLOUR = BLACK
Syntax
TRIANGLE( 100, 100, 150, 125, 150, 75, TRUE )
index = NEWSPRITE( count )
SAVEREGION( "pac2.bmp", 50, 50, 100, 100 )
Description TRIANGLE( 100, 100, 150, 150, 150, 50, TRUE )
This returns an index (or handle) to the internal sprite SAVEREGION( "pac3.bmp", 50, 50, 100, 100 )
data. You need to use the index returned in all future CLS
S=0
sprite handling functions/procedures. The count pacman = NEWSPRITE( 4 )
argument specifies the number of different versions of LOADSPRITE( "pac1.bmp", pacman, 0 )
the sprite. LOADSPRITE( "pac2.bmp", pacman, 1 )
LOADSPRITE( "pac3.bmp", pacman, 2 )
LOADSPRITE( "pac2.bmp", pacman, 3 )
FOR X = 1 TO GWIDTH STEP 25 LOOP
PLOTSPRITE( pacman, X, GHEIGHT / 2, S )
S=S+1
Associated IF S = 4 THEN S = 0
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE, WAIT( 0.05 )
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY, UPDATE
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE,
SETSPRITEALPHA, SETSPRITEANGLE, SETSPRITEFLIP, REPEAT
SETSPRITEORIGIN, SETSPRITESIZE, SPRITECOLLIDE, HIDESPRITE( pacman )
SPRITECOLLIDEPP, SPRITEOUT END
133
Contents Functions, Constants & Procedures
NUMFORMAT Example
Purpose NUMFORMAT( 6, 4 )
REM Prints 3.1416
Control how numbers are formatted.
PRINT PI
Syntax NUMFORMAT( 0, 0 )
NUMFORMAT( width, decimals ) REM Prints 3.141592654
Description PRINT PI
You can affect the way numbers are printed using the END
NUMFORMAT procedure. This takes 2 arguments, the
width specifying the total number of characters to print
and the decimals the number of characters after the
decimal point. Numbers printed this way are right-
justified with leading spaces inserted if required.
NUMFORMAT (0,0) restores the output to the general
purpose format used by default.
Associated
ASC, CHR$, DATE$, DEFCHAR, GET$, LEFT$, LEN, MID$,
NUMFORMAT, PRINT, PRINTAT, RIGHT$, SPACE$, STR$,
TIME$, VAL
134
Contents Functions, Constants & Procedures
OPEN Example
Associated
CLOSE, EOF, FFWD, INPUT#, OPEN, PRINT#, REWIND,
SEEK
135
Contents Functions, Constants & Procedures
ORIGIN Example
Purpose CLS
Move the graphics origin. COLOUR = YELLOW
REM Move the origin to the screen centre
Syntax ORIGIN( GWIDTH / 2, GHEIGHT / 2 )
ORIGIN( xpos, ypos ) PLOT( -100, -100 )
Description LINETO( -100, 100 )
This changes the graphics origin for the Cartesian LINETO( 100, 100 )
plotting procedures. The xpos, ypos coordinates are LINETO( 100, -100 )
always absolute coordinates with (0,0) being bottom left LINETO( -100, -100 )
(the default). UPDATE
ORIGIN( 0, 0 )
END
Associated
FULLSCREEN, GHEIGHT, GWIDTH, ORIGIN, SETMODE
136
Contents Functions, Constants & Procedures
PAPER Example
Associated
HTAB, HVTAB, INK, FONTSIZE, NUMFORMAT, PAPER,
PAPEROFF, PAPERON, PLOTTEXT, PRINTAT, PRINT,
TWIDTH, THEIGHT, VTAB
137
Contents Functions, Constants & Procedures
Associated
HTAB, HVTAB, INK, FONTSIZE, NUMFORMAT, PAPER,
PAPEROFF, PAPERON, PLOTTEXT, PRINTAT, PRINT,
TWIDTH, THEIGHT, VTAB
138
Contents Functions, Constants & Procedures
PAUSECHAN Example
Purpose channel = 0
Pause the playing of a sound sample. volume = 70
SETCHANVOL( channel, volume )
Syntax
intro = LOADSAMPLE( "parClip6.wav" )
PAUSECHAN( handle )
PLAYSAMPLE( intro, channel, 0 )
Description WAIT( .3 )
This function pauses the playing of the sound sample PAUSECHAN( intro )
associated with the handle returned by LOADSAMPLE WAIT( .3 )
that has been started using PLAYSAMPLE. The sample RESUMECHAN( intro )
can be resumed where it left off using RESUMECHAN END
Associated
LOADMUSIC, LOADSAMPLE, PAUSEMUSIC, PLAYMUSIC,
PLAYSAMPLE, RESUMECHAN, RESUMEMUSIC,
SETMUSICVOL, STOPCHAN, STOPMUSIC
139
Contents Functions, Constants & Procedures
PAUSEMUSIC Example
Associated
LOADMUSIC, LOADSAMPLE, PAUSEMUSIC, PLAYMUSIC,
PLAYSAMPLE, RESUMECHAN, RESUMEMUSIC,
SETMUSICVOL, STOPCHAN, STOPMUSIC
140
Contents Functions, Constants & Procedures
Associated
LEFT, MOVE, MOVETO, PENDOWN, PENUP, RIGHT,
TANGLE
141
Contents Functions, Constants & Procedures
PI / PI2 Example
PRINT FN AreaOfCircle( 12 )
Purpose
Returns the value of the constant Pi and Pi divided by 2 END
Associated
ACOS, ASIN, ATAN, COS, CLOCK, DEG, PI, PI2, RAD, SIN,
TAN
142
Contents Functions, Constants & Procedures
PINMODE Example
0 pinINPUT
1 pinOUTPUT
2 pinPWM (FUZE / Rpi)
2 pinINPUT with pull-up resistors enabled (Arduino)
Note:
If you have more than one device attached then please
refer to DETECTDEVICES, DEVICETYPE and SETDEVICE
Associated
ANALOGREAD, ANALOGWRITE, DIGITALREAD,
DIGITALWRITE, PINMODE, PWMWRITE, SOFTPWMWRITE
143
Contents Functions, Constants & Procedures
PLAYMUSIC Example
Description
This function plays a music track previously loaded
using the LOADMUSIC function which returns the
handle. The repeats are the number of times to play the
track.
Associated
LOADMUSIC, LOADSAMPLE, PAUSEMUSIC, PLAYMUSIC,
PLAYSAMPLE, RESUMECHAN, RESUMEMUSIC,
SETMUSICVOL, STOPCHAN, STOPMUSIC
144
Contents Functions, Constants & Procedures
PLAYSAMPLE Example
Purpose channel = 0
Start playing a sound sample. volume = 70
SETCHANVOL( channel, volume )
Syntax intro = LOADSAMPLE( "parClip6.wav" )
PLAYSAMPLE( handle, channel, loops ) PLAYSAMPLE( intro, channel, 0 )
Description END
This function plays a sound previously loaded using the
LOADSAMPLE function which returns the handle. The
channel is 0, 1, 2 or 3 which lets you play up to 4
concurrent samples. The loops parameter is different to
the repeats one in the PLAYMUSIC function. Here it
means the number of times to loop the sample – zero
means no loops which means play it once.
Associated
LOADMUSIC, LOADSAMPLE, PAUSEMUSIC, PLAYMUSIC,
PLAYSAMPLE, RESUMECHAN, RESUMEMUSIC,
SETMUSICVOL, STOPCHAN, STOPMUSIC
145
Contents Functions, Constants & Procedures
PLOT Example
Purpose CLS
Draw a single point on the screen. LOOP
IF INKEY <> -1 THEN BREAK
Syntax xpos = RND( GWIDTH )
PLOT( xpos, ypos ) ypos = RND( GHEIGHT )
Description COLOUR = RND( 30 )
This plots a single pixel at screen location (xpos,ypos) in PLOT( xpos, ypos )
the selected graphics mode in the selected colour. Note UPDATE
that (0,0) is bottom left by default. REPEAT
END
Associated
CIRCLE, COLOUR, ELLIPSE, HLINE, LINE, LINETO, PLOT,
PLOTTEXT, POLYEND, POLYPLOT, POLYSTART,
RGBCOLOUR, RECT, SETALPHA, TRIANGLE, VLINE
146
Contents Functions, Constants & Procedures
PLOTIMAGE Example
PLOTSPRITE Example
Purpose CLS
REM Create a new sprite with 1 version
Draw a sprite on the screen.
SpriteIndex = NEWSPRITE( 1 )
Syntax REM Load a sprite from a file
PLOTSPRITE( index, xpos, ypos, subindex ) fuzelogo$ = "dog1.png"
Description LOADSPRITE( fuzelogo$, SpriteIndex, 0 )
This plots the sprite index and version subindex at the REM Draw the sprite on the screen
coordinates (xpos, ypos). The coordinates specify the PLOTSPRITE( SpriteIndex, 0, 0, 0 )
bottom-left corner of the bounding rectangle of the UPDATE
sprite. END
Associated
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE,
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY,
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE,
SETSPRITEALPHA, SETSPRITEANGLE, SETSPRITEFLIP,
SETSPRITEORIGIN, SETSPRITESIZE, SPRITECOLLIDE,
SPRITECOLLIDEPP, SPRITEOUT
148
Contents Functions, Constants & Procedures
Purpose CLS
Indicates the start and end of a filled polygon. PROC Hexagon( 200, 400, 50, Red )
UPDATE
Syntax END
POLYEND DEF PROC Hexagon( x, y, l, c )
POLYSTART COLOUR = c
Description POLYSTART
This marks the beginning and end of a polygon POLYPLOT( x + l, y )
function. The PLOYPLOT statements within plot the POLYPLOT( x + l / 2, y - l * SQRT( 3 / 2 ))
individual points of the polygon to be drawn. POLYPLOT( x - l / 2, y - l * SQRT( 3 / 2 ))
POLYPLOT( x - l, y )
POLYPLOT( x - l / 2, y + l * SQRT( 3 / 2 ))
POLYPLOT( x + l / 2, y + l * SQRT( 3 / 2 ))
POLYEND
ENDPROC
Associated
CIRCLE, COLOUR, ELLIPSE, HLINE, LINE, LINETO, PLOT,
PLOTTEXT, POLYEND, POLYPLOT, POLYSTART,
RGBCOLOUR, RECT, SETALPHA, TRIANGLE, VLINE
149
Contents Functions, Constants & Procedures
POLYPLOT Example
Purpose CLS
Add a point to a filled polygon. PROC Hexagon( 200, 400, 50, Red )
UPDATE
Syntax END
POLYPLOT( xpos, ypos ) DEF PROC Hexagon( x, y, l, c )
Description COLOUR = c
This remembers the given xpos,ypos coordinates as part POLYSTART
of a filled polygon. Nothing is actually drawn on the POLYPLOT( x + l, y )
screen until the POLYEND instruction is executed. POLYPLOT( x + l / 2, y - l * SQRT( 3 / 2 ))
Polygons can have a maximum of 64 points. POLYPLOT( x - l / 2, y - l * SQRT( 3 / 2 ))
POLYPLOT( x - l, y )
POLYPLOT( x - l / 2, y + l * SQRT( 3 / 2 ))
POLYPLOT( x + l / 2, y + l * SQRT( 3 / 2 ))
POLYEND
ENDPROC
Associated
CIRCLE, COLOUR, ELLIPSE, HLINE, LINE, LINETO, PLOT,
PLOTTEXT, POLYEND, POLYPLOT, POLYSTART,
RGBCOLOUR, RECT, SETALPHA, TRIANGLE, VLINE
150
Contents Functions, Constants & Procedures
PLOTTEXT Example
Purpose LOOP
Display text using graphic coordinates. INK = RND ( 30 )
FONTSIZE ( RND ( 10 ) + 1 )
Syntax PLOTTEXT( "HELLO", RND( GWIDTH ), RND( GHEIGHT - 1 ))
PLOTTEXT( “text”, xpos, ypos ) UPDATE
Description REPEAT
The PRINT command uses the cursor coordinates to
display text whereas PLOTTEXT can position text at a
specified pixel location
Associated
CIRCLE, COLOUR, ELLIPSE, HLINE, LINE, LINETO, PLOT,
PLOTTEXT, POLYEND, POLYPLOT, POLYSTART,
RGBCOLOUR, RECT, SETALPHA, TRIANGLE, VLINE
151
Contents Functions, Constants & Procedures
PRINT Example
Purpose CLS
FONTSIZE ( 6 )
Output text to the screen
INK = LIGHTGREEN
Syntax PRINT "Hello Colin"
PRINT “text“ { ; “text” } INK = RED
name$ = "Colin"
Description
PRINT "Hello ";
Outputting text to the screen is done via the PRINT
PRINT name$
command. The PRINT command is quite versatile and
will print any combination of numbers and strings END
separated by the semi-colon (;). A trailing semi-colon
will suppress the printing of a new line.
Associated
HTAB, HVTAB, INK, FONTSIZE, NUMFORMAT, PAPER,
PAPEROFF, PAPERON, PLOTTEXT, PRINTAT, PRINT,
TWIDTH, THEIGHT, VTAB
152
Contents Functions, Constants & Procedures
PRINT# Example
Description
The PRINT# instruction acts just like the regular PRINT
instruction except that it sends data to the file identified
by the supplied file-handle rather than to the screen.
Numbers are formatted according to the settings of
NUMFORMAT. It is strongly recommended to only print
one item per line if you are going to read those items
back into a FUZE BASIC program again.
Associated
CLOSE, EOF, FFWD, INPUT#, OPEN, PRINT#, REWIND,
SEEK
153
Contents Functions, Constants & Procedures
PRINTAT Example
Purpose CLS
FONTSIZE ( 3 )
Set the text cursor position and print
name$ = "Sam"
Syntax age = 10
PRINTAT( x, y ); "text" PRINTAT( 0, 5 ); "My name is "; name$
Description PRINTAT( 5, 10 ); "I am "; age ; " years old"
Use to position the text cursor at the specified location END
and print. Useful for laying out text and or variables at
any preferred screen location.
Associated
HTAB, HVTAB, INK, FONTSIZE, NUMFORMAT, PAPER,
PAPEROFF, PAPERON, PLOTTEXT, PRINTAT, PRINT,
TWIDTH, THEIGHT, VTAB
154
Contents Functions, Constants & Procedures
PROC Example
Purpose CLS
FONTSIZE ( 4 )
Call a user defined procedure.
LOOP
Syntax x = RND( TWIDTH )
PROC name( {argument} { , argument } ) y = RND( THEIGHT )
Description c = RND( 30 )
Calls the specified user defined procedure called name text$ = ”Blossom”
with the specified arguments. Once the procedure has PROC text( text$, x, y, c )
been executed control returns to the command REPEAT
following. END
DEF PROC text( text$, x, y, c )
INK = c
PRINTAT( x, y ); text$
ENDPROC
Associated
DEF PROC, LOCAL, PROC, ENDPROC
155
Contents Functions, Constants & Procedures
PWMWRITE Example
Description
This procedure outputs a PWM waveform on the
selected pin. The pin must be configured for PWM
mode beforehand. The value set should be between 0
and 100.
Associated
ANALOGREAD, ANALOGWRITE, DIGITALREAD,
DIGITALWRITE, PINMODE, PWMWRITE, SOFTPWMWRITE
156
Contents Functions, Constants & Procedures
RAD Example
Associated
ACOS, ASIN, ATAN, COS, CLOCK, DEG, PI, PI2, RAD, SIN,
TAN
157
Contents Functions, Constants & Procedures
READ Example
Associated
DATA, READ, RESTORE
158
Contents Functions, Constants & Procedures
RECT Example
Purpose CLS
Draw a rectangle on the screen. LOOP
COLOUR = RND( 30 )
Syntax x = RND( GWIDTH )
RECT( xpos, ypos, width, height, fill ) y = RND( GHEIGHT )
Description w = RND( GWIDTH / 4 )
Draws a rectangle at position (xpos,ypos) with width and h = RND( GHEIGHT / 4 )
height. The final parameter, fill is either TRUE, FALSE. SETALPHA (RND( 255 ))
RECT( x, y, w, h, 1 )
UPDATE
IF INKEY <> -1 THEN BREAK
REPEAT
END
Associated
CIRCLE, COLOUR, ELLIPSE, HLINE, LINE, LINETO, PLOT,
PLOTTEXT, POLYEND, POLYPLOT, POLYSTART,
RGBCOLOUR, RECT, SETALPHA, TRIANGLE, VLINE
159
Contents Functions, Constants & Procedures
Associated
BREAK, CONTINUE, LOOP, LOOP REPEAT, FOR REPEAT,
REPEAT UNTIL, UNTIL REPEAT, WHILE REPEAT
160
Contents Functions, Constants & Procedures
RESTORE Example
Associated
DATA, READ, RESTORE
161
Contents Functions, Constants & Procedures
RESUMECHAN Example
Purpose channel = 0
Resume the playing of a sound sample. volume = 70
SETCHANVOL( channel, volume )
Syntax intro = LOADSAMPLE( "parClip6.wav" )
RESUMECHAN( handle ) PLAYSAMPLE( intro, channel, 0 )
Description WAIT( 3 )
This function resumes the playing of the sound sample PAUSECHAN( intro )
associated with the handle returned by LOADSAMPLE WAIT( 2 )
that has been started using PLAYSAMPLE and paused RESUMECHAN( intro )
using PAUSECHAN. END
Associated
LOADMUSIC, LOADSAMPLE, PAUSEMUSIC, PLAYMUSIC,
PLAYSAMPLE, RESUMECHAN, RESUMEMUSIC,
SETMUSICVOL, STOPCHAN, STOPMUSIC
162
Contents Functions, Constants & Procedures
RESUMEMUSIC Example
Associated
LOADMUSIC, LOADSAMPLE, PAUSEMUSIC, PLAYMUSIC,
PLAYSAMPLE, RESUMECHAN, RESUMEMUSIC,
SETMUSICVOL, STOPCHAN, STOPMUSIC
163
Contents Functions, Constants & Procedures
REWIND Example
Associated
CLOSE, EOF, FFWD, INPUT#, OPEN, PRINT#, REWIND,
SEEK
164
Contents Functions, Constants & Procedures
RGBCOLOUR Example
Purpose CLS
Set the current graphical plot colour to an RGB PRINT "Draw Spectrum"
(Red,Green, Blue) value. FOR value = 0 TO 255 LOOP
RGBCOLOUR( 255, value, 0 )
Syntax LINE( value , 0, value , GHEIGHT )
RGBCOLOUR( red, green, blue )
RGBCOLOUR( value , 255, 0 )
Description LINE( 511 - value , 0, 511 - value , GHEIGHT )
This sets the current graphical plot colour to an RGB RGBCOLOUR( 0, 255 - value , value )
(Red,Green, Blue) value. The values should be from 0 to LINE( 512 + value , 0, 512 + value , GHEIGHT )
255. RGBCOLOUR( 0, value , 255 )
LINE( 768 + value , 0, 768 + value , GHEIGHT )
REPEAT
UPDATE
END
Associated
CIRCLE, COLOUR, ELLIPSE, HLINE, LINE, LINETO, PLOT,
PLOTTEXT, POLYEND, POLYPLOT, POLYSTART,
RGBCOLOUR, RECT, SETALPHA, TRIANGLE, VLINE
165
Contents Functions, Constants & Procedures
RIGHT Example
Purpose CLS
Turns the turtle to the right (clockwise) by the given PRINT "Draw Pink Hexagon"
angle. PENUP
COLOUR = PINK
Syntax
PENDOWN
RIGHT( angle )
FOR I = 1 TO 6 LOOP
Description RIGHT( 60 )
Turns the virtual graphics turtle to the right (clockwise) MOVE( 100 )
by the given angle in the current angle units. REPEAT
END
Associated
LEFT, MOVE, MOVETO, PENDOWN, PENUP, RIGHT,
TANGLE
166
Contents Functions, Constants & Procedures
RIGHT$ Example
Purpose CLS
FONTSIZE( 3 )
Return the specified rightmost number of a characters
string$ = "The quick brown fox"
from a string.
FOR i = 1 TO 20 LOOP
Syntax PRINT RIGHT$( string$, i )
substring$ = RIGHT$( string$, number ) REPEAT
Description END
Returns a substring of string$ with number characters
from the right (end) of the string. If number is greater
than or equal to the length of string$ then the whole
string is returned.
Associated
ASC, CHR$, DATE$, DEFCHAR, GET$, LEFT$, LEN, MID$,
NUMFORMAT, PRINT, PRINTAT, RIGHT$, SPACE$, STR$,
TIME$, VAL
167
Contents Functions, Constants & Procedures
RIGHTCLICK Example
Purpose UPDATEMODE = 0
Returns TRUE if the right mouse button is clicked FONTSIZE (4)
LOOP
Syntax
CLS2
value = RIGHTCLICK
INK = LIGHTBLUE
Description PRINTAT (0, 0); "Mouse status"
Returns a value of 0 or 1 (TRUE or FALSE) depending on INK = RASPBERRY
whether it is press or not. PRINTAT (0, 2); "Left button="; LEFTCLICK
PRINTAT (0, 3); "Middle button="; MIDDLECLICK
PRINTAT (0, 4); "Right button="; RIGHTCLICK
PRINTAT (0, 5); "Wheel up="; WHEELUP
PRINTAT (0, 6); "Wheel down="; WHEELDOWN
UPDATE
REPEAT
Associated
MOUSEOFF, MOUSEON, MOUSEX, MOUSEY, MOUSEBUTTON,
GETMOUSE, SETMOUSE, LEFTCLICK, MIDDLECLICK ,
RIGHTCLICK, WHEELUP, WHEELDOWN, LOCKMOUSE
168
Contents Functions, Constants & Procedures
ROTATEIMAGE Example
Purpose CLS
To rotate an image by a specified number of degrees. image = LOADIMAGE ( "house3.png" )
angle=0
Syntax LOOP
ROTATEIMAGE( handle, degrees ) CLS
ROTATEIMAGE ( image, angle )
Description
PLOTIMAGE ( image, 0, 0 )
Use to rotate the specified image by the number of
angle=angle+22.5
degrees specified.
UPDATE
WAIT ( .3 )
REPEAT
END
Associated
CLS, CLS2, COPYREGION, FREEIMAGE, FULLSCREEN, GETIMAGEH,
GETIMAGEW, GRABREGION, LOADIMAGE, PLOTIMAGE,
ROTATEIMAGE, SAVEREGION, SAVESCREEN, SCALEIMAGE,
SCROLLDOWN, SCROLLLEFT, SCROLLRIGHT, SCROLLUP,
SETIMAGEORIGIN, SETMODE, UPDATE, UPDATEREGION
169
Contents Functions, Constants & Procedures
RND Example
CLS
Purpose FONTSIZE (4)
Generate a random number in a given range. LOOP
diceroll = RND (6) + 1
Syntax
INK = ORANGE
random = RND( range )
PRINTAT (0, 0); "Dice Roll: "; diceroll
Description cointoss = RND (2)
This function returns a random number based on the INK = LIGHTYELLOW
value of range. If range is zero, then the last random IF cointoss = 1 THEN PRINTAT (0, 2); "Heads"
number generated is returned, if range is 1, then a IF cointoss = 0 THEN PRINTAT (0, 2); "Tails"
random number from 0 to 1 is returned, otherwise a WHILE INKEY <> 32 LOOP
random number from 0 up to, but not including range
INK = RND (30)
is returned.
PRINTAT (0, 5); "Press space to throw / toss"
REPEAT
REPEAT
END
Associated
SEED
170
Contents Functions, Constants & Procedures
SAVEREGION Example
Purpose CLS
Save a snapshot of an area of the screen to an image COLOUR = YELLOW
file. CIRCLE ( 100, 100, 50, TRUE )
COLOUR = BLACK
Syntax
TRIANGLE( 100, 100, 150, 150, 150, 50, TRUE )
SAVEREGION( file$, xpos, ypos, width, height )
TRIANGLE( 100, 100, 150, 125, 150, 75, TRUE )
Description SAVEREGION( "pac1.bmp", 50, 50, 100, 100 )
Takes a snapshot of an area of the current screen CLS
specified by the rectangle with bottom left at pacman = NEWSPRITE( 1 )
coordinates (xpos,ypos) of specified width and height, LOADSPRITE( "pac1.bmp", pacman , 0 )
and saves it to the file named file$ in a bitmap (.bmp)
FOR x = 1 TO GWIDTH STEP 25 LOOP
format.
PLOTSPRITE( pacman, x, GHEIGHT / 2, 0 )
UPDATE
WAIT( 0.1 )
REPEAT
Associated
CLS, CLS2, COPYREGION, FREEIMAGE, FULLSCREEN, GETIMAGEH,
GETIMAGEW, GRABREGION, LOADIMAGE, PLOTIMAGE,
ROTATEIMAGE, SAVEREGION, SAVESCREEN, SCALEIMAGE,
SCROLLDOWN, SCROLLLEFT, SCROLLRIGHT, SCROLLUP,
SETIMAGEORIGIN, SETMODE, UPDATE, UPDATEREGION
171
Contents Functions, Constants & Procedures
SAVESCREEN Example
CLS
Purpose PRINT "Draw Spectrum"
Save a snapshot of the screen to an image file. FOR value = 0 TO 255 LOOP
RGBCOLOUR( 255, value, 0 )
Syntax
LINE( value , 0, value , GHEIGHT )
SAVESCREEN( filename$ )
RGBCOLOUR( value , 255, 0 )
Description LINE( 511 - value , 0, 511 - value , GHEIGHT )
This takes a snapshot of the current screen and saves it RGBCOLOUR( 0, 255 - value , value )
to the filename given in a bitmap (.bmp) format file. LINE( 512 + value , 0, 512 + value , GHEIGHT )
RGBCOLOUR( 0, value , 255 )
LINE( 768 + value , 0, 768 + value , GHEIGHT )
REPEAT
UPDATE
SAVESCREEN( "screenshot.bmp" )
END
Associated
CLS, CLS2, COPYREGION, FREEIMAGE, FULLSCREEN, GETIMAGEH,
GETIMAGEW, GRABREGION, LOADIMAGE, PLOTIMAGE,
ROTATEIMAGE, SAVEREGION, SAVESCREEN, SCALEIMAGE,
SCROLLDOWN, SCROLLLEFT, SCROLLRIGHT, SCROLLUP,
SETIMAGEORIGIN, SETMODE, UPDATE, UPDATEREGION
172
Contents Functions, Constants & Procedures
SCALEIMAGE Example
Purpose CLS
Resize a loaded image. image = LOADIMAGE ("dog1.png")
PLOTIMAGE (image, 0, 0)
Syntax
newx = GETIMAGEW (image)
SCALEIMAGE( handle, percent )
UPDATE
Description WAIT (1)
Scales a preloaded image by a specified percentage. SCALEIMAGE (image, 50)
PLOTIMAGE (image, newx, 0)
UPDATE
WAIT (1)
END
Associated
CLS, CLS2, COPYREGION, FREEIMAGE, FULLSCREEN, GETIMAGEH,
GETIMAGEW, GRABREGION, LOADIMAGE, PLOTIMAGE,
ROTATEIMAGE, SAVEREGION, SAVESCREEN, SCALEIMAGE,
SCROLLDOWN, SCROLLLEFT, SCROLLRIGHT, SCROLLUP,
SETIMAGEORIGIN, SETMODE, UPDATE, UPDATEREGION
173
Contents Functions, Constants & Procedures
SCANKEYBOARD Example
Associated
CLEARKEYBOARD, GET, GET$, INKEY, INPUT,
SCANKEYBOARD
174
Contents Functions, Constants & Procedures
SCLOSE Example
Associated
SCLOSE, SGET, SGET$, SOPEN, SPUT, SPUT$, SREADY
175
Contents Functions, Constants & Procedures
SEED Example
Purpose SEED = 10
Seed the random number generator. PRINT RND( 100 )
SEED = 10
Syntax REM Will print the same number
SEED = value PRINT RND( 100 )
Description REM Will print a different number
This can be assigned to initialise the random number PRINT RND( 100 )
generator, or you can read it to find the current seed. END
Associated
RND
177
Contents Functions, Constants & Procedures
SEEK Example
Associated
CLOSE, EOF, FFWD, INPUT#, OPEN, PRINT#, REWIND,
SEEK
178
Contents Functions, Constants & Procedures
SENSEACCELX / Y / Z Example
Purpose CLS
LOOP
Returns the value of the Raspberry Pi senseHAT
PRINT “Sense Accelerometer X=”; SENSEACCELX
accelerometer.
PRINT “Sense Accelerometer Y=”; SENSEACCELY
Syntax PRINT “Sense Accelerometer Z=”; SENSEACCELZ
value = SENSEACCELX REPEAT
value = SENSEACCELY END
value = SENSEACCELZ
Description
The Raspberry Pi senseHAT has a number of built in
sensors. The accelerometer can be accessed with this
function.
Associated
SENSECOMPASS, SENSEGYRO, SENSEACCEL
179
Contents Functions, Constants & Procedures
SENSECLS Example
CLS
Purpose
SENSEPLOT( 2, 2 )
Sets all of the LEDs on the Raspberry Pi senseHAT to off.
WAIT ( 1 )
Syntax SENSECLS
SENSECLS END
Description
Sets an RGB value of 0, 0, 0 to all of the matrix LEDs
thereby clearing the display.
Associated
SENSECLS, SENSEPLOT, SENSERECT, SENSESCROLL, SENSEHFLIP,
SENSEVFLIP, SENSERGBCOLOUR, SENSEGETRGB, SENSELINE
180
Contents Functions, Constants & Procedures
SENSECOMPASSX / Y / Z Example
Purpose CLS
LOOP
Returns the value of the Raspberry Pi senseHAT
PRINT “Sense Compass X=”; SENSECOMPASSX
compass.
PRINT “Sense Compass Y=”; SENSECOMPASSY
Syntax PRINT “Sense Compass Z=”; SENSECOMPASSZ
value = SENSECOMPASSX REPEAT
value = SENSECOMPASSY END
value = SENSECOMPASSZ
Description
The Raspberry Pi senseHAT has a number of built in
sensors. The compass can be accessed with this function.
Associated
SENSECOMPASS, SENSEGYRO, SENSEACCEL
181
Contents Functions, Constants & Procedures
SENSEGETRGB Example
Purpose CLS
SENSERGBCOLOUR( 0, 0, 255 )
Return the values used by a Raspberry Pi senseHAT LED
SENSEPLOT( 0, 0 )
Syntax SENSEGETRGB( 0, 0, r, g, b )
SENSEGETRGB(xpos, ypos, red, green, blue) PRINT “Red=”; r
PRINT “Green=”; g
Description PRINT “Blue=”; b
Returns the Red, Green and Blue values from a given LED END
at the specified matrix coordinates. It is possible to use
this for collision detection in games using the senseHAT.
Associated
SENSECLS, SENSEPLOT, SENSERECT, SENSESCROLL, SENSEHFLIP,
SENSEVFLIP, SENSERGBCOLOUR, SENSEGETRGB, SENSELINE
182
Contents Functions, Constants & Procedures
SENSEGYROX / Y / Z Example
CLS
Purpose
LOOP
Returns the value of the Raspberry Pi senseHAT gyro.
PRINT “Sense Gyro X=”; SENSEGYROX
Syntax PRINT “Sense Gyro Y=”; SENSEGYROY
value = SENSEGYROX PRINT “Sense Gyro Z=”; SENSEGYROZ
value = SENSEGYROY REPEAT
value = SENSEGYROZ END
Description
The Raspberry Pi senseHAT has a number of built in
sensors. The gyro can be accessed with this function.
Associated
SENSECOMPASS, SENSEGYRO, SENSEACCEL
183
Contents Functions, Constants & Procedures
SENSEHEIGHT Example
CLS
Purpose
LOOP
Returns the value of the Raspberry Pi senseHAT height
PRINT “Height”; SENSEHEIGHT
sensor.
REPEAT
Syntax END
value = SENSEHEIGHT
Description
The Raspberry Pi senseHAT has a number of built in
sensors. Height above sea level can be accessed with this
function. Note, this does not work well indoors.
Associated
SENSEHEIGHT, SENSEHUMIDITY, SENSEPRESSURE,
SENSETEMPERATURE
184
Contents Functions, Constants & Procedures
Purpose CLS
Horizontally flips the Raspberry Pi senseHAT LED matrix. SENSERGBCOLOUR( 255, 0, 0 )
SENSELINE( 0, 0, 0, 7 )
Syntax SENDRGBCOLOUR( 0, 255, 0 )
SENSEHFLIP SENSELINE( 0, 7, 7, 7 )
SENSEVFLIP LOOP
Description SENSEHFLIP
Reverses (flips) the LED matrix display horizontally or WAIT( 1 )
vertically. SENSEVFLIP
WAIT( 1 )
REPEAT
END
Associated
SENSECLS, SENSEPLOT, SENSERECT, SENSESCROLL, SENSEHFLIP,
SENSEVFLIP, SENSERGBCOLOUR, SENSEGETRGB, SENSELINE
185
Contents Functions, Constants & Procedures
SENSEHUMIDITY Example
CLS
Purpose
LOOP
Returns the value of the Raspberry Pi senseHAT
PRINT “Humidity”; SENSEHUMIDITY
humidity sensor.
REPEAT
Syntax END
value = SENSEHUMIDITY
Description
The Raspberry Pi senseHAT has a number of built in
sensors. Humidity can be accessed with this function.
Associated
SENSEHEIGHT, SENSEHUMIDITY, SENSEPRESSURE,
SENSETEMPERATURE
186
Contents Functions, Constants & Procedures
SENSELINE Example
CLS
Purpose
SENSERGBCOLOUR( 255, 0, 0 )
Lights a line on the Raspberry Pi senseHAT LED matrix.
SENSELINE( 0, 0, 0, 7 )
Syntax SENSERGBCOLOUR( 0, 255, 0 )
SENSELINE( x1, y1, x2, y2 ) SENSELINE( 0, 7, 7, 7 )
END
Description
Sets the RGB values, defined by SENSERGBCOLOUR, to a
line of LEDs on the Raspberry Pi senseHAT LED matrix.
The line is displayed from x1, y1 to x2, y2.
Associated
SENSECLS, SENSEPLOT, SENSERECT, SENSESCROLL, SENSEHFLIP,
SENSEVFLIP, SENSERGBCOLOUR, SENSEGETRGB, SENSELINE
187
Contents Functions, Constants & Procedures
SENSEPLOT Example
Purpose CLS
Lights an LED on the Raspberry Pi senseHAT LED matrix. SENSERGBCOLOUR( 255, 0, 0 )
SENSEPLOT( 0, 0 )
Syntax SENSERGBCOLOUR( 0, 255, 0 )
SENSEPLOT(xpos, ypos) SENSEPLOT( 7, 7 )
END
Description
Sets the RGB values, defined by SENSERGBCOLOUR, to a
single LED on the Raspberry Pi senseHAT LED matrix.
Associated
SENSECLS, SENSEPLOT, SENSERECT, SENSESCROLL, SENSEHFLIP,
SENSEVFLIP, SENSERGBCOLOUR, SENSEGETRGB, SENSELINE
188
Contents Functions, Constants & Procedures
SENSEPRESSURE Example
Purpose CLS
LOOP
Returns the value of the Raspberry Pi senseHAT air
PRINT “Pressure”; SENSEPRESSURE
pressure sensor.
REPEAT
Syntax END
value = SENSEPRESSURE
Description
The Raspberry Pi senseHAT has a number of built in
sensors. Air pressure can be accessed with this function.
Associated
SENSEHEIGHT, SENSEHUMIDITY, SENSEPRESSURE,
SENSETEMPERATURE
189
Contents Functions, Constants & Procedures
SENSERECT Example
Purpose CLS
Lights a rectangle on the Raspberry Pi senseHAT LED SENSERGBCOLOUR( 255, 0, 0 )
matrix. SENSERECT( 0, 0, 7, 7, 1 )
SENSERGBCOLOUR( 0, 255, 0 )
Syntax SENSERECT( 1, 1, 5, 5, 0 )
SENSERECT( xpos, ypos, width, height, fill ) END
Description
Sets the RGB values, defined by SENSERGBCOLOUR, to a
rectangle of LEDs on the Raspberry Pi senseHAT LED
matrix. The rectangle is displayed from xpos, ypos with a
width and height as specified. Fill can be either 0 for an
outline or 1 for filled in.
Associated
SENSECLS, SENSEPLOT, SENSERECT, SENSESCROLL, SENSEHFLIP,
SENSEVFLIP, SENSERGBCOLOUR, SENSEGETRGB, SENSELINE
190
Contents Functions, Constants & Procedures
SENSERGBCOLOUR Example
Purpose CLS
SENSERGBCOLOUR ( 255, 0, 0 )
Set the Red, Green and Blue values used by a Raspberry
Pi senseHAT LED. SENSEPLOT ( 0, 0 )
SENSERGBCOLOUR ( 0, 255, 0 )
Syntax SENSEPLOT ( 3, 3 )
SENSERGBCOLOUR( red, green, blue ) SENSERGBCOLOUR ( 0, 0, 255 )
SENSEPLOT ( 7, 7 )
Description
END
Sets the Red, Green and Blue values to be used by the
senseHAT FUZE BASIC drawing commands.
Associated
SENSECLS, SENSEPLOT, SENSERECT, SENSESCROLL, SENSEHFLIP,
SENSEVFLIP, SENSERGBCOLOUR, SENSEGETRGB, SENSELINE
191
Contents Functions, Constants & Procedures
SENSESCROLL Example
SENSECLS
Purpose SENSEPLOT( 2, 2 )
Scrolls the Raspberry Pi senseHAT LED matrix. SENSEPLOT( 2, 3 )
LOOP
Syntax SENSESCROLL ( 0, 2 ) // two up
SENSESCROLL( direction, direction ) WAIT(0.1)
SENSESCROLL ( 2, 0 ) // two right
Description WAIT(0.1)
Shifts the Raspberry Pi senseHAT LED matrix in the
SENSESCROLL ( 0, - 2 ) // two down
specified direction by the number of pixels indicated.
WAIT(0.1)
SENSESCROLL ( - 2, 0 ) // two left
WAIT(0.1)
REPEAT
END
Associated
SENSECLS, SENSEPLOT, SENSERECT, SENSESCROLL, SENSEHFLIP,
SENSEVFLIP, SENSERGBCOLOUR, SENSEGETRGB, SENSELINE
192
Contents Functions, Constants & Procedures
SENSETEMPERATURE Example
Purpose CLS
LOOP
Returns the value of the Raspberry Pi senseHAT heat
PRINT “Temperature”; SENSETEMPERATURE
sensor.
REPEAT
Syntax END
value = SENSETEMPERATURE
Description
The Raspberry Pi senseHAT has a number of built in
sensors. Temperature, in degrees, can be accessed with
this function.
Associated
SENSEHEIGHT, SENSEHUMIDITY, SENSEPRESSURE,
SENSETEMPERATURE
193
Contents Functions, Constants & Procedures
SETALPHA Example
image = loadImage ("img1.png")
setMode (getImageW (image), getImageH (image))
Purpose text$ = "FUZE BASIC"
Set the level of transparency for graphics alpha = 255
cx = GWIDTH / 2
Syntax cy = GHEIGHT / 2
SETALPHA( value ) cxdir = 2
cydir = 2
Description PaperOff
Sets the level of transparency to be used by all drawing fontSize (6)
and text commands ( 0 - 255 ). 0 is totally transparent, updateMode = 0
LOOP
255 is opaque (solid).
CLS2
IF leftClick AND alpha > 0 THEN alpha = alpha - 1
IF rightClick AND alpha < 255 THEN alpha = alpha + 1
plotImage (image, 0, 0)
setAlpha (alpha)
COLOUR = YELLOW
cx = cx + cxdir
cy = cy + cydir
IF cx < 0 OR cx > GWIDTH THEN cxdir = - cxdir
IF cy < 0 OR cy > GHEIGHT THEN cydir = - cydir
CIRCLE (cx, cy, 100, 1)
Associated INK = RASPBERRY
CIRCLE, COLOUR, ELLIPSE, HLINE, LINE, LINETO, PLOT, printAt (TWIDTH / 2 - LEN (text$) / 2, THEIGHT / 2 - 1); text$
PLOTTEXT, POLYEND, POLYPLOT, POLYSTART, UPDATE
RGBCOLOUR, RECT, SETALPHA, TRIANGLE, VLINE REPEAT
194
Contents Functions, Constants & Procedures
SETCHANVOL Example
channel = 0
Purpose
Set the volume of a sound sample. ufo = LOADSAMPLE ("senemy.wav")
LOOP
Syntax FOR volume = 20 TO 100 STEP 5 LOOP
SETCHANVOL( channel, volume ) SETCHANVOL (channel, volume)
Description PLAYSAMPLE (ufo, 0, 0)
Sets the sound sample playback volume on the WAIT (0.1)
specified channel where volume is a percentage of the REPEAT
maximum ( 0 - 100 ) REPEAT
END
Associated
LOADMUSIC, LOADSAMPLE, PAUSEMUSIC, PLAYMUSIC,
PLAYSAMPLE, RESUMECHAN, RESUMEMUSIC,
SETMUSICVOL, STOPCHAN, STOPMUSIC
195
Functions, Constants & Procedures
SETDEVICE Example
Purpose devices=DETECTDEVICES
Checks which devices are connected (Arduino / CLS
compatible or BBC micro:bit) IF devices = FALSE THEN
PRINT "No devices found"
Syntax
END
PRINT DEVICETYPE( ID )
ELSE
Description PRINT devices; " devices found"
Returns a value corresponding to the device type: PRINT
FOR id = 0 TO devices LOOP
1 = BBC micro:bit IF DEVICETYPE(id) = 1 THEN
2 = Arduino or compatible device
PRINT "BBC micro:bit :ID="; id
Note: ENDIF
If you have more than one device attached then please IF DEVICETYPE(id) = 2 THEN
refer to DETECTDEVICES, DEVICETYPE and SETDEVICE PRINT "Arduino or compatible device :ID="; id
ENDIF
REPEAT
END
Associated
DETECTDEVICES, DEVICETYPE, SETDEVICE
196
Functions, Constants & Procedures
SETIMAGEORIGIN Example
image = LOADIMAGE ("img1.png")
SETMODE (1280, 720)
Purpose
x = GETIMAGEW (image) / 2
Set the point of origin for an image y = GETIMAGEH (image) / 2
Syntax PAPEROFF
SETIMAGEORIGIN ( handle, x offset, y offset ) FONTSIZE (6)
UPDATEMODE = 0
Description LOOP
Allows you to set the drawing point of an image. This is CLS2
useful when you need to centre images or draw an IF LEFTCLICK THEN SETIMAGEORIGIN (image, 0, 0)
image using the mouse. IF RIGHTCLICK THEN
x = GETIMAGEW (image) / 2
y = GETIMAGEH (image) / 2
SETIMAGEORIGIN (image, x, y)
ENDIF
PLOTIMAGE (image, GWIDTH / 2, GHEIGHT / 2)
COLOUR = RND (30)
CIRCLE (GWIDTH / 2, GHEIGHT / 2, 30, 0)
UPDATE
Associated
REPEAT
CLS, CLS2, COPYREGION, FREEIMAGE, FULLSCREEN, GETIMAGEH,
GETIMAGEW, GRABREGION, LOADIMAGE, PLOTIMAGE,
ROTATEIMAGE, SAVEREGION, SAVESCREEN, SCALEIMAGE,
SCROLLDOWN, SCROLLLEFT, SCROLLRIGHT, SCROLLUP,
SETIMAGEORIGIN, SETMODE, UPDATE, UPDATEREGION
197
Contents Functions, Constants & Procedures
SETMODE Example
Associated
FULLSCREEN, GHEIGHT, GWIDTH, ORIGIN, SETMODE
198
Contents Functions, Constants & Procedures
SETMOUSE Example
CLS
LOCKMOUSE(TRUE)
Purpose
MOUSEON
Move the mouse pointer to the specified point.
COLOUR = WHITE
Syntax RECT (100, 100, 150, 50, TRUE)
SETMOUSE( xpos, ypos ) INK = BLACK
PAPER = WHITE
Description PLOTTEXT ("Click Me", 105, 125);
Moves the mouse pointer to the screen coordinate UPDATE
(xpos,ypos) clicked = FALSE
LOOP
GETMOUSE (x, y, z)
IF z <> 0 THEN
IF (x > 100 AND x < 250) THEN
IF (y > 100 AND y < 150) THEN
clicked = TRUE
ENDIF
ENDIF
ENDIF
REPEAT UNTIL clicked
Associated SETMOUSE (GWIDTH / 2, GHEIGHT / 2)
MOUSEOFF, MOUSEON, MOUSEX, MOUSEY, MOUSEBUTTON, LOCKMOUSE(FALSE)
GETMOUSE, SETMOUSE, LEFTCLICK, MIDDLECLICK , END
RIGHTCLICK, WHEELUP, WHEELDOWN, LOCKMOUSE
199
Contents Functions, Constants & Procedures
SETMUSICVOL Example
Description
Sets the music playback volume where level is a
percentage of the maximum (0-100)
Associated
LOADMUSIC, LOADSAMPLE, PAUSEMUSIC, PLAYMUSIC,
PLAYSAMPLE, RESUMECHAN, RESUMEMUSIC,
SETMUSICVOL, STOPCHAN, STOPMUSIC
200
Contents Functions, Constants & Procedures
SETSPRITEALPHA Example
CLS
Purpose sprite = NEWSPRITE (1)
Sets the transparency of a sprite image = LOADIMAGE ("img.png")
imagex = GWIDTH / 2 - GETIMAGEW (image) / 2
Syntax
PLOTIMAGE (image, imagex, 0)
SETSPRITEALPHA( sprite, alpha )
LOADSPRITE ("logo.png", sprite, 0)
Description spritex = GETSPRITEW (sprite) / 2
Sets how transparent a sprite is. An alpha of 0 means spritey = GETSPRITEH (sprite) / 2
it's invisible and 255 means it's completely opaque, or SETSPRITEORIGIN (sprite, spritex, spritey)
solid. FOR alpha = 0 TO 255 LOOP
SETSPRITEALPHA( sprite, alpha )
PLOTSPRITE (sprite, GWIDTH / 2, GHEIGHT / 2, 0)
UPDATE
WAIT (0.01)
REPEAT
END
Associated
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE,
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY,
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE,
SAVESPRITE, SETSPRITEALPHA, SETSPRITEANGLE,
SETSPRITEFLIP, SETSPRITEORIGIN, SETSPRITESIZE,
SPRITECOLLIDE, SPRITECOLLIDEPP, SPRITEOUT
201
Contents Functions, Constants & Procedures
SETSPRITEANGLE Example
Purpose CLS
Rotate a sprite to the given angle sprite = NEWSPRITE( 1 )
LOADSPRITE( "logo.png", sprite, 0 )
Syntax
spritex = GETSPRITEW (sprite) / 2
SETSPRITEANGLE( sprite, angle )
spritey = GETSPRITEH (sprite) / 2
Description SETSPRITEORIGIN (sprite, spritex, spritey)
Use to rotate the specified sprite to the given angle in LOOP
degrees. 0 is default. FOR angle = 0 TO 360 STEP 0.01 LOOP
SETSPRITEANGLE( sprite, angle )
PLOTSPRITE( sprite, GWIDTH / 2, GHEIGHT / 2, 0 )
UPDATE
REPEAT
REPEAT
END
Associated
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE,
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY,
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE,
SETSPRITEALPHA, SETSPRITEANGLE, SETSPRITEFLIP,
SETSPRITEORIGIN, SETSPRITESIZE, SPRITECOLLIDE,
SPRITECOLLIDEPP, SPRITEOUT
202
Contents Functions, Constants & Procedures
SETSPRITEFLIP Example
Purpose CLS
Mirror a sprite in the specified direction sprite = NEWSPRITE (1)
LOADSPRITE ("logo.png", sprite, 0)
Syntax
spritex = GETSPRITEW (sprite) / 2
SETSPRITEFLIP( sprite, flip )
spritey = GETSPRITEH (sprite) / 2
Description SETSPRITEORIGIN (sprite, spritex, spritey)
Graphically mirrors (flips) the specified sprite. PLOTSPRITE (sprite, GWIDTH / 2, GHEIGHT / 2, 0)
LOOP
0 Reset to default FOR a = 3 TO 0 STEP -1 LOOP
1 mirrored vertically SETSPRITEFLIP (sprite, a)
2 mirrored horizontally UPDATE
3 mirrored vertically & horizontally WAIT (1)
REPEAT
REPEAT
Associated
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE,
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY,
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE,
SETSPRITEALPHA, SETSPRITEANGLE, SETSPRITEFLIP,
SETSPRITEORIGIN, SETSPRITESIZE, SPRITECOLLIDE,
SPRITECOLLIDEPP, SPRITEOUT
203
Contents Functions, Constants & Procedures
SETSPRITEORIGIN Example
CLS
Purpose sprite = newSprite (1)
Sets the anchor point of a sprite loadSprite ("logo.png", sprite, 0)
LOOP
Syntax
setSpriteOrigin (sprite, 0, 0)
SETSPRITEorigin( sprite, xpos, ypos )
plotSprite (sprite, 0, 0, 0)
Description UPDATE
Use to set the origin of a specified sprite. When plotting WAIT (.5)
a sprite its default origin is bottom left. You can change middlex = getSpriteW (sprite) / 2
this to any point on the sprite. This example sets it to the middley = getSpriteH (sprite) / 2
middle. setSpriteOrigin (sprite, middlex, middley)
plotSprite (sprite, 0, 0, 0)
UPDATE
WAIT (.5)
REPEAT
Associated
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE,
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY,
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE,
SETSPRITEALPHA, SETSPRITEANGLE, SETSPRITEFLIP,
SETSPRITEORIGIN, SETSPRITESIZE, SPRITECOLLIDE,
SPRITECOLLIDEPP, SPRITEOUT
204
Contents Functions, Constants & Procedures
SETSPRITESIZE Example
CLS
Purpose sprite = NEWSPRITE( 1 )
Change the size of a sprite LOADSPRITE( "logo.png", sprite, 0 )
FOR size = 1 TO 300 step .1 LOOP
Syntax
SETSPRITESIZE( sprite, size )
SETSPRITESIZE( sprite, size )
x=(GWIDTH / 2)-GETSPRITEW (sprite) / 2
Description y=(GHEIGHT / 2)-GETSPRITEH (sprite) / 2
Sets the sprite to the specified size in percent. 100 is the PLOTSPRITE( sprite, x, y, 0 )
default, therefore 50 is half the size and 300 is three UPDATE
times as big as the original. REPEAT
END
Associated
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE,
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY,
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE,
SETSPRITEALPHA, SETSPRITEANGLE, SETSPRITEFLIP,
SETSPRITEORIGIN, SETSPRITESIZE, SPRITECOLLIDE,
SPRITECOLLIDEPP, SPRITEOUT
205
Contents Functions, Constants & Procedures
SGET Example
Associated
SCLOSE, SGET, SGET$, SOPEN, SPUT, SPUT$, SREADY
206
Contents Functions, Constants & Procedures
SGET$ Example
Associated
SCLOSE, SGET, SGET$, SOPEN, SPUT, SPUT$, SREADY
207
Contents Functions, Constants & Procedures
SGN Example
REM Prints 1
Purpose
Returns the sign of the specified number. PRINT SGN( 100 )
PRINT SGN( 0 )
Syntax REM Print -1
sign = SGN( number ) PRINT SGN( -5 )
Description END
Returns -1 if the number is negative, 1 otherwise. (Zero
is considered positive)
Associated
ABS, SGN
208
Contents Functions, Constants & Procedures
SIN Example
Associated
ACOS, ASIN, ATAN, COS, CLOCK, DEG, PI, PI2, RAD, SIN,
TAN
209
Contents Functions, Constants & Procedures
SOFTPWMWRITE Example
Associated
ANALOGREAD, ANALOGWRITE, DIGITALREAD,
DIGITALWRITE, PINMODE, PWMWRITE, SOFTPWMWRITE
210
Contents Functions, Constants & Procedures
SOPEN Example
Associated
SCLOSE, SGET, SGET$, SOPEN, SPUT, SPUT$, SREADY
211
Contents Functions, Constants & Procedures
SPACE$ Example
Purpose CLS
Returns a blank string of the specified length. blank$ = SPACE$( 30 )
FOR i = 1 TO 20 LOOP
Syntax
PRINT i; blank$; i
blank$ = SPACE$( number )
REPEAT
Description END
Returns a string of blank spaces number characters
long.
Associated
ASC, CHR$, DATE$, DEFCHAR, GET$, LEFT$, LEN, MID$,
NUMFORMAT, PRINT, PRINTAT, RIGHT$, SPACE$, STR$,
TIME$, VAL
212
Contents Functions, Constants & Procedures
SPLINE Example
FONTSIZE (1)
xpoint1 = (GWIDTH / 10) * 4
Purpose
xpoint2 = (GWIDTH / 10) * 6
Interpolate a smooth curve between two points top = (GHEIGHT / 10) * 8
Syntax LOOP
CLS2
value = SPLINE (start, point1, point2, end, controlPoint)
FOR sp = 0 TO 1 STEP 0.1 LOOP
bottom = MOUSEY
Description xStart = GWIDTH / 2 - ABS (GWIDTH / 2 - MOUSEX)
Creates a smooth curve passing through or near to, a xEnd = GWIDTH / 2 + ABS (GWIDTH / 2 - MOUSEX)
specified number of points. ‘start’ indicates where the x = SPLINE (xStart, xpoint1, xpoint2, xEnd, sp)
curve has come from; points 1 and 2 are the points the y = SPLINE (bottom, top, top, bottom, sp)
curve will pass through (or near depending on the start COLOUR = RED
and end points) and ‘end’ is where the curve would end. CIRCLE (x, y, 5, 1)
COLOUR = LIGHTPINK
‘controlPoint’ is the distance along the curve specified by LINE (xStart, bottom, xpoint1, top)
a number between 0 (the beginning) and 1 (the end). LINE (xEnd, bottom, xpoint2, top)
Therefore to return the exact middle of the curve a PLOTTEXT ("X-Start", xStart, bottom)
control point of 0.5 would be used. PLOTTEXT ("Point 1", xpoint1, top)
PLOTTEXT ("Point 2", xpoint2, top)
Associated PLOTTEXT ("X-End", xEnd, bottom)
LERP REPEAT
UPDATE
REPEAT
213
Contents Functions, Constants & Procedures
SPRITECENTRE Example
logo = NEWSPRITE ( 1 )
Purpose hand = NEWSPRITE ( 1 )
Sets the anchor point of a sprite to its centre LOADSPRITE ("hand1.png", hand, 0 )
SPRITECENTRE ( hand )
Syntax
LOADSPRITE ("fuzelogo.png", logo, 0 )
SPRITECENTRE( sprite )
LOOP
Description PLOTSPRITE ( logo, MOUSEX, MOUSEY, 0 )
Use to set the origin of a specified sprite to its exact PLOTSPRITE ( hand, MOUSEX, MOUSEY, 0 )
centre. IF LEFTCLICK THEN
SPRITECENTRE ( logo )
ELSE
IF RIGHTCLICK THEN
SETSPRITEORIGIN ( logo, 0, 0 )
ENDIF
ENDIF
UPDATE
REPEAT
Associated
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE,
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY,
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE,
SETSPRITEALPHA, SETSPRITEANGLE, SETSPRITEFLIP,
SETSPRITEORIGIN, SETSPRITESIZE, SPRITECOLLIDE,
SPRITECOLLIDEPP, SPRITEOUT
214
Contents Functions, Constants & Procedures
SPRITECOLLIDE Example
CLS
COLOUR = YELLOW
Purpose
CIRCLE (100, 100, 50, TRUE)
Detect a sprite collision (fast bounding box)
SAVEREGION ("s1.bmp", 50, 50, 100, 100)
Syntax COLOUR = Red
collision = SPRITECOLLIDE( target ) CIRCLE (100, 100, 50, TRUE)
SAVEREGION ("s2.bmp", 50, 50, 100, 100)
Description
CLS2
Returns the sprite index of the first sprite that the sprite s1 = NEWSPRITE (1)
index target has collided with, or -1 if there is no s2 = NEWSPRITE (1)
collision. It only checks the current sprite location and LOADSPRITE ("s1.bmp", s1, 0)
this is only updated after a screen update LOOP so it is LOADSPRITE ("s2.bmp", s2, 0)
possible to call PLOTSPRITE() and have a sprite overlap FOR X = 0 TO GWIDTH STEP 1 LOOP
but it not be detected until after the update has
PLOTSPRITE (s1, X, 200, 0)
happened on screen.
PLOTSPRITE (s2, GWIDTH - X - 100, 200, 0)
IF SPRITECOLLIDE (s2) <> -1 THEN
PRINT "COLLIDED!"
END
Associated
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE, ENDIF
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY, UPDATE
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE, WAIT (0.01)
SETSPRITEALPHA, SETSPRITEANGLE, SETSPRITEFLIP,
SETSPRITEORIGIN, SETSPRITESIZE, SPRITECOLLIDE, REPEAT
SPRITECOLLIDEPP, SPRITEOUT END
215
Contents Functions, Constants & Procedures
SPRITECOLLIDEPP Example
CLS
COLOUR = YELLOW
Purpose
CIRCLE( 100, 100, 50, TRUE )
Detect a sprite collision (pixel perfect) SAVEREGION( "s1.bmp", 50, 50, 101, 101 )
Syntax COLOUR = RED
collision = SPRITECOLLIDEPP( target, accuracy ) CIRCLE( 100, 100, 50, TRUE )
SAVEREGION( "s2.bmp", 50, 50, 101, 101 )
Description CLS2
This is a slower but more accurate version of s1 = NEWSPRITE( 1 )
SPRITECOLLIDE. It first does do a simple bounding box s2 = NEWSPRITE( 1 )
test then checks row at a time. The accuracy parameter LOADSPRITE( "s1.bmp", s1, 0 )
is how many pixels to skip both horizontally and LOADSPRITE( "s2.bmp", s2, 0 )
vertically. This is from 1 to 16, where 1 is "perfect" and FOR x = 0 TO GWIDTH LOOP
greater than 1 is less accurate, but faster. This will affect PLOTSPRITE( s1, x, 200, 0 )
the amount of visible overlap you get before a collision PLOTSPRITE( s2, GWIDTH - x - 100, 200, 0 )
is detected. IF SPRITECOLLIDEPP (s2, 8) <> -1 THEN
PRINT "COLLIDED!"
END
Associated ENDIF
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE, UPDATE
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY, WAIT (0.01)
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE,
SETSPRITEALPHA, SETSPRITEANGLE, SETSPRITEFLIP, REPEAT
SETSPRITEORIGIN, SETSPRITESIZE, SPRITECOLLIDE, END
SPRITECOLLIDEPP, SPRITEOUT
216
Contents Functions, Constants & Procedures
SPRITEOUT Example
Associated
ADVANCESPRITE, CLONESPRITE, GETSPRITEANGLE,
GETSPRITEH, GETSPRITEW, GETSPRITEX, GETSPRITEY,
HIDESPRITE, LOADSPRITE, NEWSPRITE, PLOTSPRITE,
SETSPRITEALPHA, SETSPRITEANGLE, SETSPRITEFLIP,
SETSPRITEORIGIN, SETSPRITESIZE, SPRITECOLLIDE,
SPRITECOLLIDEPP, SPRITEOUT
217
Contents Functions, Constants & Procedures
SPUT Example
Associated
SCLOSE, SGET, SGET$, SOPEN, SPUT, SPUT$, SREADY
218
Contents Functions, Constants & Procedures
SPUT$ Example
Associated
SCLOSE, SGET, SGET$, SOPEN, SPUT, SPUT$, SREADY
219
Contents Functions, Constants & Procedures
SQRT Example
CLS
Purpose
Return the square root of the specified number. FONTSIZE (3)
INK= GREEN
Syntax PRINT "foursquared = 4 * 4"
squareroot = SQRT( number ) foursquared = 4 * 4
Description PRINT
Returns the square root of the argument number. This is INK=LIGHTPINK
the opposite of multiplying a number by itself i.e. X = PRINT "The Squareroot of foursquared is ";SQRT( foursquared )
SQRT(X * X). END
220
Contents Functions, Constants & Procedures
SREADY Example
Associated
SCLOSE, SGET, SGET$, SOPEN, SPUT, SPUT$, SREADY
221
Contents Functions, Constants & Procedures
STOP Example
Purpose CLS
Stop a running program. FONTSIZE (3)
INK = WHITE
Syntax
INPUT "Enter the Password: ", pass$
STOP
IF pass$ <> "wibble" THEN
Description INK = RED
Program execution is stopped with a message PRINT "Password Incorrect"
indicating the current line number. END
ENDIF
INK = GREEN
PRINT "Password Correct"
END
Associated
CONT
222
Contents Functions, Constants & Procedures
STOPCHAN Example
channel = 0
Purpose
Stop the playing of a sound sample. volume = 70
SETCHANVOL( channel, volume )
Syntax intro = LOADSAMPLE( "senemy.wav" )
STOPCHAN( handle ) PLAYSAMPLE( intro, channel, 999 )
Description WAIT( 1 )
This function stops the playing of the sound sample STOPCHAN( intro )
associated with the handle returned by LOADSAMPLE END
that has been started using PLAYSAMPLE. It cannot be
resumed once stopped.
Associated
LOADMUSIC, LOADSAMPLE, PAUSEMUSIC, PLAYMUSIC,
PLAYSAMPLE, RESUMECHAN, RESUMEMUSIC,
SETMUSICVOL, STOPCHAN, STOPMUSIC
223
Contents Functions, Constants & Procedures
STOPMUSIC Example
Purpose channel = 0
Stop music playing completely. volume = 70
SETCHANVOL( channel, volume )
Syntax
intro = LOADMUSIC( "neon.mp3" )
STOPMUSIC
PLAYMUSIC( intro, channel )
Description WAIT( 1 )
Stops a playing music track which cannot then be STOPMUSIC
resumed. END
Associated
LOADMUSIC, LOADSAMPLE, PAUSEMUSIC, PLAYMUSIC,
PLAYSAMPLE, RESUMECHAN, RESUMEMUSIC,
SETMUSICVOL, STOPCHAN, STOPMUSIC
224
Contents Functions, Constants & Procedures
STR$ Example
Syntax
string$ = STR$( number )
Description
Returns a string in the decimal (base 10) representation
of number. This is useful if you want to append a
number to a string. This is the opposite of the VAL
function.
Associated
ASC, CHR$, DATE$, DEFCHAR, GET$, LEFT$, LEN, MID$,
NUMFORMAT, PRINT, PRINTAT, RIGHT$, SPACE$, STR$,
TIME$, VAL
225
Contents Functions, Constants & Procedures
SWAP Example
CLS
FONTSIZE(3)
Purpose lowest = 99
Swap the value of two variables. highest = 0
INK=LIGHTGREEN
Syntax
PRINT "Lowest "; lowest
SWAP( value1, value2 )
PRINT "Highest "; highest
Description WAIT (1)
This swaps the value of the 2 variables round. Both PRINT
INK=RASPBERRY
arguments must be the same type - i.e. Both numeric or
PRINT "Wait, that's not right, one second please."
both string. WAIT (1.5)
IF lowest > highest THEN SWAP( highest, lowest )
INK = LIGHTGREEN
PRINT
PRINT "Lowest "; lowest
PRINT "Highest "; highest
WAIT(1)
INK=RASPBERRY
PRINT
PRINT "There.. much better!"
Associated END
MIN, MAX
226
Contents Functions, Constants & Procedures
TAN Example
Purpose DEG
Return the tangent of the given angle. PRINT "Tangent of 45 degrees: "; TAN( 45 )
PRINT "ArcTangent of 1: "; ATAN( 1 )
Syntax END
tangent = TAN( angle )
Description
Returns the tangent of the angle in the current angle
units. In a right-angled triangle the tangent of an angle
is the ratio of the length of the opposite side to the
length of the adjacent side. This is a measure of the
steepness of an angle.
Associated
ACOS, ASIN, ATAN, COS, CLOCK, DEG, PI, PI2, RAD, SIN,
TAN
228
Contents Functions, Constants & Procedures
TANGLE Example
CLS
Purpose
Read or set the current angle of the turtle. ORIGIN (GWIDTH / 2, GHEIGHT / 2)
CLOCK
Syntax COLOUR = LIGHTBROWN
angle = TANGLE FOR i = 1 TO 60 LOOP
TANGLE = angle TANGLE = i
Description MOVETO (0, 0)
This can be read or assigned to and represents the PENDOWN
current angle of the turtle when using turtle graphics MOVE (100)
mode (in the current angle units) REPEAT
END
Associated
LEFT, MOVE, MOVETO, PENDOWN, PENUP, RIGHT,
TANGLE
229
Contents Functions, Constants & Procedures
CLS
Purpose
text$ = "This text is centred in the screen"
The height and width in characters of the display.
PRINTAT (( TWIDTH - LEN( text$ )) / 2, THEIGHT / 2 ); text$
Syntax END
height = THEIGHT
width = TWIDTH
Description
Returns the text character height and width of the
display.
Associated
HTAB, HVTAB, INK, FONTSIZE, NUMFORMAT, PAPER,
PAPEROFF, PAPERON, PLOTTEXT, PRINTAT, PRINT,
TWIDTH, THEIGHT, VTAB
230
Contents Functions, Constants & Procedures
TIME Example
Associated
MICROTIME
231
Contents Functions, Constants & Procedures
TIME$ Example
Description
This returns a string with the current time in the
following format: HH:MM:SS. For example: 18:05:45.
Associated
ASC, CHR$, DATE$, DEFCHAR, GET$, LEFT$, LEN, MID$,
NUMFORMAT, PRINT, PRINTAT, RIGHT$, SPACE$, STR$,
TIME$, VAL
232
Contents Functions, Constants & Procedures
TONE Example
Purpose channel = 1
Play a tone with the specified parameters. volume = 70
FOR note = 1 TO 5 LOOP
Syntax READ frequency, duration
TONE( channel, volume, frequency, duration ) TONE( channel, volume, frequency, duration )
Description REPEAT
This plays a simple tone of the given frequency (1 to END
5000Hz), volume (%) and duration (0.01 to 20 seconds) DATA 440, 1, 493, 1, 392, 1, 196, 1, 294 ,2
on the given channel.
233
Contents Functions, Constants & Procedures
TRIANGLE Example
Purpose LOOP
Draw a triangle on the screen. COLOUR = RND( 30 )
x1 = RND( GWIDTH )
Syntax x2 = RND(GWIDTH )
TRIANGLE ( xpos1, ypos1, xpos2, ypos2, xpos3, ypos3, fill) x3 = RND(GWIDTH )
Description y1 = RND(GHEIGHT )
Draws a triangle with its corners at the three given y2 = RND(GHEIGHT )
points. The final parameter, fill is either TRUE or FALSE, y3 = RND(GHEIGHT )
and specifies filled (TRUE) or outline (FALSE). f = RND( 2 )
TRIANGLE ( x1, y1, x2, y2, x3, y3, f )
UPDATE
IF INKEY <> -1 THEN BREAK
REPEAT
END
Associated
CIRCLE, COLOUR, ELLIPSE, HLINE, LINE, LINETO, PLOT,
PLOTTEXT, POLYEND, POLYPLOT, POLYSTART,
RGBCOLOUR, RECT, SETALPHA, TRIANGLE, VLINE
234
Contents Functions, Constants & Procedures
TRUE Example
Associated
FALSE
235
Contents Functions, Constants & Procedures
UPDATEMODE Example
Purpose CLS
Set the video update mode. INPUT "Update Mode? ", mode
IF mode >= 0 AND mode <= 2 THEN
Syntax
PRINT "Press space to exit"
UPDATEMODE = mode
WAIT( 1 )
Description UPDATEMODE = mode
UPDATEMODE determines when the screen is redrawn. LOOP
Redrawing the screen takes a little time and will slow PRINT "Hello World ";
down a program if you do it too often. The value of the
REPEAT UNTIL INKEY = 32
mode parameter can be 0, 1, or 2 as follows:
UPDATE
0- automatic updates do not happen. Nothing will be
ELSE
drawn on the screen until UPDATE is issued.
PRINT "Invalid Update Mode"
1-This is the default mode whereby an UPDATE
happens automatically when you output a new line, or ENDIF
the screen scrolls. WAIT( 1 )
2-The screen is updated after every PRINT instruction END
whether it takes a new line or not.
Associated
CLS, CLS2, UPDATE, UPDATEMODE, UPDATEREGION
236
Contents Functions, Constants & Procedures
REM Print 1 to 10
Purpose
count = 1
Loop until the specified condition is met.
UNTIL count > 10 LOOP
Syntax PRINT count
UNTIL condition LOOP count = count + 1
{statements} REPEAT
REPEAT END
Description
Execute the statements zero or more times until the
condition is TRUE (Not 0).
Because the test is done at the start of the loop the
statements may not be executed at all
Associated
BREAK, CONTINUE, LOOP, LOOP REPEAT, FOR REPEAT,
REPEAT UNTIL, UNTIL REPEAT, WHILE REPEAT
237
Contents Functions, Constants & Procedures
UPDATE Example
REM Moire patterns
Purpose LOOP
Update screen graphics. CLS
Syntax COLOUR = RND( 30 ) + 1
UPDATE
x = RND( GWIDTH )
Description y = RND( GHEIGHT )
Graphics are drawn to a temporary screen buffer rather than
the visible screen. The UPDATE command copies the working FOR w = 0 TO GWIDTH - 1 STEP 3 LOOP
area to the main display. An update is also performed if your LINE( x, y, w, 0 )
program stops for input, or when you PRINT a new line.
LINE( x, y, w, GHEIGHT - 1 )
REPEAT
FOR h = 0 TO GHEIGHT-1 STEP 3 LOOP
LINE( x, y, 0, h )
LINE( x, y, GWIDTH - 1, h )
REPEAT
UPDATE
REPEAT
END
Associated
CLS, CLS2, UPDATE, UPDATEMODE, UPDATEREGION
238
Contents Functions, Constants & Procedures
UPDATEREGION Example
CLS
Purpose LOCKMOUSE (TRUE)
Update a region of the screen. boxsize = 50
Syntax LOOP
UPDATEREGION (x, y, width, height ) rx = MOUSEX
Description ry = MOUSEY
Restricts the screen update to a specified rectangular area. IF LEFTCLICK AND boxsize > 10 THEN
This can really aid performance especially with games
programming. If only a portion of your screen contains boxsize = boxsize - 1
moving graphics then updating this are only will increase ENDIF
performance.
IF RIGHTCLICK AND boxsize < gHeight - MOUSEY THEN
boxsize = boxsize + 1
ENDIF
IF MOUSEX > GWIDTH - boxsize THEN rx = GWIDTH - boxsize
IF MOUSEY > GHEIGHT - boxsize THEN ry = GHEIGHT - boxsize
IF MIDDLECLICK THEN UPDATE
COLOUR = RND (30)
CIRCLE (RND (GWIDTH), RND (GHEIGHT), RND (100), 1)
COLOUR = WHITE
RECT (rx, ry, boxsize, boxsize, 0)
Associated
UPDATEREGION (rx, ry, boxsize, boxsize)
CLS, CLS2, UPDATE, UPDATEMODE, UPDATEREGION
REPEAT
239
Contents Functions, Constants & Procedures
VAL Example
Associated
ASC, CHR$, DATE$, DEFCHAR, GET$, LEFT$, LEN, MID$,
NUMFORMAT, PRINT, PRINTAT, RIGHT$, SPACE$, STR$,
TIME$, VAL
240
Contents Functions, Constants & Procedures
VLINE Example
CLS
Purpose FOR xpos = 0 TO GWIDTH STEP 100 LOOP
Draws a vertical line. COLOUR=RED
VLINE( 0, GHEIGHT, xpos-1 )
Syntax
COLOUR=LIGHTPINK
VLINE ( ypos1, ypos2, xpos )
VLINE( 0, GHEIGHT, xpos )
Description COLOUR=RED
Draws a vertical line on column xpos, from row ypos1 to VLINE( 0, GHEIGHT, xpos+1 )
row ypos2. UPDATE
REPEAT
END
Associated
CIRCLE, COLOUR, ELLIPSE, HLINE, LINE, LINETO, PLOT,
PLOTTEXT, POLYEND, POLYPLOT, POLYSTART,
RGBCOLOUR, RECT, SETALPHA, TRIANGLE, VLINE
241
Contents Functions, Constants & Procedures
WAIT Example
242
Contents Functions, Constants & Procedures
WHEELDOWN Example
Purpose UPDATEMODE = 0
Returns TRUE if the mouse wheel is scrolled down FONTSIZE (4)
LOOP
Syntax
CLS2
value = WHEELDOWN
INK = LIGHTBLUE
Description PRINTAT (0, 0); "Mouse status"
Returns a value of 0 or 1 (TRUE or FALSE) depending on INK = RASPBERRY
whether it is press or not. PRINTAT (0, 2); "Left button="; LEFTCLICK
PRINTAT (0, 3); "Middle button="; MIDDLECLICK
PRINTAT (0, 4); "Right button="; RIGHTCLICK
PRINTAT (0, 5); "Wheel up="; WHEELUP
PRINTAT (0, 6); "Wheel down="; WHEELDOWN
UPDATE
REPEAT
Associated
MOUSEOFF, MOUSEON, MOUSEX, MOUSEY, MOUSEBUTTON,
GETMOUSE, SETMOUSE, LEFTCLICK, MIDDLECLICK ,
RIGHTCLICK, WHEELUP, WHEELDOWN, LOCKMOUSE
243
Contents Functions, Constants & Procedures
WHEELUP Example
Purpose UPDATEMODE = 0
Returns TRUE if the mouse wheel is scrolled up FONTSIZE (4)
LOOP
Syntax
CLS2
value = WHEELUP
INK = LIGHTBLUE
Description PRINTAT (0, 0); "Mouse status"
Returns a value of 0 or 1 (TRUE or FALSE) depending on INK = RASPBERRY
whether it is press or not. PRINTAT (0, 2); "Left button="; LEFTCLICK
PRINTAT (0, 3); "Middle button="; MIDDLECLICK
PRINTAT (0, 4); "Right button="; RIGHTCLICK
PRINTAT (0, 5); "Wheel up="; WHEELUP
PRINTAT (0, 6); "Wheel down="; WHEELDOWN
UPDATE
REPEAT
Associated
MOUSEOFF, MOUSEON, MOUSEX, MOUSEY, MOUSEBUTTON,
GETMOUSE, SETMOUSE, LEFTCLICK, MIDDLECLICK ,
RIGHTCLICK, WHEELUP, WHEELDOWN, LOCKMOUSE
244
Contents Functions, Constants & Procedures
Associated
BREAK, CONTINUE, LOOP, LOOP REPEAT, FOR REPEAT,
REPEAT UNTIL, UNTIL REPEAT, WHILE REPEAT
245
Contents
246
Contents
INK = BRIGHTGREEN
Joystick and Gamepad PRINTAT (but * 3, 6); "#"; but
INK = YELLOW
Example
UPDATEMODE = 0 PRINTAT (but * 3, 7); GETBUTTON (0, but)
FONTSIZE (3) REPEAT
SETUPGAMEPAD (0) INK = ORANGE
LOOP PRINTAT (0, 9); "Analog states"
CLS2 FOR ax = 0 TO NUMAXES (0) - 1 LOOP
INK = ORANGE INK = BRIGHTGREEN
PRINTAT (0, 0); "The detected joystick has" PRINTAT (ax * 8, 10); "#"; ax
INK = BRIGHTGREEN INK = YELLOW
PRINTAT (0, 1); "Buttons: "; PRINTAT (ax * 8, 11); GETAXIS (0, ax)
INK = YELLOW REPEAT
PRINT NUMBUTTONS (0) - 1 INK = ORANGE
INK = BRIGHTGREEN PRINTAT (0, 13); "Digital pad states"
PRINTAT (0, 2); "Analog Sticks & Triggers: "; FOR hat = 0 TO NUMHATS (0) - 1 LOOP
INK = YELLOW INK = BRIGHTGREEN
PRINT NUMAXES (0) PRINTAT (hat * 3, 14); "#"; hat
INK = BRIGHTGREEN INK = YELLOW
PRINTAT (0, 3); "Digital pads: "; PRINTAT (hat * 3, 15); GETHAT (0, hat)
INK = YELLOW REPEAT
PRINT NUMHATS (0) UPDATE
INK = ORANGE REPEAT
PRINTAT (0, 5); "Button states" PRINT
FOR but = 0 TO NUMBUTTONS (0) - 1 LOOP END
247
Contents ScanKeyboard values
248
Contents
If you only have one device attached then this is not mbRECT( x1, y1, w, h, brightness, fill )
required and the SETDEVICE statement is redundant. Draws a rectangle from x1, y1 with a width (w) and height (h)
Otherwise SETDEVICE must be used before switching to with a brightness between 0 (off) and 255. The ‘fill’ can be 0
a different device. (empty) or 1 (filled in)
mbBUTTONA
Returns the value of the micro:bit button A:
0 = not pressed 1 = pressed
mbBUTTONB
Returns the value of the micro:bit button B:
249
Contents
value = mbTEMP
Using the BBC micro:bit Returns the micro:bit’s internal CPU temperature in degrees
centigrade
0 = not pressed 1 = pressed
value = mbGESTURE
MbTouch( pin ) Returns a value depending on the physical position of the BBC
Returns the capacitive value of the specified pin (0, 1 or 2) micro:bit. Values are as follows;
mbTiltUp = 1
value = mbCOMPASSHEADING
mbTiltDown = 2
Returns the value of the micro:bit internal compass in degrees
between 0 (north) and 359. mbTiltLeft = 3
mbTiltRight= 4
value = mbCOMPASSX / Y / Z mbFaceup = 5
Returns the compass X, Y and Z values. mbFacedown = 6
mbFreefall = 7
value = mbCOMPASSFIELDSTRENGTH mbshake = 11
Returns the compass magnetic field value
250
Contents
FUZE BASIC
fuze.co.uk
253