I don't understand how to make 1 box that is being cloned for multiple times where every second block has a different color. I thought of making a main box and shape it and then make a loop in which i clone it multiple times, but i cant make the loop to clone it always next to the other clone. Also when it comes to the colors i defined a list which gets gives me an error for this variable not being used i wanted to use it so make every second block in the other color.
def draw_boxes(box_list):
box = Turtle()
box.shape("square")
box.shapesize(1, 3)
color_list = ["cyan", "pink"]
box_list = []
#Box_layer1
for box_layer1 in range(9):
box_layer1 = box.clone()
box_layer1.goto() # not filled in since i dont know how to make the clone go to the other clone
# Box_layer2
# Box_layer3
pass
This seems to cause me a lot of troubles if anyone knows anything it would be amazing.
I see you are defining a
Turtle
object whenever thedraw_boxes
function is called. That would result in far too manyTurtle
s. Instead, define theboxes_list
outside of the function.To iterate through the
box_list
along side each box's index so that the previous box can be accessed during each iteration, useenumerate
.The below code is a demonstration, where the
Turtle
s move in a Slinky movement:Output:
If you want the standard snake game movement:
Output:
UPDATE:
Turns out this is supposed to be a box-breaker game, not a snake game.
For the box breaker game: