dimanche 4 novembre 2018

Multiple Turtles, multiple random movements

I have an assignment where I have to make a game in python with turtles. I am able to generate a grid like I want to, and I am able to generate multiple different turtles. my - I have no clue where to start in terms of figuring out how to have each of my three different turtles each move throughout the board randomly, while staying on the grid line. - the "game" must stop after two of the turtles have hit the edge of the screen, I do not know how to do this, either.

here is what I have so far:

import turtle
import random

turtle.pensize(2)
turtle.penup()
turtle.goto(-160,-160)
turtle.pendown()
turtle.color("green")
turtle.speed(0)
for i in range(4):
    turtle.forward(320)
    turtle.left(90)

for y in range(-160,160,80):
    for x in range(-160,160,80):

        turtle.penup()
        turtle.goto(x,y)
        turtle.pendown()

        for k in range(4):
            turtle.forward(40)
            turtle.left(90)

        turtle.end_fill()       

for y in range(-120,160,80):
    for x in range(-120,160,80):

        turtle.penup()
        turtle.goto(x,y)
        turtle.pendown()
        for k in range(4):
            turtle.forward(40)
            turtle.left(90)


billy = turtle.Turtle()
billy.shape("turtle")
billy.color("red")
billy.penup()
billy.left(90)


rick = turtle.Turtle()
rick.shape("turtle")
rick.color("orange")
rick.penup()



mike = turtle.Turtle()
mike.shape("turtle")
mike.color("purple")
mike.penup()




turtle.done()

strong guidance would be VERY helpful.




Aucun commentaire:

Enregistrer un commentaire