
Day 19 of 100
Today, I did more on turtle graphics and also leart about event listeners and multiple instances. Basically, an event listener is a function that 'listens' for when you press a certain key and it then preformes an action when you do press that key and multiple instances means having multiple objects from the same class, in my case this would mean having multiple turtles at once. First Project - Drawing from turtle import Turtle , Screen turtle = Turtle () screen = Screen () turtle . shape ( " turtle " ) turtle . pensize ( 2 ) screen . bgcolor ( " #FDFBD4 " ) screen . setup ( width = 700 , height = 500 ) screen . title ( " Etch-a-Sketch " ) def forwards (): turtle . forward ( 10 ) def backwards (): turtle . backward ( 10 ) def clockwise (): turtle . left ( 10 ) def anti_clockwise (): turtle . right ( 10 ) def clearscreen (): turtle . penup () turtle . home () turtle . pendown () turtle . clear () screen . onkey ( forwards , " w " ) screen . onkey ( backwards , " s " ) screen . onkey ( a
Continue reading on Dev.to Python
Opens in a new tab




