Bitbop Manual
Make pictures, beats, games, and tools with JavaScript.
Start here
Turtle.reset();
while (true) {
Turtle.move(4);
sleep(50);
}
Use classic JavaScript with var and function () {}. Run starts fresh. Pause holds the program in place. Step runs one highlighted statement. The Console runs snippets in Global. After Step, it uses the current local scope.
Speaking JavaScript ↗ is an outside ES5 guide. It is written for adults and experienced programmers. Use the complete API reference for studio commands.
Workspace controls
| Control | What it does |
|---|---|
| Format | Makes Code easy to read in one edit. Undo reverses the whole change. |
| Wrap | Shows long lines on more than one screen line. Your code does not change. |
| Zoom | Makes Code text larger or smaller. |
| Examples | Opens one of four finished projects. Undo Example brings back your previous project. |
| File | Names the project, opens a .bop file, saves a copy, or makes a share link. |
| Panels | Shows or hides parts of the studio. |
Control Board
Board.buttonA.onPress(function () {
Turtle.home();
});
buttonA,buttonB,buttonC, andbuttonDprovideonPress,onRelease, and a Booleanvalue.toggleAandtoggleBprovideonChange(function (value) {})and a Boolean value.sliderAandsliderBprovideonChange(function (value) {})and values from 0 through 100.
Canvas, Turtle, and Paint
Canvas.onClick(function (event) {
console.log(event.x, event.y);
});
Canvasprovideswidth,height,onClick,onPress,onDrag, andonRelease. Adding a callback turns off finger painting until Stop or a fresh Run.Turtleprovidesreset,home,penDown,penUp,color,width,turn, andmove.Paintprovidesclear,stroke(points, options), andfill(x, y, color).- Canvas Clear clears both layers and returns Turtle home.
Music
Music.play('C4', 0.25, { type: 'triangle' });
sleep(250);
Music.play('E4', 0.25);
Music provides play, stop, stopAll, setInstrument, setVolume, and setEnvelope. Notes can be names such as C4, F#3, and Db5, or MIDI numbers.
Input and timing
prompt(message, defaultValue)asks for text. OK returns text; Cancel returnsnull.Keyboard.onPressandKeyboard.onReleaselisten to virtual-piano notes.sleep(milliseconds)pauses the current code path. UseInfinityto wait forever; callbacks still work and Step never waits.UI.show,UI.hide, andUI.isVisiblecontrol the code, controls, canvas, piano, and console panels.
Debugging
console.log, console.warn, and console.error write values to the Console. Add JavaScript's debugger; statement to pause on that Code line. The Console then uses that line's local scope. You can inspect or change variables before you Step or Resume. Start typing and press Tab or Enter to complete supported globals, nested members, parameters, locals, and known object members. Function completion supplies classic-JavaScript parentheses, argument stops, and callback skeletons. Resume and Stop clear the local scope and return the Console to Global.
if (mark === 17) {
debugger;
}
Use debugger; in Code, not in a Console snippet.
Errors highlight their source line. After Step, run a variable name in the Console to inspect its local value.