Day 20 - Building the Snake Game: Part 1
Mastering the Digital Serpent

Search for a command to run...
Mastering the Digital Serpent

No comments yet. Be the first to comment.
My journey of learning Python by going through a 100 Days of Code course. The main focus is for me to reflect on what I learned and have written summaries to come back to for future reference.
Leveling Up the games functionality.
The Beta is here...and a new thumbnail. 😏

Reaching the final stretch

Oh, how far I've come... and how far I’ve yet to go.

Embracing TDD, Elevating the UX & Developing CI Workflow Systems

Foundation Laid, Core Functionality Set & QOL Tasks Completed

For the following days (Day 20 and Day 21), the objective is the build the classic Snake game. Angela breaks down the goals for the and part one will consist of:
Creating the snake body by creating 3 squares on the screen last a given starting point.
Moving the snake forward without breaking.
Finally, add the ability to turn the snake.
There weren't any new concepts discussed in today's lesson, but, looking at Day 21, we touch base on Class Inheritance.
This project has to be one of the hardest I've tried yet. More so on all the connected parts than the lack of understanding of certain concepts. We built the snake in our main.py file initially but then migrated the snake build into its own file and Class.
class Snake:
def __init__(self):
self.full_snake = []
self.create_snake()
self.head = self.full_snake[0]
def create_snake(self):
for position in STARTING_POSITION:
new_snake = Turtle(shape="square")
new_snake.penup()
new_snake.goto(position)
self.full_snake.append(new_snake)
After getting it created, we worked on the movement. This part is where I struggled a bit due to needing to work with X and Y coordinates. Trying to get the 3 squares to align like a snake and then move smoothly took some more diving into the Python Turtle Graphics doc. After the snake got moving, we worked on adding the ability to turn it, which was a little bit easier to grasp and code up. After a couple of hours of early AM work, finished part 1! The snake moves forward and can turn without turning on itself.
Video: Snake Game Part 1 Example
Since I'm working on more than one file for this project, I won't be posting everything I wrote today but you can find it in the Day-19 folder on GitHub -> https://github.com/kdleonard93/100-Days-Of-Code_Python/tree/day-20/day-20
That wraps up Part 1 of the Snake Project. Since I worked on this before my normal work hours, there's a chance I'll be posting Part 2 (Day 21) later this evening. There I will make note of the new concept Class Inheritance and wrap up my first full Python game!