def HighlightMutipleHex(self,HexList): self.pathfind.fill((0,0,0,0)) color = pygame.Color(250,250,0, 250) for hex in HexList: if HexMath.checkInGrid(hex[0],hex[1],self.mMap.x,self.mMap.y): radius = self.mMap.radius height = radius * math.sqrt(3) side = radius * 3/2 width = radius * 2 cornerX = [height/2,height,height,height/2,0,0] cornerY = [0,radius/2,side,width,side,radius/2] if hex[1] % 2: #ungrade PixelX = (hex[0]+1)* height -height/2 else: #grade PixelX = hex[0] * height PixelY = hex[1] * side pointlist = [] i = 0 while i <6: pointlist.append((cornerX[i] + PixelX,cornerY[i] + PixelY)) i += 1 pygame.draw.aalines(self.highlight, color,False, pointlist,1)
def HighlightHex(self,ArrayCord): #rebuild this, hex cords are now stored in tile #highlight the selected hex #clear old highlight self.highlight.fill((0,0,0,0)) color = pygame.Color(0,0,250, 250) #check if cord is in grid if HexMath.checkInGrid(ArrayCord[0],ArrayCord[1],self.mMap.x,self.mMap.y): radius = self.mMap.radius height = radius * math.sqrt(3) side = radius * 3/2 width = radius * 2 cornerX = [height/2,height,height,height/2,0,0] cornerY = [0,radius/2,side,width,side,radius/2] if ArrayCord[1] % 2: #ungrade PixelX = (ArrayCord[0]+1)* height -height/2 else: #grade PixelX = ArrayCord[0] * height PixelY = ArrayCord[1] * side pointlist = [] i = 0 while i <6: pointlist.append((cornerX[i] + PixelX,cornerY[i] + PixelY)) i += 1 pygame.draw.aalines(self.highlight, color,False, pointlist,1)