Turtle graphics drawing over itself

后端 未结 1 1461
故里飘歌
故里飘歌 2021-01-24 19:59

This should be a very simple question, however, it is proving difficult for me. I\'m rather new to turtle graphics, and so, I am trying to get a simple drawing done. My turtle

相关标签:
1条回答
  • 2021-01-24 20:24

    I believe the problem is that you're accidentally drawing on the backstroke. Try this instead:

    for y in range(height):
        turtle.sety(y)
    
        turtle.pendown()
    
        for x in range(width):
            detLand(y, x)
            turtle.setx(x)
    
        turtle.penup()
    
        turtle.setx(0)
    

    I believe your problem is this schism:

    turtle.setx(x)
    turtle.sety(y)
    

    Think about what happens at end of line, you just set Y and then you come around with X = 0 and over draw the line you just finished before Y gets positioned correctly.

    0 讨论(0)
提交回复
热议问题