Jump to:

- Core Functionality
- Game Engine
- Music Language
- Tutorial

# BooBoo Tutorial

This tutorial assumes you have some prior programming experience.

BooBoo is extremely easy to learn, and I'm not going to cover any API here, but only basic syntax. Refer to the docs for API.

BooBoo could be considered similar to a high-level assembly language. Everything starts with an opcode (function) followed by parameters. The only syntax identifying the end of one statement and the start of another is the presence of another API function:

    <func> <param1> <param2> <func2> <param1> <param2> <param3> <func3> <func4>

Everything between functions is slurped up and passed to the preceding function.

Functions can be defined:

    function derp
    {
    	call do_something
    }

And can return values:

    function derp2 a b c
    {
    	return (+ a b c)
    }
    ...
    var result
    call_result result derp2 32984 438 13

Expressions also use Polish notation (operation first) format. A C expression like:

    x = (x * (x + y))

Can be written as:

    = x (* x (+ x y))

Hello world:

    print "Hello, World!\n"

Hello world Game Launcher (red screen):

    function draw { clear 255 0 0 }

Loops:

You can do loops with the branch functions (je, jge, etc) but more commonly you can use a for loop:

    for <var> <start value> <expression> <increment> <label>

for example to loop to 10:

    var i
    for i 0 (< i 10) 1 again
    	print "%\n" i
    :again

Conditionals:

    if <expression> <label> <elseif-expression> <label> <else label>

for example:

    if (== i 10) ten (== i 9) nine below
    	print "TEN!\n"
    :ten
    	print "NINE!\n"
    :nine
    	print "BELOW NINE!\n"
    :below

You can define your own expression sub handlers. For example (== i 10) is an expression that evaluates to TRUE if i equals 10. You can define operators like ==:

    function times_7 x
    {
    	return (* x 7)
    }
    ...
    = foo (times_7 777)

Vectors and maps:

The docs have more info, but you can access vectors and maps with fishes. You can fish into a vector:

    [v x y z] ; this will dig into a few vectors to pull a value out

It's equivalent in C++ to:

    v[x][y][z]

Or a map:

    [m "foo" "bar" "baz"] ; this will dig into a few maps to pull out "baz"

Which is equivalent to m["foo"]["bar"]["baz"] in C++.

You can nest them:

    [v x y [m "foo" "bar" [v2 z]]]

In C++ that would be:

    v[x][y][m["foo"]["bar"][v2[z]]]

Or you can mix them with expressions:

    [v x y (+ z 1)]

These can be used anywhere a variable can be used.