class MyTurtles(turtle.Turtle, Vuegrille): def createBateau(self, longueur, coords, nom): self.bateau = Bateau(False, longueur, coords, nom) def move(self, x, y): corner = Vuegrille.getcorner(self, x, y) if self.bateau.getOrientation() == False: self.setx(corner[0] + DEFAULT_MARGIN / 8) self.sety(corner[1] - DEFAULT_MARGIN / 4) else: self.setx(corner[0] + DEFAULT_MARGIN / 4) self.sety(corner[1] + DEFAULT_MARGIN / 8) self.bateau.setCoordonnee(self.getcoords(x, y)) def changeOrientation(self, x, y): if (self.bateau.getOrientation() == False): self.left(90) corner = Vuegrille.getcorner(self, x, y) self.setx(corner[0] + DEFAULT_MARGIN / 4) self.sety(corner[1] - (DEFAULT_MARGIN - 5)) self.bateau.setOrientation(True) else: self.right(90) corner = Vuegrille.getcorner(self, x, y) self.setx(corner[0] + (DEFAULT_MARGIN / 8)) self.sety(corner[1] - (DEFAULT_MARGIN / 4)) self.bateau.setOrientation(False)
def createBateau(self, longueur, coords, nom): self.bateau = Bateau(False, longueur, coords, nom)