Dofi Fantasy Console

Poyo's Guide to Dofi

Getting Started

Welcome to the Dofi Fantasy Console! This is a retro-style programming environment inspired by classic 8-bit computers.

Basic Syntax

The Balena language uses a simple, Lox-inspired syntax:

// Variables
var x = 10; // Declare a variable
var message = "Hello, World!"; // Declare a variable
// Functions
fun greet(name) { // Define a function
print "Hello World!"; // Print a message
}

if (x > 5) {
print("x is greater than 5"); // Print a message if x is greater than 5
}
                    

Drawing Pixels

// Set a pixel at (x, y) to a specific color
pset(x, y, r, g, b);
                    

Math Functions

Useful mathematical functions:

// Trigonometric functions
sin(angle);
cos(angle);
floor(number); // floor function
sqrt(x * x + y * y)
                    

Game Loop Structure

Most games follow this pattern:

// Initialize game state
fun _init() {
var player_x = 64;
var player_y = 64;
}
// Update game logic (called every frame)
fun _update() {
// Update game state
}
// Draw everything (called every frame)
fun _draw() {
cls();
pset(x, y, 0, 255, 0);
}
                    

Tips & Keybinds

  • Use cls() at the start of _draw() to clear the screen
  • Keep your game loop efficient - avoid heavy calculations in _draw()
  • Use _update() for calculating heavy stuff
  • Store frequently used values in variables to improve performance
  • Use pset(x, y, r, g, b) to draw pixels
  • Use print {variable} for debugging
  • Use Ctrl+R to run the code in the editor
  • Press ESC to switch from the CLI to the editor, and viceversa