Skip to content
FutureBlitz

    Install

    Guide

    Coming from Blitz3D

    Blitz3D's language mapped to FutureBlitz's, and where graphics and sound come from.

    FutureBlitz keeps Blitz3D’s plain words and programs that read from the top, and adds types, null safety, errors, generics, and threads. It isn’t source-compatible: a .bb file is translated, and this guide is that translation, part by part.

    The language, mapped

    Blitz3DFutureBlitz
    name$, hp%, speed#name: String, hp: Int, speed: Float, or inferred from the value
    Variables made by using themEvery variable declared with Local, Global, or Const
    Next, Wend, EndIfEnd For, End While, End If
    And, Or, Not&&, ||, !, which stop early, and &, |, ~ for bits
    Type with its global list, New, Each, DeleteA Class or Struct, kept in arrays and Maps you own, freed when nothing refers to it
    e\hpe.hp
    Print "hi"Print("hi"): calls always take parentheses
    "HP: " + hp"HP: {hp}"
    Dim grid(10, 10)Local grid: Int[11, 11], or an Int[] that grows
    Include "file.bb"Import, of a module
    .decls filesExtern blocks, or fb bindgen from a C header
    Goto, GosubLoops, Functions, and labeled Break and Continue
    Int, Float, and StringSized integers, Double, Bool, Char, tuples, Enums, and std.math’s vectors
    No error handlingThrows, Try, Catch, Finally, and panics with stack traces

    Keywords are PascalCase, as Blitz3D’s usual style wrote them, and case-sensitive: if is an ordinary name. When one written in another case breaks a line, the error says how it’s spelled.

    Types become Classes

    A Blitz3D Type is a record and a global list in one. In FutureBlitz the record is a Class, and the list is an array the program keeps, so there can be several, and nothing is in one by accident.

    Type Order
        Field item$, count%
    End Type
    
    o.Order = New Order
    o\item = "pears" : o\count = 0
    
    For o.Order = Each Order
        If o\count = 0 Then Delete o
    Next
    Import std.core
    Import std.collections
    
    Class Order
        Field item: String
        Field count: Int
    
        New(item: String, count: Int)
            Self.item = item
            Self.count = count
        End New
    End Class
    
    Local orders: Order[] = [Order("apples", 3), Order("pears", 0), Order("plums", 5)]
    orders.RemoveAll(Function(o: Order) => o.count == 0)
    For o In orders
        Print("{o.count} {o.item}")
    End For
    Output
    3 apples
    5 plums

    An object is freed the moment the last reference to it goes, so a removed order is gone without a Delete.

    Globals and Functions

    Top-level code is the program, as in Blitz3D. Its Locals are its own, and a Function sees the file’s Globals and Consts.

    Import std.core
    
    Const MAX_TRIES = 3
    Global tries = 0
    
    Function TryAgain(): Bool
        tries += 1
        Return tries < MAX_TRIES
    End Function
    
    While TryAgain()
        Print("try {tries}")
    End While
    Print("gave up after {tries}")
    Output
    try 1
    try 2
    gave up after 3

    Strings

    Strings take values in braces, with format specs after a colon. + joins Strings only, so a number goes in braces rather than being added.

    Import std.core
    
    Local total = 1500
    Local share = 0.875
    Print("Total: {total:,}   Share: {share:.1%}")
    Output
    Total: 1,500   Share: 87.5%

    Arrays

    Dim becomes an array type. An array knows its length, grows with Add, and is checked on every index, so an index out of range is a panic that names the line, not a crash.

    Import std.core
    Import std.collections
    
    Local scores: Int[] = [40, 75]
    scores.Add(90)
    scores.Sort()
    Print("{scores.Count} scores, best {scores[scores.Count - 1]}")
    Output
    3 scores, best 90

    Graphics and sound

    FutureBlitz is a general-purpose language. Its standard library draws on images, with std.image’s canvas and fonts, but has no windows, 3D rendering, or sound. A program that opens a window or plays sound uses a package for it, installed with fb add, or calls a C library directly, as Using a C library shows. The language, its tools, and the standard library are the same whichever one a program uses.

    Report an issue with this page or with FutureBlitz on GitHub.