OpenBrackets
Intermediate Python
Week 8 Day 2
Welcome!
Welcome to class!
This is the Intermediate Python Programming class. Make sure you’re in the right place!
Schedule for today:
Reminders
Please keep your camera on as much as possible! This helps us know how you’re doing and whether you’re following along. It will also help you stay more engaged.
Don’t be afraid to ask questions!
Asking Questions
Type in chat
Or
How are you doing?
1 2 3 4 5 6 7 8 9 10
Steps for Snake
Step 5: Eating food
Optional: Make sure the next random spot isn’t close enough to the head to be eaten instantly
10 minute break!
Step 6a: Creating snake segments
The segments of the snake are the green parts. The head doesn’t count as a segment.
Each segment will be a square turtle. The color is your choice.
We’ll store our snake segments in a list. Since our snake starts with just a head, we won’t have any segments at the start of the game. Create an empty list for the segments.
0
1
2
Step 6b: Moving snake segments, part 1
This is probably the most difficult part of the game, but give it your best shot!
Step 6c: Adding snake segments
When a piece of food is eaten, we need to add another segment. This segment will go at the end of the snake. Then the snake will move.
Step 6d: Moving snake segments, part 2
Right now, only the first segment is moving.
Extra: using .pos()
.pos() gives us a pair of numbers as the full position of the turtle
We can use
turtle1.goto(turtle2.pos())
instead of
turtle1.goto(turtle2.xcor(), turtle2.ycor())
Thanks for coming to class!
Please let us know if you have any questions!