I drove a board with 8x8 dimension by using turtle module. It looks like a chessboard,but it is not,since the black blocks are randomly distributed.
The aim is that I want to make an A-Star Algorithm. The algorithm part is done. However, I am stuck in the graphical interface part.
I was using turtle-graphics
module, but as far as I can understand, it draws the shapes by using a pen, which is move whole specific path by drawing the lines. I was dealing with the functions of turtle module in order to understand what are they.
My question are:
I want to put an object or image into a specific block. In fact, the block that I put into the object will be white.
I also want that object to move from one block to another block like a chess game. (However, it is not).
After one movement, is it possible to fill the previous block with a color ? (Actually, it is possible, I've done this part, but it was a bit time consuming. I mean, the program has to wait a bit to complete the pen movements in order to fill that block with a color.)
import turtle import image Tess=turtle.Turtle() Tess.pensize(1) Tess.speed(-100) w=40 def mysquare(who,thecolor,size): who.pendown() who.pencolor('black') who.fillcolor(thecolor) who.begin_fill() who.setheading(0) for i in range(4): who.forward(size) who.left(90) who.end_fill() for j in range(8): for i in range(8): # print(i,j) if i==5 and j==7 or i==5 and j==6 or i==3 and j==5 or i==7 and j==5 or i==2 and j==4 or i==4 and j==4 or i==5 and j==4 or i==6 and j==4: scolor='black' else: scolor='white' Tess.penup() Tess.goto((i-4)*w,(j-4)*w) mysquare(Tess,scolor,w)