Getting started

Your first five minutes

New to basicFusion? This short guide takes you from a blank screen to your first moving pixels. No installing, no setup. Just open the editor and type along. When you want the full command list, head to Documentation.

1

Open the editor

Go to Create, click Create New Project, give it a name, and the editor opens. Type code on the left, then press the Run button to see what it does. You will be doing that a lot: write a bit, run it, look at what happened.

2

Say hello

Every program can start with one line. PRINT writes text to the screen.

hello.bf
PRINT "HELLO, WORLD!"

→ HELLO, WORLD!

3

Store things in variables

A variable is a named box that holds a value. You make one just by assigning to it. No special keyword needed. Numbers go in plain names; text goes in names that end with a $.

vars.bf
SCORE = 100          ' a number
NAME$ = "Ada"        ' text ends with $

PRINT NAME$
PRINT SCORE + 1

→ Ada
→ 101

Rule of thumb: if it ends in $ it holds text, otherwise it holds a number. So LIVES is a number and TITLE$ is a word.
4

Turn on graphics mode

SCREEN switches from text to a pixel canvas that you size with a width and height. CLS clears it. Then you can draw: shapes take an (x, y) position and a colour written as text.

draw.bf
SCREEN 320, 180     ' a 320x180 canvas
CLS
CIRCLE (160, 90), 40, "magenta"
PSET (160, 90), "cyan"

→ a magenta circle with a single cyan pixel in the middle

Colours can be names like "cyan" or "magenta", or built from numbers with RGB(r, g, b) when you want an exact shade.
5

Repeat with a loop

A FOR ... NEXT loop runs the same lines over and over, counting as it goes. STEP sets how much the counter jumps each time. Here it draws a set of rings.

rings.bf
SCREEN 320, 180
CLS
FOR R = 8 TO 80 STEP 8
  CIRCLE (160, 90), R, "cyan"
NEXT R

→ ten cyan rings growing outward from the centre

6

Make a decision

IF ... THEN only runs something when a condition is true. This is how games check for a win, a collision, or in this case a game over.

check.bf
LIVES = 0

IF LIVES = 0 THEN PRINT "GAME OVER"

→ GAME OVER

7

Smooth animation: FASTGRAPHICS & SYNC

When you animate, you clear and redraw the whole screen dozens of times a second. If every shape appears the instant it is drawn, the picture flickers, because you catch it half-finished. FASTGRAPHICS fixes that: it turns on double buffering, so your drawing goes onto a hidden page nobody can see yet.

Nothing shows until you call SYNC. It flips the finished page onto the screen in one go, clears the hidden page for the next frame, and paces the loop to a steady frame rate. So the recipe for any animation or game is always the same three parts:

pulse.bf
SCREEN 320, 180     ' 1. size the canvas
FASTGRAPHICS          ' 2. turn on double buffering (once)

r = 10
DO                    ' 3. draw a frame, then SYNC - forever
  CLS
  CIRCLE (160, 90), r, "cyan"
  r = r + 2
  IF r > 90 THEN r = 10
  SYNC
LOOP

-> a ring that grows and restarts, perfectly smooth

Remember it as draw, then SYNC. Leave out FASTGRAPHICS and you see every half-drawn step; add it and each frame appears whole. The same trick powers demoscene effects, sprites and full games.
8

Modern shortcuts (all optional)

basicFusion keeps the classic style, but you can also write in a looser, more modern way. None of it is required, so pick whichever version reads better to you.

  • No type sigils. A variable appears as soon as you assign to it, so there is no DIM, and text works fine without a $ at the end.
  • Call like a function. You can run a SUB by writing name(). The old CALL name still works too.
  • Colour as an argument. Instead of setting a colour first, you can pass it straight in: CIRCLE(x, y, colour).
  • C-style maths. Shorthands like x += 1 (also -=, *=, /=) instead of x = x + 1.
modern.bf
score = 0              ' no DIM, no type, just assign
score += 10            ' C-style: += -= *= /=
name = "Ada"           ' text without a $ sigil

SUB boom()
    CIRCLE(120, 80, "cyan")  ' colour as the 3rd argument
END SUB

boom()                ' call with (), no CALL needed
Old and new styles mix freely in the same program. Write TITLE$ or just title, CALL boom or boom(). Both are fine.

Fun examples to copy, run and remix

Paste any of these into a new project and press Run. Change the numbers, swap the colours, break things and see what happens. Every command here is explained in full in the Documentation.

graphics

A colour gradient

Two loops walk every pixel and colour it with RGB. Your first full-screen image.

gradient.bf
SCREEN 320, 180
FOR y = 0 TO 179
  FOR x = 0 TO 319
    PSET (x, y), RGB(x, y, 128)
  NEXT x
NEXT y
demoscene

An animated sine wave

SIN plus TIMER makes it move; SYNC shows each frame. A classic scene effect in a few lines.

wave.bf
SCREEN 320, 180
FASTGRAPHICS
DO
  CLS
  FOR x = 0 TO 319
    y = 90 + SIN(x / 18 + TIMER * 3) * 60
    PSET (x, y), "cyan"
  NEXT x
  SYNC
LOOP
tiny game

A bouncing ball

Move it a little each frame, flip direction at the walls. It is the basis of almost every game.

bounce.bf
SCREEN 320, 180
FASTGRAPHICS
x = 40
y = 30
dx = 3
dy = 2
DO
  CLS
  x = x + dx
  y = y + dy
  IF x < 8 OR x > 312 THEN dx = -dx
  IF y < 8 OR y > 172 THEN dy = -dy
  CIRCLE (x, y), 8, "magenta"
  SYNC
LOOP
text & strings

Play with words

Measure, upper-case and slice text. $ names hold words; MID$ pulls out one letter.

words.bf
NAME$ = "basicFusion"
PRINT "Length:  "; LEN(NAME$)
PRINT "Shout:   "; UCASE$(NAME$)
PRINT "First 5: "; LEFT$(NAME$, 5)
PRINT "Backwards:"
FOR i = LEN(NAME$) TO 1 STEP -1
  PRINT MID$(NAME$, i, 1);
NEXT i
maths

Numbers & dice

A times table, a random dice roll with RND, and a square root. Great for homework helpers.

maths.bf
PRINT "7 times table:"
FOR n = 1 TO 10
  PRINT "7 x "; n; " = "; 7 * n
NEXT n
PRINT "Dice roll: "; INT(RND() * 6) + 1
PRINT "Root of 144: "; SQR(144)
for kids

Draw a smiley

A big head, two eyes, and a curved smile drawn dot by dot. Change the colours and make it yours.

smiley.bf
SCREEN 200, 200
CIRCLE (100, 100), 80, "yellow"
CIRCLE (72, 80), 9, "white"
CIRCLE (128, 80), 9, "white"
FOR a = 20 TO 160
  x = 100 + COS(a * PI / 180) * 50
  y = 115 + SIN(a * PI / 180) * 40
  PSET (x, y), "red"
NEXT a

The essentials, at a glance

PRINT "text"Write text or a number to the screen.
NAME = 5Store a number in a variable.
NAME$ = "hi"Store text. The name ends with $.
SCREEN w, hSwitch to a pixel canvas of that size.
CLSClear the screen.
PSET (x, y), "col"Light up a single pixel.
CIRCLE (x, y), r, "col"Draw a circle at (x, y) with radius r.
FOR i = 1 TO 10 ... NEXT iRepeat lines, counting from 1 to 10.
IF cond THEN ...Run something only when the condition is true.