comments
// this is a comment
vars and types
var points = 100;
var amount = 4.20;
var enabled = true;
var name = 'shooty game';

typeof name == 'string';

// more: https://floaty.dev/r/vars-and-types
operators
// + - * / ^ % =
// += -= *= /= %= ^=
// < > <= >= == !=
// && || !
strings
var game = 'Mario Kart';
var platform = 'Wii';

text(game + ' ' + platform);
text(`${game} ${platform}`);
text(`${kills * 100} points`);

text(str, x, y, c);

// more: https://floaty.dev/r/strings
functions
function difference(x, y) {
    return x - y;
}

var result = difference(16, 12);
conditionals
if (position > 120) {
    position = 120;
} else {
    position += 1;
}
math functions
Math.sin(x);
Math.abs(1.1);
Math.floor(1.6);
Math.ceil(1.4);

// more: https://floaty.dev/r/math-functions

rnd(); // ← random float between 0 and 1
rnd(128); // ← random float between 0 and 128

engine.randomFloatBetween(min, max);
engine.randomIntegerBetween(min, max);
arrays
var particles = [];
particles.push(new Particle(6));
particles.push(new Particle(7));

particles.length == 2;

particles.pop(); // ← remove and return the last particle

var enemies = [1, 2, 3];

enemies.includes(2) == true;

enemies.map(function(number) {
    return number + 1;
});

enemies.filter(function(number) {
    return number % 2;
});

// more: https://floaty.dev/r/arrays
objects
var player = {
    x: 64,
    y: 64,
};

player.speed = 2;

Object.keys(player) == ['x', 'y', 'speed'];
Object.values(player) == [64, 64, 2];
Object.entries(player) == [['x', 64], ['y', 64], ...];

// more: https://floaty.dev/r/objects
loops
for (var i = 0; i < 10; i += 1) {
    text('number: ' + i);
}

for (var i = 0; i < enemies.length; i += 1) {
    text(`enemy: ${enemies[i]}`);
}

for (var value of enemies) {
    text(`value: ${value}`);
}

for (var key in abilities) {
    text(`key: ${key}`);
}

for (var [key, value] of Object.entries(abilities)) {
    text(`key: ${key}, value: ${value}`);
}
colors
  • 0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
pal(to, from);
pal();
cls(color = 0);
sprites
spr(
    key, x, y,
    [w = 1], [h = 1],
    [flipX = false], [flipY = false],
);

fget(key, flag);
fset(key, flag, value);
pixels
pget(x, y);
pset(x, y, color);
shapes
rect(x1, y1, x2, y2, color);
rectPixels(x1, y1, x2, y2);
rectFill(x1, y1, x2, y2, color);
rectFillPixels(x1, y1, x2, y2);

circ(x, y, r, color, [thickness = 1]);
circPixels(x, y, r, [thickness = 1]);
circFill(x, y, r, color);
circFillPixels(x, y, r);

line(x1, y1, x2, y2, color);
linePixels(x1, y1, x2, y2);

removeDuplicatePixels(pixels);
removeCornerPixels(pixels);
collisions
circlesCollide([x, y, r], [x, y, r]);
boxesCollide([l, t, r, b], [l, t, r, b]);
sounds
sfx(key);
controls
btn('a');
btnp('d');

btnp(); // ← any key

// more: https://floaty.dev/r/supported-keys