The Grownup Guide to Bitsbox

First Things First Info for Educators

Red Racer

Example app for teaching kids to code showing a parking lot and a car that can be driven by dragging it around the screen

This app lets you drive a car by dragging your cursor on the screen.

1 fill('parking lot') {

Line 1 puts a background image of a parking lot on the screen.

2 size = 150

Line 2 creates a new variable called "size" and assigns it the value 150.

3 speed = 500

Line 3 creates a new variable called "speed" and assigns it the value 500.

4 c = stamp('car8',size)

Line 4 stamps a car on the screen and assigns it the name "c".

5  

Line 5 is left blank to create visual spacing in the code.

6 function drag() {

Line 6 creates a new block of code called drag() which tells the app what to do when you drag your cursor on the screen.

7 c.move(x,y,speed)

Line 7 tells "c" (which is the car) to move.

8 c.aim(x,y)

Line 8 tells "c" (which is the car) to rotate until it's aimed at the spot where you're touching the screen.

9 }

Line 9 uses a curly bracket } to indicate that this is the end of the drag() function which started on line 6.