Level 1
Level 1
We might use the term object-oriented programming too. This describes how the code works.
An object is a package of operations and properties. For example, an object is like a dog. The
breed, size or color of the dog is a property and an operation would be when you tell it to sit,
bark or fetch. Small Basic helps you with this by color coding, as you’re about to see!
GraphicsWindow.DrawImage("https://aka.ms/mz1", 0, 0)
We have a maze for the turtle to run through! Let’s teleport the turtle to the top left of the
window, so we can start at the beginning of the maze. You know how we used 0s to make the
image start at the top left corner? We’re going to do something similar with the turtle, but
we’re going to set it down a little bit away from the top left corner. Let’s use 50 instead of 0.
We’re going to make sure the turtle is 50 pixels away from the left edge:
Turtle.X = 50
and 50 pixels away from the top:
Turtle.Y = 50
Press to make sure the turtle is where you want it to be!
Turtle.TurnRight()
Turtle.Move(100)
Click the button at the top and see what the turtle does.
Oh no, it didn’t go far enough! Can you change how far the turtle moves until it looks like this?
Great! Now the turtle is ready to go down the next path. What does it have to do now? It has to
turn before it can keep going! Add another line of code at the bottom:
Turtle.TurnRight()
And then run it with the button to make sure the turtle is facing the correct direction.
Keep going- make the turtle move through the whole maze until it reaches the red flowers at
the bottom left!
CHALLENGE: Can you make the turtle do a celebration dance at the end?
Want to do something a little different? Here are some things you can try! Where do you think
you would put them in the code?
GraphicsWindow.DrawImage(
"https://aka.ms/mz2", 0, 0)
GraphicsWindow.DrawImage(
"https://aka.ms/mz3", 0, 0)
GraphicsWindow.DrawImage( GraphicsWindow.DrawImage(
"https://aka.ms/mz4", 0, 0) "https://aka.ms/mz5", 0, 0)
Lesson 6: Share your code!
In Small Basic, you can export a program so that other people with Small Basic can look at the
code, run it and edit it. Simply click the button in the top menu.
You’ll get a popup that looks like this:
The special code in blue is what you can share with your
friends who also use Small Basic. The link in purple is what
you can share with friends and family who don’t write
code; you can email or text it to them!
Click and type in “tetris” (all lowercase). The Tetris code appears!
Let’s run it and see what it looks like! The instructions are on the right. The Left and Right
arrows move it, Up rotates, and Down drops your piece. Do you see the title that says “Small
Basic Tetris”? Let’s change that!