Skip to content
FutureBlitz

    Install

    Guide

    Coming from Blitz3D

    What stayed from Blitz3D, what changed and why, and how a .bb program's parts are written in FutureBlitz.

    FutureBlitz is a new language in Blitz3D’s spirit: plain words, programs that read from the top, and a main loop you write yourself. It isn’t source-compatible with Blitz3D, so a .bb file is translated rather than compiled. This page is what that translation looks like, by hand.

    What changed, at a glance

    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, EndIf, End FunctionEnd For, End While, End If, End Function
    And, Or, Not (bitwise, not short-circuit)&&, ||, !, which stop early, and &, |, ~ for bits
    Type with a global list, New, Each, DeleteClass or Struct with Methods, in arrays and Maps you own, freed by reference counting
    e\hpe.hp
    Print "hi", Graphics3D 800, 600Print("hi"): calls always take parentheses
    "HP: " + hp"HP: {hp}"
    Dim grid(10, 10)Local grid: Int[11, 11], or a dynamic Int[]
    Include "file.bb"Import, of a module; there’s no textual include
    .decls filesExtern blocks in your code, or fb bindgen from a C header
    Goto, GosubLoops, Functions, and labeled Break and Continue
    Int, Float, and String onlySized integers, Double, Bool, Char, tuples, Enums, and std.math’s vectors
    No error handlingThrows, Try, Catch, Finally, and panics with stack traces

    Keywords are case-sensitive and PascalCase, as Blitz3D’s usual style already wrote them; when one’s miscased, the compiler 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 Bullet
        Field x#, y#
        Field speed#
    End Type
    
    b.Bullet = New Bullet
    b\x = 10 : b\speed = 4
    
    For b.Bullet = Each Bullet
        b\x = b\x + b\speed
        If b\x > 100 Then Delete b
    Next
    Import std.core
    Import std.collections
    
    Class Bullet
        Field x: Float
        Field y: Float
        Field speed: Float
    
        New(x: Float, speed: Float)
            Self.x = x
            Self.speed = speed
        End New
    
        Method Update()
            x += speed
        End Method
    End Class
    
    Local bullets: Bullet[] = [Bullet(10, 4), Bullet(97, 4)]
    For b In bullets
        b.Update()
    End For
    bullets.RemoveAll(Function(b: Bullet) => b.x > 100)
    Print("{bullets.Count} bullet left, at x = {bullets[0].x}")
    Output
    1 bullet left, at x = 14

    An object is freed the moment the last reference to it goes, and its Destroy Method runs then, so a removed bullet is gone without a Delete.

    Globals and functions

    Top-level code is the program, as in Blitz3D. Its Locals belong to it alone, and a Function sees Globals and Consts, declared anywhere in the file.

    Import std.core
    
    Const MAX_LIVES = 3
    Global lives = MAX_LIVES
    
    Function LoseLife(): Bool
        lives -= 1
        Return lives > 0
    End Function
    
    While LoseLife()
        Print("lives left: {lives}")
    End While
    Print("game over")
    Output
    lives left: 2
    lives left: 1
    game over

    Strings

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

    Import std.core
    
    Local score = 1500
    Local accuracy = 0.875
    Print("Score: {score:,}   Accuracy: {accuracy:.1%}")
    Print("Score: " + "{score}")
    Output
    Score: 1,500   Accuracy: 87.5%
    Score: 1500

    The main loop

    Blitz3D’s frame loop, While Not KeyHit(1) ... Flip ... Wend, stays the shape of a game’s: a While that updates, draws, and calls Flip(). That comes with FutureBlitz’s engine, a separate library built after the language and its tools. What the language adds to the loop is coroutines, which Flip() resumes every frame, so a sequence of steps over many frames is one Async Function rather than a state machine (see concurrency).

    Moving a game over

    A tool to translate .bb code is planned for when the engine is done, since it maps Blitz3D’s engine commands to the engine’s: one pass for what’s mechanical (syntax, blocks, suffixes, Type to Class), and a second, reviewed by a person, for what needs judgment, like Goto and a Type’s global list. Until then, the table above is the translation.

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