Learning to program a turtle to build different structures.

15
Learning to program a turtle to build different structures

Transcript of Learning to program a turtle to build different structures.

Page 1: Learning to program a turtle to build different structures.

Learning to program a turtle to build different structures

Page 2: Learning to program a turtle to build different structures.

Learning Objective• To move the turtle around using different

libraries

• To program a turtle to try and build different shapes using the different blocks

Page 3: Learning to program a turtle to build different structures.

• It’s a computer which can build for you! It can save you time, ifyou code it!

• It needs fuel so that it can buildand move on to it’s next location

• It is possible to build fullstructures which can be sharedwith friends!

What is the Turtle?

Page 4: Learning to program a turtle to build different structures.

Getting Started• Load up your inventory by

typing ‘E’. This will allow youto search for the ‘turtle’

• You will need a ‘Mining Turtle’

• Click this and then move it into your inventory

• Once in your inventory, addit to your world in a nice flatspace

Page 5: Learning to program a turtle to build different structures.

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.

Page 6: Learning to program a turtle to build different structures.

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 enoughenergy to build

Page 7: Learning to program a turtle to build different structures.

Task 1: - Label your turtle• Right click on your

turtle and it will bring up the programming menu.

• We need to set a label sothat we can alwaysreuse our computer.

• Label set MyTurtleProg

• This should give yourturtle a label

Page 8: Learning to program a turtle to build different structures.

Task 2: - Moving your turtle• Type ‘edit myfirstmovement’

• This will set up your first program which allows you to get your turtle moving around.

Page 9: Learning to program a turtle to build different structures.

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”

Page 10: Learning to program a turtle to build different structures.

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: - >

Page 11: Learning to program a turtle to build different structures.

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()

Page 12: Learning to program a turtle to build different structures.

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

Page 13: Learning to program a turtle to build different structures.

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.

Page 14: Learning to program a turtle to build different structures.

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()

Page 15: Learning to program a turtle to build different structures.

Finishing Up!What is the problemwith the code that

we’ve had to do thislesson?

The next lesson will introduce you tousing a ‘for’ loop

in your programming