Hi there! Welcome to our fun coding adventure with Code Monkey! Today, we’re going to learn about something called objects and how we can make them do cool things. We’ll also discover two new ways to make our monkey turn, and even how to make him walk backwards. Ready to dive in? Let’s go!
In our coding world, objects are everything you see and can interact with, like bushes, bridges, bananas, and turtles. Some objects can do special actions, like our monkey, who can step and turn. These actions are called functions, and the numbers we add to them are called arguments. For example, when we use the function step(10)
, the number 10
is the argument.
Now, let’s talk about turning. There are three ways to make an object turn:
We already know how to use turnRight
or turnLeft
. These are simple and direct ways to turn our monkey.
Another way to turn is by using degrees, like turn(45)
or turn(-90)
. But how do we know how many degrees to turn? Here’s a secret: our ruler is also a protractor! When we measure the distance from the monkey to the banana, it shows the angle, like 45
, which tells us how much the monkey needs to turn to face the banana. You can use this trick to measure angles from the monkey or the turtle.
The third way is using the function turnTo
. With turnTo
, you don’t need to use right, left, or numbers. This function figures out the direction to turn so the monkey faces another object, like a banana or a bridge. Just use the object’s name, and you’re set!
Now, let’s learn how to make the monkey walk backwards. When we want him to go forward, we type step(10)
. To make him go backwards, we type step(-10)
. The computer understands -10
as 10 steps in the opposite direction.
Here’s a neat trick: if you hover over any object on the stage, its name will appear next to it. If you click on the object, its name will be added to your code editor. This is super helpful if you don’t feel like typing!
Thanks for joining this tutorial! Now it’s your turn to practice turning and walking backwards. Just remember, if you try this in real life, watch out for bananas on the floor. Have fun and good luck!
turnTo
function simplifies the process of directing objects in a coding environment?Explore your surroundings and identify objects that could be part of a coding world, like bushes or bridges. Write down what actions these objects might perform if they were in a code, similar to how the monkey can step and turn.
Create a small obstacle course in your classroom. Use commands like turnRight
, turnLeft
, and step(10)
to navigate through it. Try using degrees to make precise turns and see how accurately you can follow the path.
Use a protractor to measure angles in the classroom. Practice turning by using degrees, just like the monkey does. Try turning to face different objects and see if you can get the angles right!
In a safe space, practice walking backwards by counting steps. Compare how it feels to walking forwards. Discuss how using negative numbers in coding can change the direction of movement.
Write a short story where you are the monkey. Use coding terms like step
and turnTo
to describe your journey. Share your adventure with the class and see how creative you can get!
Sure! Here’s a sanitized version of the YouTube transcript:
—
Hi, welcome back to our Code Monkey tutorials! Today, we will learn about objects and how to use them. We will also learn two new ways to make the monkey turn: how to make him walk backwards and a helpful trick. Ready? Here we go!
What are objects? Objects are everything in the scene we can interact with, like the bush, bridge, banana, and turtle. Some objects have a set of actions they can perform. For example, the monkey can step and turn. These actions are called functions, and the input we add to them is called an argument. For example, in the function `step(10)`, we have the argument `10`.
Now let’s talk about the function `turn`. There are three ways to make an object turn. The first way is to use `turnRight` or `turnLeft`, which we already know. A second way to turn is by using degrees, like `turn(45)` or `turn(-90)`. But how would you know how many degrees to turn? You ask! Well, our ruler is secretly also a protractor. When we measure the distance from the monkey to the banana, it also shows the number `45`, which is the angle the monkey has to turn in order to face the banana. You can use the ruler to measure degrees from the monkey or from the turtle.
The third and final way to turn is by using the function `turnTo`. When using `turnTo`, we don’t need to use `right`, `left`, or a number. The `turnTo` function calculates the direction to turn in order to face another object. All we need is the name of another object, such as `banana` or `bridge`.
Another useful skill you are going to learn in this video is walking backwards. Remember that in order to tell the monkey to go forward, we type `step(10)`. So if we want him to go backwards, we type `step(-10)`. The computer will read `-10` in this context as 10 steps backwards.
Now I want to show you a cool trick! If you hover over any object on the stage, you will see its name appear next to it. If you click on the object, its name will be added to the editor. This can come in handy if you don’t feel like typing right now.
Thank you for watching this tutorial! Now it’s time for you to practice turning and walking backwards. But remember, if you do it in real life, be careful not to step on any bananas. Good luck!
—
Let me know if you need any further modifications!
Coding – The process of writing instructions for a computer to follow. – Example sentence: In our computer class, we learned the basics of coding by creating a simple game.
Objects – Items or elements in a program that can hold data and perform actions. – Example sentence: In the game, the characters and the background are all objects that we can control with code.
Functions – Blocks of code that perform a specific task and can be used whenever needed. – Example sentence: We used functions to make the character jump and run in our game.
Turn – To change direction in a program, often used in controlling movement. – Example sentence: The robot will turn left when it reaches the wall.
Degrees – A unit of measurement for angles, often used in programming to control rotation. – Example sentence: We programmed the robot to turn 90 degrees to the right.
Monkey – A playful character often used in coding games to teach programming concepts. – Example sentence: In the coding game, the monkey collects bananas as it moves through the levels.
Step – A single movement or action in a sequence of instructions in a program. – Example sentence: Each step in the program moves the character closer to the goal.
Backwards – Moving in the opposite direction from the way one is facing, often used in programming to control movement. – Example sentence: The robot moved backwards to avoid the obstacle.
Angle – The space between two lines that meet at a point, used in programming to control direction. – Example sentence: We adjusted the angle of the cannon to hit the target in the game.
Banana – A common item or goal in coding games, often used to teach programming concepts. – Example sentence: The monkey collected a banana each time it solved a puzzle in the game.