Download presentation
Presentation is loading. Please wait.
Published byJasper Daniel Modified over 9 years ago
1
Learning to program a turtle to build different structures
2
Learning Objective To move the turtle around using different libraries To program a turtle to try and build different shapes using the different blocks
3
It’s a computer which can build for you! It can save you time, if you code it! It needs fuel so that it can build and move on to it’s next location It is possible to build full structures which can be shared with friends! What is the Turtle?
4
Getting Started Load up your inventory by typing ‘E’. This will allow you to search for the ‘turtle’ You will need a ‘Mining Turtle’ Click this and then move it into your inventory Once in your inventory, add it to your world in a nice flat space
5
Time for Fuel The turtle cannot move unless it has fuel. You will need to search for some coal. Try and add 64 pieces of coal into your inventory so that you can fuel up later. You should then be able to drag it into the bottom of your screen.
6
Task 1: - Fueling Right click on your turtle and it will bring up the programming menu. If you have placed the coal on the right, you should type in “refuel all” This will full up your turtle with enough energy to build
7
Task 1: - Label your turtle Right click on your turtle and it will bring up the programming menu. We need to set a label so that we can always reuse our computer. Label set MyTurtleProg This should give your turtle a label
8
Task 2: - Moving your turtle Type ‘edit myfirstmovement’ This will set up your first program which allows you to get your turtle moving around.
9
Task 2: - Moving your turtle You now have a blank program screen. To get your turtle to move forward you use the following command. Turtle.forward() Press CTRL and SAVE Exit the program and run it by typing “myfirstmovement”
10
Task 2: - Moving your turtle That might have been a little difficult to spot movement. Try and make it sleep between each movement so that you can watch it move. Try this code: - >
11
Task 2: - TINKER TIME!! Now that you have managed to get your turtle to move forward, try and play around with the following: Turtle.forward() Turtle.turnright() Turtle.turnleft() Turtle.up() Turtle.down() Turtle.digDown() Turtle.digUp()
12
Task 3: - Building blocks In order for our turtle to place blocks, you need to place them in the inventory. I’ve placed some wooden planks as the first item of the inventory. You can now place them whenever you move forward. The next slide will show you an example
13
Task 3: - Building blocks Turtle.select(1) – selects the first item from the inventory (of the turtle) Turtle.place() – places the turtle in the world Turtle.back() – moves the turtle back one place This example will create 3 blocks. You will need to use ‘turnLeft’ or ‘TurnRight’ depending on which way you’re facing.
14
Challenge! Using what you’ve learnt so far you’re required to build a 4 by 4 square using the following: Turtle.Select(1) Turtle.forward()* depends on which way you’re facing Turtle.back() * depends on which way you’re facing Turtle.place* places the block onto the screen Turtle.turnRight()* depends on which way you’re facing Turtle.turnLeft()* depends on which way you’re facing EXTENSION: - Are you able to build a program which builds a more than one structure on top of each other…. Turtle.up()
15
Finishing Up! What is the problem with the code that we’ve had to do this lesson? The next lesson will introduce you to using a ‘for’ loop in your programming
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.